Skip to content

Commit

Permalink
Don't remove content when not running normally
Browse files Browse the repository at this point in the history
  • Loading branch information
bpiwowar committed May 12, 2024
1 parent 758c4db commit 1091555
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
18 changes: 16 additions & 2 deletions src/xpmir/experiments/ir.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Any, List, Optional, Dict
import logging
import pandas as pd
from pathlib import Path
import click
import io
Expand Down Expand Up @@ -120,13 +121,26 @@ def cli(upload_to_hub: str):
tb_logs=results.tb_logs,
)

print(results.evaluations.to_dataframe()) # noqa: T201
# Print the results
df = results.evaluations.to_dataframe()
pd.set_option("display.max_columns", None)
pd.set_option("display.max_rows", None)
pd.set_option("display.width", 200)
print(df) # noqa: T201

# And save them
csv_path = self.xp.resultspath / "results.csv"
logging.info(f"Saved results in {csv_path.absolute()}")
with csv_path.open("wt") as fp:
df.to_csv(fp, index=False)

return cli(extra_args, standalone_mode=False)

@cached_property
def tensorboard_service(self):
return self.xp.add_service(TensorboardService(self.xp.resultspath / "runs"))
return self.xp.add_service(
TensorboardService(self.xp, self.xp.resultspath / "runs")
)


ir_experiment = IRExperimentHelper.decorator
Expand Down
12 changes: 0 additions & 12 deletions src/xpmir/experiments/learning.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import inspect
from functools import cached_property

from xpmir.experiments import ExperimentHelper
Expand All @@ -11,17 +10,6 @@ def tensorboard_service(self) -> TensorboardService:
"""Returns a tensorboard service"""
return self.xp.add_service(TensorboardService(self.xp.resultspath / "runs"))

# TODO: remove when in experimaestro
@classmethod
def decorator(cls, *args, **kwargs):
if len(args) == 1 and len(kwargs) == 0 and inspect.isfunction(args[0]):
return cls(callable)

def wrapper(callable):
return cls(callable)

return wrapper


learning_experiment = LearningExperimentHelper.decorator
"""Wraps an experiment into an experiment where a model is learned
Expand Down

0 comments on commit 1091555

Please sign in to comment.