Skip to content

Commit

Permalink
addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sonaalthaker committed Feb 14, 2024
1 parent 800f623 commit 6fd8ee7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
2 changes: 1 addition & 1 deletion rubicon_ml/domain/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ def add_comments(self, comments: List[str]):
comments : List[str]
A list of string comments to add to the domain model.
"""
self.comments = list(set(self.comments).union(set(comments)))
self.comments.extend(comments)
29 changes: 4 additions & 25 deletions rubicon_ml/repository/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1219,31 +1219,10 @@ def _get_comment_metadata_root(
self, project_name, experiment_id=None, entity_identifier=None, entity_type=None
):
"""Returns the directory to write comments to."""
get_metadata_root_lookup = {
"Artifact": self._get_artifact_metadata_root,
"Dataframe": self._get_dataframe_metadata_root,
"Experiment": self._get_experiment_metadata_root,
"Metric": self._get_metric_metadata_root,
"Feature": self._get_feature_metadata_root,
"Parameter": self._get_parameter_metadata_root,
}

try:
get_metadata_root = get_metadata_root_lookup[entity_type]
except KeyError:
raise ValueError("`experiment_id` and `entity_identifier` can not both be `None`.")

if entity_type == "Experiment":
experiment_metadata_root = get_metadata_root(project_name)

return f"{experiment_metadata_root}/{experiment_id}"
else:
entity_metadata_root = get_metadata_root(project_name, experiment_id)

# We want to slugify the names of Metrics, Features, and Parameters- not Artifacts, Dataframes, or Experiments
if entity_type in ["Metric", "Feature", "Parameter"]:
entity_identifier = slugify(entity_identifier)
return f"{entity_metadata_root}/{entity_identifier}"
# comments and tags are currently written to the same root with a different filename
return self._get_tag_metadata_root(
project_name, experiment_id, entity_identifier, entity_type
)

def add_comments(
self, project_name, comments, experiment_id=None, entity_identifier=None, entity_type=None
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/repository/test_base_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ def test_add_comments(memory_repository):
experiment = _create_experiment(repository)
repository.add_comments(
experiment.project_name,
["wow"],
["this is a comment"],
experiment_id=experiment.id,
entity_type=experiment.__class__.__name__,
)
Expand All @@ -1001,4 +1001,4 @@ def test_add_comments(memory_repository):
with open_file as f:
comments_json = json.load(f)

assert ["wow"] == comments_json["added_comments"]
assert ["this is a comment"] == comments_json["added_comments"]

0 comments on commit 6fd8ee7

Please sign in to comment.