Skip to content

Commit

Permalink
feat: add experiment.save_revision()
Browse files Browse the repository at this point in the history
  • Loading branch information
zbjornson committed Oct 25, 2024
1 parent c006319 commit be6d1b2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ v1.0.0 will be the first stable release of the CellEngine Python Toolkit.
permissions required for some operations.
* All tests now run against a real CellEngine instance instead of using mocks,
avoiding bugs due to stale mocks.
* Support for `experiment.save_revision()`.
9 changes: 9 additions & 0 deletions cellengine/resources/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,15 @@ def undelete(self) -> None:
self.deleted = None
ce.APIClient().update_experiment(self._id, {"deleted": self.deleted})

def save_revision(self, description: str) -> None:
"""
Saves a revision of the experiment. The new revision will be the last
entry in the `revisions` property.
"""
r = ce.APIClient().save_experiment_revision(self._id, description)
self._properties["revisions"] = r.get("revisions")
self._properties["deepUpdated"] = r.get("deepUpdated")

# Attachments

@property
Expand Down
6 changes: 6 additions & 0 deletions cellengine/utils/api_client/APIClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ def delete_experiment(self, _id):
"""
self._delete(f"{self.base_url}/api/v1/experiments/{_id}")

def save_experiment_revision(self, _id, description: str) -> Dict:
return self._post(
f"{self.base_url}/api/v1/experiments/{_id}/revision",
json={"description": description},
)

# ------------------------------- FCS Files --------------------------------

def get_fcs_files(self, experiment_id, as_dict=False) -> List[FcsFile]:
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/test_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ def test_experiment_clone(blank_experiment: Experiment):
assert exp.name == blank_experiment.name + "-1"


def test_save_revision(blank_experiment):
preDU = blank_experiment.deep_updated
blank_experiment.save_revision("my description")
assert len(blank_experiment.revisions) == 1
assert blank_experiment.revisions[0].get("description") == "my description"
assert blank_experiment.deep_updated > preDU


def test_experiment_upload_fcs_file(blank_experiment: Experiment):
file = blank_experiment.upload_fcs_file(
"tests/data/Specimen_001_A1_A01_MeOHperm(DL350neg).fcs"
Expand Down

0 comments on commit be6d1b2

Please sign in to comment.