From ab727838e1be5c96c071048fca96738a0aa784b1 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Wed, 12 Jul 2023 11:42:39 -0700 Subject: [PATCH 01/37] remove step feature for local workspaces --- tango/workspace.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tango/workspace.py b/tango/workspace.py index e9bb72815..a7c671a7c 100644 --- a/tango/workspace.py +++ b/tango/workspace.py @@ -20,6 +20,8 @@ from urllib.parse import ParseResult, urlparse import pytz +from sqlitedict import SqliteDict +import shutil from .common import Registrable from .common.from_params import FromParams @@ -419,6 +421,29 @@ def step_result(self, step_name: str) -> Any: return self.step_cache[run.steps[step_name]] raise KeyError(f"No step named '{step_name}' found in previous runs") + + def remove_step(self, step_name: str) -> Any: + """ + Get Step name (Unique ID) from the user and remove the step information from cache + :raises KeyError: If no step with the unique name found in the cache dir + """ + # get path to dir dynamically + sqlite_path = self.dir / "stepinfo.sqlite" + with SqliteDict(sqlite_path) as d: + try: + step_location = d[step_name].result_location + # remove step info from the sqlite dict + del d[step_name] + d.commit() + # remove cache directory + try: + shutil.rmtree(step_location) + except OSError: + raise OSError('Step Cache folder not found') + return('Step deleted') + except KeyError: + raise KeyError(f"No step named '{step_name}' found") + def capture_logs_for_run(self, name: str) -> ContextManager[None]: """ Should return a context manager that can be used to capture the logs for a run. From 2f04716da44c0990e2fd319241207c40afa01127 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Thu, 13 Jul 2023 14:40:33 -0700 Subject: [PATCH 02/37] cleaned code for remove step cache for local workspaces --- tango/step_caches/local_step_cache.py | 8 ++++++++ tango/workspace.py | 29 ++++++++------------------- tango/workspaces/local_workspace.py | 13 ++++++++++++ 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/tango/step_caches/local_step_cache.py b/tango/step_caches/local_step_cache.py index dcc519ae1..d2a9666ea 100644 --- a/tango/step_caches/local_step_cache.py +++ b/tango/step_caches/local_step_cache.py @@ -2,6 +2,7 @@ import logging import warnings import weakref +import shutil from pathlib import Path from typing import Any, MutableMapping, Optional, OrderedDict, Union, cast @@ -147,6 +148,13 @@ def __setitem__(self, step: Step, value: Any) -> None: pass raise + def __delitem__(self, step_unique_id) -> None: + location = self.dir / step_unique_id + try: + shutil.rmtree(location) + except OSError: + raise OSError('Step Cache folder not found') + def __len__(self) -> int: return sum(1 for _ in self.dir.glob(f"*/{self.METADATA_FILE_NAME}")) diff --git a/tango/workspace.py b/tango/workspace.py index a7c671a7c..6446b7786 100644 --- a/tango/workspace.py +++ b/tango/workspace.py @@ -422,27 +422,14 @@ def step_result(self, step_name: str) -> Any: raise KeyError(f"No step named '{step_name}' found in previous runs") - def remove_step(self, step_name: str) -> Any: - """ - Get Step name (Unique ID) from the user and remove the step information from cache - :raises KeyError: If no step with the unique name found in the cache dir - """ - # get path to dir dynamically - sqlite_path = self.dir / "stepinfo.sqlite" - with SqliteDict(sqlite_path) as d: - try: - step_location = d[step_name].result_location - # remove step info from the sqlite dict - del d[step_name] - d.commit() - # remove cache directory - try: - shutil.rmtree(step_location) - except OSError: - raise OSError('Step Cache folder not found') - return('Step deleted') - except KeyError: - raise KeyError(f"No step named '{step_name}' found") + def step_cache_remove(self, step_unique_id: str) -> Any: + """ + Removes cached step using the given unique step id + :raises KeyError: If there is no step with the given name. + """ + raise NotImplementedError() + + def capture_logs_for_run(self, name: str) -> ContextManager[None]: """ diff --git a/tango/workspaces/local_workspace.py b/tango/workspaces/local_workspace.py index 905ca5d79..17c084785 100644 --- a/tango/workspaces/local_workspace.py +++ b/tango/workspaces/local_workspace.py @@ -322,6 +322,19 @@ def step_failed(self, step: Step, e: BaseException) -> None: lock.release() del self.locks[step] + def step_cache_remove(self, step_unique_id: str) -> None: + """ + Get Step unique id from the user and remove the step information from cache + :raises KeyError: If no step with the unique name found in the cache dir + """ + with SqliteDict(self.step_info_file) as d: + try: + del d[step_unique_id] + d.commit() + self.cache.__delitem__(step_unique_id) + except KeyError: + raise KeyError(f"No step named '{step_unique_id}' found") + def register_run(self, targets: Iterable[Step], name: Optional[str] = None) -> Run: # sanity check targets targets = list(targets) From f9d112a80cfaba4d7ab4311b9bf21d9f7617bf8a Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Fri, 14 Jul 2023 11:05:08 -0700 Subject: [PATCH 03/37] resolved comments for local workspace --- tango/workspace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tango/workspace.py b/tango/workspace.py index 6446b7786..92f2642ed 100644 --- a/tango/workspace.py +++ b/tango/workspace.py @@ -422,7 +422,7 @@ def step_result(self, step_name: str) -> Any: raise KeyError(f"No step named '{step_name}' found in previous runs") - def step_cache_remove(self, step_unique_id: str) -> Any: + def step_cache_remove(self, step_unique_id: str): """ Removes cached step using the given unique step id :raises KeyError: If there is no step with the given name. From 15656581f5acd61f8e72976f9640fef1c0b471ca Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Fri, 14 Jul 2023 11:17:52 -0700 Subject: [PATCH 04/37] remove cached step for memory workspaces --- tango/step_caches/memory_step_cache.py | 6 ++++++ tango/workspaces/memory_workspace.py | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/tango/step_caches/memory_step_cache.py b/tango/step_caches/memory_step_cache.py index e57751c70..7844ea13e 100644 --- a/tango/step_caches/memory_step_cache.py +++ b/tango/step_caches/memory_step_cache.py @@ -35,6 +35,12 @@ def __setitem__(self, step: Step, value: Any) -> None: UserWarning, ) + def __delitem__(self, step_unique_id) -> None: + if step_unique_id in self.cache: + del self.cache[step_unique_id] + else: + raise KeyError(f"{step_unique_id} not present in the memory cache. Can't be deleted") + def __contains__(self, step: object) -> bool: if isinstance(step, (Step, StepInfo)): return step.unique_id in self.cache diff --git a/tango/workspaces/memory_workspace.py b/tango/workspaces/memory_workspace.py index bcbb89498..7c039773a 100644 --- a/tango/workspaces/memory_workspace.py +++ b/tango/workspaces/memory_workspace.py @@ -98,6 +98,17 @@ def step_failed(self, step: Step, e: BaseException) -> None: existing_step_info.end_time = utc_now_datetime() existing_step_info.error = exception_to_string(e) + def step_cache_remove(self, step_unique_id: str) -> None: + """ + Get Step unique id from the user and remove the step information from memory cache + :raises KeyError: If no step with the unique name found in the cache dir + """ + try: + del self.unique_id_to_info[step_unique_id] + self.step_cache.__delitem__(step_unique_id) + except KeyError: + raise KeyError(f"{step_unique_id} step info not found, step cache cannot be deleted") + def register_run(self, targets: Iterable[Step], name: Optional[str] = None) -> Run: if name is None: name = petname.generate() From 379567878576b9d131f44093d5aa6a9bd3f3dbf4 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Mon, 17 Jul 2023 21:45:24 -0700 Subject: [PATCH 05/37] tests added --- tango/step_caches/local_step_cache.py | 4 +++- tango/step_caches/memory_step_cache.py | 1 + tango/workspaces/local_workspace.py | 2 ++ tango/workspaces/memory_workspace.py | 3 ++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tango/step_caches/local_step_cache.py b/tango/step_caches/local_step_cache.py index d2a9666ea..d76b3cd1b 100644 --- a/tango/step_caches/local_step_cache.py +++ b/tango/step_caches/local_step_cache.py @@ -1,4 +1,5 @@ import collections +import os import logging import warnings import weakref @@ -149,9 +150,10 @@ def __setitem__(self, step: Step, value: Any) -> None: raise def __delitem__(self, step_unique_id) -> None: - location = self.dir / step_unique_id + location = str(self.dir) + '/' + str(step_unique_id) try: shutil.rmtree(location) + assert not os.path.exists(location) except OSError: raise OSError('Step Cache folder not found') diff --git a/tango/step_caches/memory_step_cache.py b/tango/step_caches/memory_step_cache.py index 7844ea13e..75e39b2f0 100644 --- a/tango/step_caches/memory_step_cache.py +++ b/tango/step_caches/memory_step_cache.py @@ -38,6 +38,7 @@ def __setitem__(self, step: Step, value: Any) -> None: def __delitem__(self, step_unique_id) -> None: if step_unique_id in self.cache: del self.cache[step_unique_id] + assert step_unique_id not in self.cache else: raise KeyError(f"{step_unique_id} not present in the memory cache. Can't be deleted") diff --git a/tango/workspaces/local_workspace.py b/tango/workspaces/local_workspace.py index 17c084785..d6469f0ee 100644 --- a/tango/workspaces/local_workspace.py +++ b/tango/workspaces/local_workspace.py @@ -329,8 +329,10 @@ def step_cache_remove(self, step_unique_id: str) -> None: """ with SqliteDict(self.step_info_file) as d: try: + assert step_unique_id in d del d[step_unique_id] d.commit() + assert step_unique_id not in d self.cache.__delitem__(step_unique_id) except KeyError: raise KeyError(f"No step named '{step_unique_id}' found") diff --git a/tango/workspaces/memory_workspace.py b/tango/workspaces/memory_workspace.py index 7c039773a..687b8f8bd 100644 --- a/tango/workspaces/memory_workspace.py +++ b/tango/workspaces/memory_workspace.py @@ -105,7 +105,8 @@ def step_cache_remove(self, step_unique_id: str) -> None: """ try: del self.unique_id_to_info[step_unique_id] - self.step_cache.__delitem__(step_unique_id) + assert step_unique_id not in self.unique_id_to_info + del self.step_cache[step_unique_id] except KeyError: raise KeyError(f"{step_unique_id} step info not found, step cache cannot be deleted") From 6f3d60cad41449223fa4eb3fd96d0bc17fac02da Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Mon, 17 Jul 2023 22:00:08 -0700 Subject: [PATCH 06/37] fixed style issues --- tango/step_caches/local_step_cache.py | 4 ++-- tango/workspace.py | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tango/step_caches/local_step_cache.py b/tango/step_caches/local_step_cache.py index d76b3cd1b..6191f5176 100644 --- a/tango/step_caches/local_step_cache.py +++ b/tango/step_caches/local_step_cache.py @@ -1,9 +1,9 @@ import collections -import os import logging +import os +import shutil import warnings import weakref -import shutil from pathlib import Path from typing import Any, MutableMapping, Optional, OrderedDict, Union, cast diff --git a/tango/workspace.py b/tango/workspace.py index 92f2642ed..00378b42e 100644 --- a/tango/workspace.py +++ b/tango/workspace.py @@ -20,8 +20,6 @@ from urllib.parse import ParseResult, urlparse import pytz -from sqlitedict import SqliteDict -import shutil from .common import Registrable from .common.from_params import FromParams From ddcbf9e545b36cd94d71f3fec3af7b4a97f9a948 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Mon, 17 Jul 2023 22:20:54 -0700 Subject: [PATCH 07/37] fixed style issues +1 --- tango/step_caches/local_step_cache.py | 4 ++-- tango/workspace.py | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tango/step_caches/local_step_cache.py b/tango/step_caches/local_step_cache.py index 6191f5176..897fa3aeb 100644 --- a/tango/step_caches/local_step_cache.py +++ b/tango/step_caches/local_step_cache.py @@ -150,12 +150,12 @@ def __setitem__(self, step: Step, value: Any) -> None: raise def __delitem__(self, step_unique_id) -> None: - location = str(self.dir) + '/' + str(step_unique_id) + location = str(self.dir) + "/" + str(step_unique_id) try: shutil.rmtree(location) assert not os.path.exists(location) except OSError: - raise OSError('Step Cache folder not found') + raise OSError("Step Cache folder not found") def __len__(self) -> int: return sum(1 for _ in self.dir.glob(f"*/{self.METADATA_FILE_NAME}")) diff --git a/tango/workspace.py b/tango/workspace.py index 00378b42e..d77e94299 100644 --- a/tango/workspace.py +++ b/tango/workspace.py @@ -419,7 +419,6 @@ def step_result(self, step_name: str) -> Any: return self.step_cache[run.steps[step_name]] raise KeyError(f"No step named '{step_name}' found in previous runs") - def step_cache_remove(self, step_unique_id: str): """ Removes cached step using the given unique step id @@ -427,8 +426,6 @@ def step_cache_remove(self, step_unique_id: str): """ raise NotImplementedError() - - def capture_logs_for_run(self, name: str) -> ContextManager[None]: """ Should return a context manager that can be used to capture the logs for a run. From fe06aeb0656174355af417e86f98c39a2ac0de03 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Tue, 18 Jul 2023 10:16:06 -0700 Subject: [PATCH 08/37] step cache place holder --- tango/step_cache.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tango/step_cache.py b/tango/step_cache.py index 29ef70b35..76d8abea1 100644 --- a/tango/step_cache.py +++ b/tango/step_cache.py @@ -48,6 +48,10 @@ def __setitem__(self, step: Step, value: Any) -> None: """Writes the results for the given step. Throws an exception if the step is already cached.""" raise NotImplementedError() + def __delitem__(self, step_unique_id) -> None: + """Removes a step from step cache""" + raise NotImplementedError() + @abstractmethod def __len__(self) -> int: """Returns the number of results saved in this cache.""" From 48661a666deb6e348b057c97240df0d9bbd7ccd3 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Tue, 18 Jul 2023 11:06:44 -0700 Subject: [PATCH 09/37] adding tests --- .../local_workspace_cache_remove_test.py | 25 +++++++++++++++++++ .../memory_workspace_cache_remove_test.py | 24 ++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/workspaces/local_workspace_cache_remove_test.py create mode 100644 tests/workspaces/memory_workspace_cache_remove_test.py diff --git a/tests/workspaces/local_workspace_cache_remove_test.py b/tests/workspaces/local_workspace_cache_remove_test.py new file mode 100644 index 000000000..5b31ed9cc --- /dev/null +++ b/tests/workspaces/local_workspace_cache_remove_test.py @@ -0,0 +1,25 @@ +import pytest + +from tango import Step + +from tango.common.testing import TangoTestCase +from tango.step_info import StepState +from tango.workspaces import LocalWorkspace + + +class AdditionStep(Step): + def run(self, a: int, b: int) -> int: + return a + b + + +class Test_Cache_Remove_Workspace(TangoTestCase): + def test_step_cache_remove(self): + workspace = LocalWorkspace(self.TEST_DIR) + step = AdditionStep(a=1, b=2) + step_info = workspace.step_info(step) + assert step_info.state == StepState.INCOMPLETE + result = step.result(workspace) + step_info = workspace.step_info(step) + assert step_info.state == StepState.COMPLETED + step_unique_id = step.unique_id + workspace.step_cache_remove(step_unique_id) diff --git a/tests/workspaces/memory_workspace_cache_remove_test.py b/tests/workspaces/memory_workspace_cache_remove_test.py new file mode 100644 index 000000000..b5d97fe46 --- /dev/null +++ b/tests/workspaces/memory_workspace_cache_remove_test.py @@ -0,0 +1,24 @@ +# import pytest + +from tango import Step +from tango.step_info import StepState +from tango.workspaces import MemoryWorkspace + + +class AdditionStep(Step): + def run(self, a: int, b: int) -> int: + return a + b + + +def test_step_cache_remove(): + workspace = MemoryWorkspace() + step1 = AdditionStep(a=1, b=2) + step_info = workspace.step_info(step1) + assert step_info.state == StepState.INCOMPLETE + result1 = step1.result(workspace) + step_info = workspace.step_info(step1) + assert step_info.state == StepState.COMPLETED + step1_unique_id = step1.unique_id + workspace.step_cache_remove(step1_unique_id) + + From 1c684055e3e1be4af8c9ad4bd96d3fc7c8934249 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Tue, 18 Jul 2023 11:15:44 -0700 Subject: [PATCH 10/37] fixed styling in tests --- tests/workspaces/local_workspace_cache_remove_test.py | 1 - tests/workspaces/memory_workspace_cache_remove_test.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/tests/workspaces/local_workspace_cache_remove_test.py b/tests/workspaces/local_workspace_cache_remove_test.py index 5b31ed9cc..dccc53ee7 100644 --- a/tests/workspaces/local_workspace_cache_remove_test.py +++ b/tests/workspaces/local_workspace_cache_remove_test.py @@ -1,7 +1,6 @@ import pytest from tango import Step - from tango.common.testing import TangoTestCase from tango.step_info import StepState from tango.workspaces import LocalWorkspace diff --git a/tests/workspaces/memory_workspace_cache_remove_test.py b/tests/workspaces/memory_workspace_cache_remove_test.py index b5d97fe46..d9beaaaa6 100644 --- a/tests/workspaces/memory_workspace_cache_remove_test.py +++ b/tests/workspaces/memory_workspace_cache_remove_test.py @@ -20,5 +20,3 @@ def test_step_cache_remove(): assert step_info.state == StepState.COMPLETED step1_unique_id = step1.unique_id workspace.step_cache_remove(step1_unique_id) - - From bc289c2d3ad886f6deea15cba6ac3f911292603a Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Wed, 19 Jul 2023 11:20:05 -0700 Subject: [PATCH 11/37] abstraction tag added --- tango/step_cache.py | 1 + tango/workspace.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tango/step_cache.py b/tango/step_cache.py index 76d8abea1..b06edaeae 100644 --- a/tango/step_cache.py +++ b/tango/step_cache.py @@ -48,6 +48,7 @@ def __setitem__(self, step: Step, value: Any) -> None: """Writes the results for the given step. Throws an exception if the step is already cached.""" raise NotImplementedError() + @abstractmethod def __delitem__(self, step_unique_id) -> None: """Removes a step from step cache""" raise NotImplementedError() diff --git a/tango/workspace.py b/tango/workspace.py index d77e94299..050c7e587 100644 --- a/tango/workspace.py +++ b/tango/workspace.py @@ -419,6 +419,7 @@ def step_result(self, step_name: str) -> Any: return self.step_cache[run.steps[step_name]] raise KeyError(f"No step named '{step_name}' found in previous runs") + @abstractmethod def step_cache_remove(self, step_unique_id: str): """ Removes cached step using the given unique step id From c2bf197397b1c96c488e1154bec4cc994ab6d4bc Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Thu, 20 Jul 2023 16:19:47 -0700 Subject: [PATCH 12/37] cache remove for GCS remote space --- tango/integrations/gs/workspace.py | 10 ++++++++++ tango/step_caches/local_step_cache.py | 11 +++++++++++ tango/step_caches/remote_step_cache.py | 12 ++++++++++++ tango/workspaces/remote_workspace.py | 21 +++++++++++++++++++++ 4 files changed, 54 insertions(+) diff --git a/tango/integrations/gs/workspace.py b/tango/integrations/gs/workspace.py index 9ad211905..17e00084d 100644 --- a/tango/integrations/gs/workspace.py +++ b/tango/integrations/gs/workspace.py @@ -385,6 +385,16 @@ def _update_step_info(self, step_info: StepInfo): self._ds.put(step_info_entity) + def _remove_step_info(self, step_info: StepInfo) -> None: + # remove dir from bucket + step_artifact = self.client.get(self.Constants.step_artifact_name(step_info)) + if step_artifact is not None: + self.client.delete(step_artifact) + + # remove datastore entities + self._ds.delete(key=self._ds.key("stepinfo", step_info.unique_id)) + + def _save_run_log(self, name: str, log_file: Path): """ The logs are stored in the bucket. The Run object details are stored in diff --git a/tango/step_caches/local_step_cache.py b/tango/step_caches/local_step_cache.py index 897fa3aeb..836d43d4e 100644 --- a/tango/step_caches/local_step_cache.py +++ b/tango/step_caches/local_step_cache.py @@ -91,6 +91,17 @@ def _get_from_cache(self, key: str) -> Optional[Any]: except KeyError: return None + def _remove_from_cache(self, key:str) -> None: + # check and remove from strong cache + if key in self.strong_cache: + del self.strong_cache[key] + assert key not in self.strong_cache + + # check and remove from weak cache + if key in self.weak_cache: + del self.weak_cache[key] + assert key not in self.weak_cache + def _metadata_path(self, step_or_unique_id: Union[Step, StepInfo, str]) -> Path: return self.step_dir(step_or_unique_id) / self.METADATA_FILE_NAME diff --git a/tango/step_caches/remote_step_cache.py b/tango/step_caches/remote_step_cache.py index 0f21ed253..127398722 100644 --- a/tango/step_caches/remote_step_cache.py +++ b/tango/step_caches/remote_step_cache.py @@ -155,3 +155,15 @@ def __setitem__(self, step: Step, value: Any) -> None: # Finally, add to in-memory caches. self._add_to_cache(step.unique_id, value) + + + def __delitem__(self, step_unique_id) -> None: + # check and delete local cache dir + if self.step_dir(step_unique_id).is_dir(): + shutil.rmtree(self.step_dir(step_unique_id)) + + # remove from memory cache + self._remove_from_cache(key=step_unique_id) + + return None + diff --git a/tango/workspaces/remote_workspace.py b/tango/workspaces/remote_workspace.py index 3460ca4a9..e35e012cd 100644 --- a/tango/workspaces/remote_workspace.py +++ b/tango/workspaces/remote_workspace.py @@ -174,6 +174,23 @@ def step_failed(self, step: Step, e: BaseException) -> None: finally: self.locks.pop(step).release() + def step_cache_remove(self, step_unique_id: str) -> None: + """ + Get Step unique id from the user and remove the step information from cache + :raises KeyError: If no step with the unique name found in the cache dir + """ + try: + step_info = self.step_info(step_unique_id) + + # remove remote objects + self._remove_step_info(step_info) + + # remove cache info + del self.cache[step_unique_id] + except KeyError: + raise KeyError(f"No step named '{step_unique_id}' found.") + return None + def _get_run_step_info(self, targets: Iterable[Step]) -> Tuple[Dict, Dict]: import concurrent.futures @@ -229,3 +246,7 @@ def capture_logs_for_run(self, name: str) -> Generator[None, None, None]: @abstractmethod def _update_step_info(self, step_info: StepInfo): raise NotImplementedError() + + @abstractmethod + def _remove_step_info(self, step_info: StepInfo): + raise NotImplementedError() From 525bdb7cd128ff0c55e5e70535610868a8825a4d Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Thu, 20 Jul 2023 16:56:03 -0700 Subject: [PATCH 13/37] fixed style and type issues --- tango/integrations/gs/workspace.py | 1 - tango/integrations/wandb/workspace.py | 7 +++++++ tango/step_caches/local_step_cache.py | 2 +- tango/step_caches/remote_step_cache.py | 2 -- tests/workspaces/local_workspace_cache_remove_test.py | 2 +- tests/workspaces/memory_workspace_cache_remove_test.py | 2 +- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tango/integrations/gs/workspace.py b/tango/integrations/gs/workspace.py index 17e00084d..116e0f8dc 100644 --- a/tango/integrations/gs/workspace.py +++ b/tango/integrations/gs/workspace.py @@ -394,7 +394,6 @@ def _remove_step_info(self, step_info: StepInfo) -> None: # remove datastore entities self._ds.delete(key=self._ds.key("stepinfo", step_info.unique_id)) - def _save_run_log(self, name: str, log_file: Path): """ The logs are stored in the bucket. The Run object details are stored in diff --git a/tango/integrations/wandb/workspace.py b/tango/integrations/wandb/workspace.py index 36e663a0f..6242dd2a8 100644 --- a/tango/integrations/wandb/workspace.py +++ b/tango/integrations/wandb/workspace.py @@ -292,6 +292,13 @@ def step_failed(self, step: Step, e: BaseException) -> None: if step.unique_id in self._running_step_info: del self._running_step_info[step.unique_id] + def step_cache_remove(self, step_unique_id: str): + """ + Removes cached step using the given unique step id + :raises KeyError: If there is no step with the given name. + """ + raise NotImplementedError() + def register_run(self, targets: Iterable[Step], name: Optional[str] = None) -> Run: all_steps = set(targets) for step in targets: diff --git a/tango/step_caches/local_step_cache.py b/tango/step_caches/local_step_cache.py index 836d43d4e..aaece269b 100644 --- a/tango/step_caches/local_step_cache.py +++ b/tango/step_caches/local_step_cache.py @@ -91,7 +91,7 @@ def _get_from_cache(self, key: str) -> Optional[Any]: except KeyError: return None - def _remove_from_cache(self, key:str) -> None: + def _remove_from_cache(self, key: str) -> None: # check and remove from strong cache if key in self.strong_cache: del self.strong_cache[key] diff --git a/tango/step_caches/remote_step_cache.py b/tango/step_caches/remote_step_cache.py index 127398722..d8e1381eb 100644 --- a/tango/step_caches/remote_step_cache.py +++ b/tango/step_caches/remote_step_cache.py @@ -156,7 +156,6 @@ def __setitem__(self, step: Step, value: Any) -> None: # Finally, add to in-memory caches. self._add_to_cache(step.unique_id, value) - def __delitem__(self, step_unique_id) -> None: # check and delete local cache dir if self.step_dir(step_unique_id).is_dir(): @@ -166,4 +165,3 @@ def __delitem__(self, step_unique_id) -> None: self._remove_from_cache(key=step_unique_id) return None - diff --git a/tests/workspaces/local_workspace_cache_remove_test.py b/tests/workspaces/local_workspace_cache_remove_test.py index dccc53ee7..ba3629a5a 100644 --- a/tests/workspaces/local_workspace_cache_remove_test.py +++ b/tests/workspaces/local_workspace_cache_remove_test.py @@ -7,7 +7,7 @@ class AdditionStep(Step): - def run(self, a: int, b: int) -> int: + def run(self, a: int, b: int) -> int: # type: ignore return a + b diff --git a/tests/workspaces/memory_workspace_cache_remove_test.py b/tests/workspaces/memory_workspace_cache_remove_test.py index d9beaaaa6..91dfe4b4e 100644 --- a/tests/workspaces/memory_workspace_cache_remove_test.py +++ b/tests/workspaces/memory_workspace_cache_remove_test.py @@ -6,7 +6,7 @@ class AdditionStep(Step): - def run(self, a: int, b: int) -> int: + def run(self, a: int, b: int) -> int: # type: ignore return a + b From bebf5ce805e428cbcf068fdb0b0b975c9cda4588 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Fri, 21 Jul 2023 12:58:02 -0700 Subject: [PATCH 14/37] style issues --- tango/integrations/wandb/workspace.py | 7 ------- tests/workspaces/local_workspace_cache_remove_test.py | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/tango/integrations/wandb/workspace.py b/tango/integrations/wandb/workspace.py index 6242dd2a8..36e663a0f 100644 --- a/tango/integrations/wandb/workspace.py +++ b/tango/integrations/wandb/workspace.py @@ -292,13 +292,6 @@ def step_failed(self, step: Step, e: BaseException) -> None: if step.unique_id in self._running_step_info: del self._running_step_info[step.unique_id] - def step_cache_remove(self, step_unique_id: str): - """ - Removes cached step using the given unique step id - :raises KeyError: If there is no step with the given name. - """ - raise NotImplementedError() - def register_run(self, targets: Iterable[Step], name: Optional[str] = None) -> Run: all_steps = set(targets) for step in targets: diff --git a/tests/workspaces/local_workspace_cache_remove_test.py b/tests/workspaces/local_workspace_cache_remove_test.py index ba3629a5a..9d16b6886 100644 --- a/tests/workspaces/local_workspace_cache_remove_test.py +++ b/tests/workspaces/local_workspace_cache_remove_test.py @@ -7,7 +7,7 @@ class AdditionStep(Step): - def run(self, a: int, b: int) -> int: # type: ignore + def run(self, a: int, b: int) -> int: # type: ignore return a + b From b31c230138b762e36c54985b9625eeb021138b4d Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Mon, 24 Jul 2023 21:02:43 -0700 Subject: [PATCH 15/37] cache remove for beaker workspace --- tango/integrations/beaker/workspace.py | 10 +++++++++- tango/step_caches/remote_step_cache.py | 2 -- tango/workspaces/remote_workspace.py | 1 - 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tango/integrations/beaker/workspace.py b/tango/integrations/beaker/workspace.py index 69355ae28..276da0f51 100644 --- a/tango/integrations/beaker/workspace.py +++ b/tango/integrations/beaker/workspace.py @@ -417,6 +417,14 @@ def _update_step_info(self, step_info: StepInfo): self.beaker.dataset.upload( step_info_dataset, # folder name json.dumps(step_info.to_json_dict()).encode(), # step info dict. - self.Constants.STEP_INFO_FNAME, # step info filename + self.Constants.STEP_INFO_FNAME, # step info filenambeake quiet=True, ) + + def _remove_step_info(self, step_info: StepInfo) -> None: + # remove dir from beaker workspace + dataset_name = self.Constants.step_artifact_name(step_info) + step_dataset = self.beaker.dataset.get(dataset_name) + if step_dataset is not None: + self.beaker.dataset.delete(step_dataset) + diff --git a/tango/step_caches/remote_step_cache.py b/tango/step_caches/remote_step_cache.py index d8e1381eb..2f6fb5e86 100644 --- a/tango/step_caches/remote_step_cache.py +++ b/tango/step_caches/remote_step_cache.py @@ -163,5 +163,3 @@ def __delitem__(self, step_unique_id) -> None: # remove from memory cache self._remove_from_cache(key=step_unique_id) - - return None diff --git a/tango/workspaces/remote_workspace.py b/tango/workspaces/remote_workspace.py index e35e012cd..75e1bda69 100644 --- a/tango/workspaces/remote_workspace.py +++ b/tango/workspaces/remote_workspace.py @@ -181,7 +181,6 @@ def step_cache_remove(self, step_unique_id: str) -> None: """ try: step_info = self.step_info(step_unique_id) - # remove remote objects self._remove_step_info(step_info) From df5462bfc676aedf53ddb9030e8abef048f51e8e Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Mon, 24 Jul 2023 21:17:52 -0700 Subject: [PATCH 16/37] style check --- tango/integrations/beaker/workspace.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tango/integrations/beaker/workspace.py b/tango/integrations/beaker/workspace.py index 276da0f51..d3ff96f56 100644 --- a/tango/integrations/beaker/workspace.py +++ b/tango/integrations/beaker/workspace.py @@ -427,4 +427,3 @@ def _remove_step_info(self, step_info: StepInfo) -> None: step_dataset = self.beaker.dataset.get(dataset_name) if step_dataset is not None: self.beaker.dataset.delete(step_dataset) - From da9202f829ef2ff81b687ee2bf4fa579b49c77c6 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Wed, 26 Jul 2023 18:55:58 -0700 Subject: [PATCH 17/37] suggested changes + tests --- tango/step_caches/local_step_cache.py | 6 ++-- tango/step_caches/memory_step_cache.py | 9 +++--- tango/step_caches/remote_step_cache.py | 8 +++--- tango/workspace.py | 2 +- tango/workspaces/local_workspace.py | 7 ++--- tango/workspaces/memory_workspace.py | 6 ++-- tango/workspaces/remote_workspace.py | 4 +-- tests/integrations/beaker/workspace_test.py | 1 + tests/integrations/gs/workspace_test.py | 28 +++++++++++++++++++ .../local_workspace_cache_remove_test.py | 24 ---------------- tests/workspaces/local_workspace_test.py | 22 +++++++++++++++ .../memory_workspace_cache_remove_test.py | 22 --------------- tests/workspaces/memory_workspace_test.py | 20 +++++++++++++ 13 files changed, 91 insertions(+), 68 deletions(-) delete mode 100644 tests/workspaces/local_workspace_cache_remove_test.py delete mode 100644 tests/workspaces/memory_workspace_cache_remove_test.py create mode 100644 tests/workspaces/memory_workspace_test.py diff --git a/tango/step_caches/local_step_cache.py b/tango/step_caches/local_step_cache.py index aaece269b..c65e9dcb6 100644 --- a/tango/step_caches/local_step_cache.py +++ b/tango/step_caches/local_step_cache.py @@ -160,11 +160,11 @@ def __setitem__(self, step: Step, value: Any) -> None: pass raise - def __delitem__(self, step_unique_id) -> None: - location = str(self.dir) + "/" + str(step_unique_id) + def __delitem__(self, step: Union[Step, StepInfo]) -> None: + location = str(self.dir) + "/" + str(step.unique_id) try: shutil.rmtree(location) - assert not os.path.exists(location) + self._remove_from_cache(step.unique_id) except OSError: raise OSError("Step Cache folder not found") diff --git a/tango/step_caches/memory_step_cache.py b/tango/step_caches/memory_step_cache.py index 75e39b2f0..184b7a4ce 100644 --- a/tango/step_caches/memory_step_cache.py +++ b/tango/step_caches/memory_step_cache.py @@ -35,12 +35,11 @@ def __setitem__(self, step: Step, value: Any) -> None: UserWarning, ) - def __delitem__(self, step_unique_id) -> None: - if step_unique_id in self.cache: - del self.cache[step_unique_id] - assert step_unique_id not in self.cache + def __delitem__(self, step: Union[Step, StepInfo]) -> None: + if step.unique_id in self.cache: + del self.cache[step.unique_id] else: - raise KeyError(f"{step_unique_id} not present in the memory cache. Can't be deleted") + raise KeyError(f"{step.unique_id} not present in the memory cache. Cannot be deleted.") def __contains__(self, step: object) -> bool: if isinstance(step, (Step, StepInfo)): diff --git a/tango/step_caches/remote_step_cache.py b/tango/step_caches/remote_step_cache.py index 2f6fb5e86..74950fcc0 100644 --- a/tango/step_caches/remote_step_cache.py +++ b/tango/step_caches/remote_step_cache.py @@ -156,10 +156,10 @@ def __setitem__(self, step: Step, value: Any) -> None: # Finally, add to in-memory caches. self._add_to_cache(step.unique_id, value) - def __delitem__(self, step_unique_id) -> None: + def __delitem__(self, step: Union[Step, StepInfo]) -> None: # check and delete local cache dir - if self.step_dir(step_unique_id).is_dir(): - shutil.rmtree(self.step_dir(step_unique_id)) + if self.step_dir(step.unique_id).is_dir(): + shutil.rmtree(self.step_dir(step.unique_id)) # remove from memory cache - self._remove_from_cache(key=step_unique_id) + self._remove_from_cache(key=step.unique_id) diff --git a/tango/workspace.py b/tango/workspace.py index 050c7e587..1261b267b 100644 --- a/tango/workspace.py +++ b/tango/workspace.py @@ -420,7 +420,7 @@ def step_result(self, step_name: str) -> Any: raise KeyError(f"No step named '{step_name}' found in previous runs") @abstractmethod - def step_cache_remove(self, step_unique_id: str): + def remove_step(self, step_unique_id: str): """ Removes cached step using the given unique step id :raises KeyError: If there is no step with the given name. diff --git a/tango/workspaces/local_workspace.py b/tango/workspaces/local_workspace.py index d6469f0ee..61b4113e4 100644 --- a/tango/workspaces/local_workspace.py +++ b/tango/workspaces/local_workspace.py @@ -322,18 +322,17 @@ def step_failed(self, step: Step, e: BaseException) -> None: lock.release() del self.locks[step] - def step_cache_remove(self, step_unique_id: str) -> None: + def remove_step(self, step_unique_id: str) -> None: """ Get Step unique id from the user and remove the step information from cache :raises KeyError: If no step with the unique name found in the cache dir """ with SqliteDict(self.step_info_file) as d: try: - assert step_unique_id in d + step_info = self.step_info(step_unique_id) del d[step_unique_id] d.commit() - assert step_unique_id not in d - self.cache.__delitem__(step_unique_id) + del self.cache[step_info] except KeyError: raise KeyError(f"No step named '{step_unique_id}' found") diff --git a/tango/workspaces/memory_workspace.py b/tango/workspaces/memory_workspace.py index 687b8f8bd..47b29c077 100644 --- a/tango/workspaces/memory_workspace.py +++ b/tango/workspaces/memory_workspace.py @@ -98,15 +98,15 @@ def step_failed(self, step: Step, e: BaseException) -> None: existing_step_info.end_time = utc_now_datetime() existing_step_info.error = exception_to_string(e) - def step_cache_remove(self, step_unique_id: str) -> None: + def remove_step(self, step_unique_id: str) -> None: """ Get Step unique id from the user and remove the step information from memory cache :raises KeyError: If no step with the unique name found in the cache dir """ try: + step_info = self.step_info(step_unique_id) del self.unique_id_to_info[step_unique_id] - assert step_unique_id not in self.unique_id_to_info - del self.step_cache[step_unique_id] + del self.step_cache[step_info] except KeyError: raise KeyError(f"{step_unique_id} step info not found, step cache cannot be deleted") diff --git a/tango/workspaces/remote_workspace.py b/tango/workspaces/remote_workspace.py index 75e1bda69..49d351a9f 100644 --- a/tango/workspaces/remote_workspace.py +++ b/tango/workspaces/remote_workspace.py @@ -174,7 +174,7 @@ def step_failed(self, step: Step, e: BaseException) -> None: finally: self.locks.pop(step).release() - def step_cache_remove(self, step_unique_id: str) -> None: + def remove_step(self, step_unique_id: str) -> None: """ Get Step unique id from the user and remove the step information from cache :raises KeyError: If no step with the unique name found in the cache dir @@ -185,7 +185,7 @@ def step_cache_remove(self, step_unique_id: str) -> None: self._remove_step_info(step_info) # remove cache info - del self.cache[step_unique_id] + del self.cache[step_info] except KeyError: raise KeyError(f"No step named '{step_unique_id}' found.") return None diff --git a/tests/integrations/beaker/workspace_test.py b/tests/integrations/beaker/workspace_test.py index 4c68bcef0..f6f0d71d2 100644 --- a/tests/integrations/beaker/workspace_test.py +++ b/tests/integrations/beaker/workspace_test.py @@ -4,6 +4,7 @@ from tango.workspace import Workspace + def test_from_url(beaker_workspace: str): workspace = Workspace.from_url(f"beaker://{beaker_workspace}") assert isinstance(workspace, BeakerWorkspace) diff --git a/tests/integrations/gs/workspace_test.py b/tests/integrations/gs/workspace_test.py index 28318db8e..290776a04 100644 --- a/tests/integrations/gs/workspace_test.py +++ b/tests/integrations/gs/workspace_test.py @@ -40,3 +40,31 @@ def test_direct_usage(self): workspace.step_finished(step, 1.0) assert workspace.step_info(step).state == StepState.COMPLETED assert workspace.step_result_for_run(run.name, "float") == 1.0 + + def test_remove_step(self): + workspace = GSWorkspace(GS_BUCKET_NAME) + step = FloatStep(step_name="float", result=1.0) + step_info = workspace.step_info(step) + + workspace.step_starting(step) + workspace.step_finished(step, 1.0) + bucket_artifact = workspace.Constants.step_artifact_name(step_info) + ds_entity = workspace._ds.get(key=workspace._ds.key("stepinfo", step_info.unique_id)) + cache = workspace.step_cache + + assert workspace.client.artifacts(prefix=bucket_artifact) is not None + assert ds_entity is not None + assert step in cache + + workspace.remove_step(step.unique_id) + cache = workspace.step_cache + + ds_entity = workspace._ds.get(key=workspace._ds.key("stepinfo", step_info.unique_id)) + + try: + workspace.client.artifacts(prefix=bucket_artifact) + except KeyError: + pass + #to assert that the artifact is no longer present in the bucket + assert ds_entity is None + assert step not in cache diff --git a/tests/workspaces/local_workspace_cache_remove_test.py b/tests/workspaces/local_workspace_cache_remove_test.py deleted file mode 100644 index 9d16b6886..000000000 --- a/tests/workspaces/local_workspace_cache_remove_test.py +++ /dev/null @@ -1,24 +0,0 @@ -import pytest - -from tango import Step -from tango.common.testing import TangoTestCase -from tango.step_info import StepState -from tango.workspaces import LocalWorkspace - - -class AdditionStep(Step): - def run(self, a: int, b: int) -> int: # type: ignore - return a + b - - -class Test_Cache_Remove_Workspace(TangoTestCase): - def test_step_cache_remove(self): - workspace = LocalWorkspace(self.TEST_DIR) - step = AdditionStep(a=1, b=2) - step_info = workspace.step_info(step) - assert step_info.state == StepState.INCOMPLETE - result = step.result(workspace) - step_info = workspace.step_info(step) - assert step_info.state == StepState.COMPLETED - step_unique_id = step.unique_id - workspace.step_cache_remove(step_unique_id) diff --git a/tests/workspaces/local_workspace_test.py b/tests/workspaces/local_workspace_test.py index b987a87c3..b48777649 100644 --- a/tests/workspaces/local_workspace_test.py +++ b/tests/workspaces/local_workspace_test.py @@ -1,4 +1,5 @@ from shutil import copytree +from sqlitedict import SqliteDict import pytest @@ -8,6 +9,7 @@ from tango.workspaces import LocalWorkspace + class AdditionStep(Step): def run(self, a: int, b: int) -> int: # type: ignore return a + b @@ -73,3 +75,23 @@ def test_local_workspace_upgrade_v1_to_v2(self): while len(dependencies) > 0: step_info = workspace.step_info(dependencies.pop()) dependencies.extend(step_info.dependencies) + + def test_remove_step(self): + workspace = LocalWorkspace(self.TEST_DIR) + step = AdditionStep(a=1, b=2) + workspace.step_starting(step) + workspace.step_finished(step, 1.0) + + with SqliteDict(workspace.step_info_file) as d: + assert step.unique_id in d + + cache = workspace.step_cache + assert step in cache + + workspace.remove_step(step.unique_id) + + with SqliteDict(workspace.step_info_file) as d: + assert step.unique_id not in d + + cache = workspace.step_cache + assert step not in cache \ No newline at end of file diff --git a/tests/workspaces/memory_workspace_cache_remove_test.py b/tests/workspaces/memory_workspace_cache_remove_test.py deleted file mode 100644 index 91dfe4b4e..000000000 --- a/tests/workspaces/memory_workspace_cache_remove_test.py +++ /dev/null @@ -1,22 +0,0 @@ -# import pytest - -from tango import Step -from tango.step_info import StepState -from tango.workspaces import MemoryWorkspace - - -class AdditionStep(Step): - def run(self, a: int, b: int) -> int: # type: ignore - return a + b - - -def test_step_cache_remove(): - workspace = MemoryWorkspace() - step1 = AdditionStep(a=1, b=2) - step_info = workspace.step_info(step1) - assert step_info.state == StepState.INCOMPLETE - result1 = step1.result(workspace) - step_info = workspace.step_info(step1) - assert step_info.state == StepState.COMPLETED - step1_unique_id = step1.unique_id - workspace.step_cache_remove(step1_unique_id) diff --git a/tests/workspaces/memory_workspace_test.py b/tests/workspaces/memory_workspace_test.py new file mode 100644 index 000000000..9a84d8af8 --- /dev/null +++ b/tests/workspaces/memory_workspace_test.py @@ -0,0 +1,20 @@ +from tango.common.testing.steps import FloatStep +from tango.workspaces import MemoryWorkspace + + +def test_remove_step(): + workspace = MemoryWorkspace() + step = FloatStep(step_name="float", result=1.0) + + workspace.step_starting(step) + workspace.step_finished(step, 1.0) + cache = workspace.step_cache + + assert step.unique_id in workspace.unique_id_to_info + assert step in cache + + workspace.remove_step(step.unique_id) + cache = workspace.step_cache + + assert step.unique_id not in workspace.unique_id_to_info + assert step not in cache \ No newline at end of file From 9b90608de27ca93ccac9d568a11c1cbbb500778a Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Wed, 26 Jul 2023 19:03:12 -0700 Subject: [PATCH 18/37] style changes fixed --- tests/integrations/beaker/workspace_test.py | 1 - tests/workspaces/local_workspace_test.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/integrations/beaker/workspace_test.py b/tests/integrations/beaker/workspace_test.py index f6f0d71d2..4c68bcef0 100644 --- a/tests/integrations/beaker/workspace_test.py +++ b/tests/integrations/beaker/workspace_test.py @@ -4,7 +4,6 @@ from tango.workspace import Workspace - def test_from_url(beaker_workspace: str): workspace = Workspace.from_url(f"beaker://{beaker_workspace}") assert isinstance(workspace, BeakerWorkspace) diff --git a/tests/workspaces/local_workspace_test.py b/tests/workspaces/local_workspace_test.py index b48777649..2c66568ee 100644 --- a/tests/workspaces/local_workspace_test.py +++ b/tests/workspaces/local_workspace_test.py @@ -1,7 +1,7 @@ from shutil import copytree -from sqlitedict import SqliteDict import pytest +from sqlitedict import SqliteDict from tango import Step from tango.common.testing import TangoTestCase @@ -9,7 +9,6 @@ from tango.workspaces import LocalWorkspace - class AdditionStep(Step): def run(self, a: int, b: int) -> int: # type: ignore return a + b From 59d44e43a96d424f82fd439351f4ca2e819ea792 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Thu, 27 Jul 2023 11:35:42 -0700 Subject: [PATCH 19/37] tests for remote workspaces --- tests/integrations/beaker/workspace_test.py | 27 +++++++++++++++++++++ tests/integrations/gs/workspace_test.py | 9 ++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/tests/integrations/beaker/workspace_test.py b/tests/integrations/beaker/workspace_test.py index 4c68bcef0..2701d4938 100644 --- a/tests/integrations/beaker/workspace_test.py +++ b/tests/integrations/beaker/workspace_test.py @@ -1,3 +1,5 @@ +import pytest + from tango.common.testing.steps import FloatStep from tango.integrations.beaker.workspace import BeakerWorkspace from tango.step_info import StepState @@ -5,6 +7,7 @@ def test_from_url(beaker_workspace: str): + print(beaker_workspace) workspace = Workspace.from_url(f"beaker://{beaker_workspace}") assert isinstance(workspace, BeakerWorkspace) @@ -22,3 +25,27 @@ def test_direct_usage(beaker_workspace: str): workspace.step_finished(step, 1.0) assert workspace.step_info(step).state == StepState.COMPLETED assert workspace.step_result_for_run(run.name, "float") == 1.0 + +def test_remove_step(beaker_workspace: str): + beaker_workspace = 'ai2/tango_remove_cache_test' + workspace = BeakerWorkspace(beaker_workspace) + step = FloatStep(step_name="float", result=1.0) + + workspace.step_starting(step) + workspace.step_finished(step, 1.0) + + step_info = workspace.step_info(step) + dataset_name = workspace.Constants.step_artifact_name(step_info) + cache = workspace.step_cache + + assert workspace.beaker.dataset.get(dataset_name) is not None + assert step in cache + + workspace.remove_step(step.unique_id) + cache = workspace.step_cache + dataset_name = workspace.Constants.step_artifact_name(step_info) + + with pytest.raises(Exception) as excinfo: + workspace.beaker.dataset.get(dataset_name) + assert 'DatasetNotFound' in str(excinfo) + assert step not in cache diff --git a/tests/integrations/gs/workspace_test.py b/tests/integrations/gs/workspace_test.py index 290776a04..ac2452f0b 100644 --- a/tests/integrations/gs/workspace_test.py +++ b/tests/integrations/gs/workspace_test.py @@ -1,5 +1,7 @@ import os +import pytest + from tango.common.testing import TangoTestCase from tango.common.testing.steps import FloatStep from tango.integrations.gs.common import empty_bucket, empty_datastore @@ -61,10 +63,9 @@ def test_remove_step(self): ds_entity = workspace._ds.get(key=workspace._ds.key("stepinfo", step_info.unique_id)) - try: + with pytest.raises(Exception) as excinfo: workspace.client.artifacts(prefix=bucket_artifact) - except KeyError: - pass - #to assert that the artifact is no longer present in the bucket + + assert 'KeyError' in str(excinfo) assert ds_entity is None assert step not in cache From 0cbd3f92194fbfcb8180870d364c3af7875174d1 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Thu, 27 Jul 2023 13:18:35 -0700 Subject: [PATCH 20/37] style and type checks --- tango/integrations/wandb/workspace.py | 7 +++++++ tests/integrations/beaker/workspace_test.py | 5 +++-- tests/integrations/gs/workspace_test.py | 2 +- tests/workspaces/local_workspace_test.py | 2 +- tests/workspaces/memory_workspace_test.py | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tango/integrations/wandb/workspace.py b/tango/integrations/wandb/workspace.py index 36e663a0f..97b008484 100644 --- a/tango/integrations/wandb/workspace.py +++ b/tango/integrations/wandb/workspace.py @@ -292,6 +292,13 @@ def step_failed(self, step: Step, e: BaseException) -> None: if step.unique_id in self._running_step_info: del self._running_step_info[step.unique_id] + def remove_step(self, step_unique_id: str): + """ + Removes cached step using the given unique step id + :raises KeyError: If there is no step with the given name. + """ + raise NotImplementedError() + def register_run(self, targets: Iterable[Step], name: Optional[str] = None) -> Run: all_steps = set(targets) for step in targets: diff --git a/tests/integrations/beaker/workspace_test.py b/tests/integrations/beaker/workspace_test.py index 2701d4938..350614750 100644 --- a/tests/integrations/beaker/workspace_test.py +++ b/tests/integrations/beaker/workspace_test.py @@ -26,8 +26,9 @@ def test_direct_usage(beaker_workspace: str): assert workspace.step_info(step).state == StepState.COMPLETED assert workspace.step_result_for_run(run.name, "float") == 1.0 + def test_remove_step(beaker_workspace: str): - beaker_workspace = 'ai2/tango_remove_cache_test' + beaker_workspace = "ai2/tango_remove_cache_test" workspace = BeakerWorkspace(beaker_workspace) step = FloatStep(step_name="float", result=1.0) @@ -47,5 +48,5 @@ def test_remove_step(beaker_workspace: str): with pytest.raises(Exception) as excinfo: workspace.beaker.dataset.get(dataset_name) - assert 'DatasetNotFound' in str(excinfo) + assert "DatasetNotFound" in str(excinfo) assert step not in cache diff --git a/tests/integrations/gs/workspace_test.py b/tests/integrations/gs/workspace_test.py index ac2452f0b..c5ffd137b 100644 --- a/tests/integrations/gs/workspace_test.py +++ b/tests/integrations/gs/workspace_test.py @@ -66,6 +66,6 @@ def test_remove_step(self): with pytest.raises(Exception) as excinfo: workspace.client.artifacts(prefix=bucket_artifact) - assert 'KeyError' in str(excinfo) + assert "KeyError" in str(excinfo) assert ds_entity is None assert step not in cache diff --git a/tests/workspaces/local_workspace_test.py b/tests/workspaces/local_workspace_test.py index 2c66568ee..58c4dacf5 100644 --- a/tests/workspaces/local_workspace_test.py +++ b/tests/workspaces/local_workspace_test.py @@ -93,4 +93,4 @@ def test_remove_step(self): assert step.unique_id not in d cache = workspace.step_cache - assert step not in cache \ No newline at end of file + assert step not in cache diff --git a/tests/workspaces/memory_workspace_test.py b/tests/workspaces/memory_workspace_test.py index 9a84d8af8..41529ee07 100644 --- a/tests/workspaces/memory_workspace_test.py +++ b/tests/workspaces/memory_workspace_test.py @@ -17,4 +17,4 @@ def test_remove_step(): cache = workspace.step_cache assert step.unique_id not in workspace.unique_id_to_info - assert step not in cache \ No newline at end of file + assert step not in cache From e4749a3b820277d34854ec0202021b3eb75802af Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Thu, 27 Jul 2023 13:51:17 -0700 Subject: [PATCH 21/37] incorporated suggestions --- tango/step_caches/remote_step_cache.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tango/step_caches/remote_step_cache.py b/tango/step_caches/remote_step_cache.py index 74950fcc0..4999797ba 100644 --- a/tango/step_caches/remote_step_cache.py +++ b/tango/step_caches/remote_step_cache.py @@ -157,9 +157,4 @@ def __setitem__(self, step: Step, value: Any) -> None: self._add_to_cache(step.unique_id, value) def __delitem__(self, step: Union[Step, StepInfo]) -> None: - # check and delete local cache dir - if self.step_dir(step.unique_id).is_dir(): - shutil.rmtree(self.step_dir(step.unique_id)) - - # remove from memory cache - self._remove_from_cache(key=step.unique_id) + super().__delitem__(step) \ No newline at end of file From 889298c4b574aef9055e4c613219e4dc3bd19245 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Thu, 27 Jul 2023 14:20:56 -0700 Subject: [PATCH 22/37] adding PR review changes --- tango/integrations/transformers/__init__.py | 2 ++ tango/step_caches/remote_step_cache.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tango/integrations/transformers/__init__.py b/tango/integrations/transformers/__init__.py index 927a126a2..92941c5f0 100644 --- a/tango/integrations/transformers/__init__.py +++ b/tango/integrations/transformers/__init__.py @@ -98,6 +98,8 @@ transformers::AutoModelForSpeechSeq2Seq::from_pretrained transformers::AutoModelForTableQuestionAnswering::from_config transformers::AutoModelForTableQuestionAnswering::from_pretrained + transformers::AutoModelForTextEncoding::from_config + transformers::AutoModelForTextEncoding::from_pretrained transformers::AutoModelForTokenClassification::from_config transformers::AutoModelForTokenClassification::from_pretrained transformers::AutoModelForUniversalSegmentation::from_config diff --git a/tango/step_caches/remote_step_cache.py b/tango/step_caches/remote_step_cache.py index 4999797ba..2b11c2625 100644 --- a/tango/step_caches/remote_step_cache.py +++ b/tango/step_caches/remote_step_cache.py @@ -157,4 +157,4 @@ def __setitem__(self, step: Step, value: Any) -> None: self._add_to_cache(step.unique_id, value) def __delitem__(self, step: Union[Step, StepInfo]) -> None: - super().__delitem__(step) \ No newline at end of file + super().__delitem__(step) From e1a37bdd297b09608116a1cb7a8cd5b3117ad902 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Wed, 13 Sep 2023 16:52:38 -0700 Subject: [PATCH 23/37] Update tango/integrations/beaker/workspace.py Co-authored-by: Akshita Bhagia --- tango/integrations/beaker/workspace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tango/integrations/beaker/workspace.py b/tango/integrations/beaker/workspace.py index d3ff96f56..1915fc719 100644 --- a/tango/integrations/beaker/workspace.py +++ b/tango/integrations/beaker/workspace.py @@ -417,7 +417,7 @@ def _update_step_info(self, step_info: StepInfo): self.beaker.dataset.upload( step_info_dataset, # folder name json.dumps(step_info.to_json_dict()).encode(), # step info dict. - self.Constants.STEP_INFO_FNAME, # step info filenambeake + self.Constants.STEP_INFO_FNAME, # step info filename quiet=True, ) From df93c21d3da7ec352709a79877b6c59d53e5dee3 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Thu, 14 Sep 2023 10:48:40 -0700 Subject: [PATCH 24/37] Update tango/step_caches/local_step_cache.py Co-authored-by: Akshita Bhagia --- tango/step_caches/local_step_cache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tango/step_caches/local_step_cache.py b/tango/step_caches/local_step_cache.py index c65e9dcb6..1ed9dcd12 100644 --- a/tango/step_caches/local_step_cache.py +++ b/tango/step_caches/local_step_cache.py @@ -166,7 +166,7 @@ def __delitem__(self, step: Union[Step, StepInfo]) -> None: shutil.rmtree(location) self._remove_from_cache(step.unique_id) except OSError: - raise OSError("Step Cache folder not found") + raise OSError(f"Step cache folder for '{step.unique_id}' not found. Cannot be deleted.") def __len__(self) -> int: return sum(1 for _ in self.dir.glob(f"*/{self.METADATA_FILE_NAME}")) From 9be5ff80eb1098ba223188c390c11dff971ac8a7 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Thu, 14 Sep 2023 10:49:07 -0700 Subject: [PATCH 25/37] Update tango/step_cache.py Co-authored-by: Akshita Bhagia --- tango/step_cache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tango/step_cache.py b/tango/step_cache.py index b06edaeae..a7228e190 100644 --- a/tango/step_cache.py +++ b/tango/step_cache.py @@ -49,7 +49,7 @@ def __setitem__(self, step: Step, value: Any) -> None: raise NotImplementedError() @abstractmethod - def __delitem__(self, step_unique_id) -> None: + def __delitem__(self, step_unique_id: str) -> None: """Removes a step from step cache""" raise NotImplementedError() From b5a65d69330229f8198e0b6d9b25eb57c7889d21 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Thu, 14 Sep 2023 10:50:00 -0700 Subject: [PATCH 26/37] Update tango/step_caches/remote_step_cache.py Co-authored-by: Akshita Bhagia --- tango/step_caches/remote_step_cache.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tango/step_caches/remote_step_cache.py b/tango/step_caches/remote_step_cache.py index 2b11c2625..0f21ed253 100644 --- a/tango/step_caches/remote_step_cache.py +++ b/tango/step_caches/remote_step_cache.py @@ -155,6 +155,3 @@ def __setitem__(self, step: Step, value: Any) -> None: # Finally, add to in-memory caches. self._add_to_cache(step.unique_id, value) - - def __delitem__(self, step: Union[Step, StepInfo]) -> None: - super().__delitem__(step) From 0c2d1015304be98b3cf96ab0699f94c8db7da331 Mon Sep 17 00:00:00 2001 From: Akshita Bhagia Date: Thu, 14 Sep 2023 16:34:18 -0700 Subject: [PATCH 27/37] make lint happy --- tango/common/from_params.py | 2 +- tests/common/from_params_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tango/common/from_params.py b/tango/common/from_params.py index 9575c8874..fb7bf63be 100644 --- a/tango/common/from_params.py +++ b/tango/common/from_params.py @@ -514,7 +514,7 @@ def construct_arg( ) elif annotation == str: # Strings are special because we allow casting from Path to str. - if type(popped_params) == str or isinstance(popped_params, Path): + if isinstance(popped_params, str) or isinstance(popped_params, Path): return str(popped_params) # type: ignore else: raise TypeError( diff --git a/tests/common/from_params_test.py b/tests/common/from_params_test.py index 4c0bc4af8..40c983d2f 100644 --- a/tests/common/from_params_test.py +++ b/tests/common/from_params_test.py @@ -470,7 +470,7 @@ def __init__(self, a: str, x: int = 42, **kwargs): assert instance.x == 42 assert instance.a == -1 assert len(instance.rest) == 1 # type: ignore - assert type(instance.rest["raw_a"]) == str # type: ignore + assert isinstance(instance.rest["raw_a"], str) # type: ignore assert instance.rest["raw_a"] == "123" # type: ignore def test_kwargs_are_passed_to_deeper_superclasses(self): From 9b21a09915955810188c3a699f4eb361e4564175 Mon Sep 17 00:00:00 2001 From: Akshita Bhagia Date: Thu, 14 Sep 2023 16:44:18 -0700 Subject: [PATCH 28/37] fix type --- tango/step_cache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tango/step_cache.py b/tango/step_cache.py index a7228e190..99dea91a4 100644 --- a/tango/step_cache.py +++ b/tango/step_cache.py @@ -49,7 +49,7 @@ def __setitem__(self, step: Step, value: Any) -> None: raise NotImplementedError() @abstractmethod - def __delitem__(self, step_unique_id: str) -> None: + def __delitem__(self, step_unique_id: Union[Step, StepInfo]) -> None: """Removes a step from step cache""" raise NotImplementedError() From 97e99094b4452e1e9ebba44893334bf078663eb9 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Fri, 15 Sep 2023 11:53:51 -0700 Subject: [PATCH 29/37] Update tests/integrations/beaker/workspace_test.py Co-authored-by: Akshita Bhagia --- tests/integrations/beaker/workspace_test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/integrations/beaker/workspace_test.py b/tests/integrations/beaker/workspace_test.py index 350614750..dc6b9cdb5 100644 --- a/tests/integrations/beaker/workspace_test.py +++ b/tests/integrations/beaker/workspace_test.py @@ -46,7 +46,6 @@ def test_remove_step(beaker_workspace: str): cache = workspace.step_cache dataset_name = workspace.Constants.step_artifact_name(step_info) - with pytest.raises(Exception) as excinfo: + with pytest.raises(DatasetNotFound): workspace.beaker.dataset.get(dataset_name) - assert "DatasetNotFound" in str(excinfo) assert step not in cache From b164eb615a2e81940f96893c8f1a3c3333f1747f Mon Sep 17 00:00:00 2001 From: Akshita Bhagia Date: Fri, 15 Sep 2023 15:33:12 -0700 Subject: [PATCH 30/37] add missing import --- tests/integrations/beaker/workspace_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integrations/beaker/workspace_test.py b/tests/integrations/beaker/workspace_test.py index dc6b9cdb5..d42a1064b 100644 --- a/tests/integrations/beaker/workspace_test.py +++ b/tests/integrations/beaker/workspace_test.py @@ -1,4 +1,5 @@ import pytest +from beaker import DatasetNotFound from tango.common.testing.steps import FloatStep from tango.integrations.beaker.workspace import BeakerWorkspace From 1e59e14a775d3068d91d854a9f47cad76abcb14c Mon Sep 17 00:00:00 2001 From: Akshita Bhagia Date: Fri, 15 Sep 2023 15:38:14 -0700 Subject: [PATCH 31/37] we shouldn't have to update this list everytime a new model is added to HF --- tango/integrations/transformers/__init__.py | 73 +-------------------- 1 file changed, 3 insertions(+), 70 deletions(-) diff --git a/tango/integrations/transformers/__init__.py b/tango/integrations/transformers/__init__.py index 92941c5f0..386e48ecb 100644 --- a/tango/integrations/transformers/__init__.py +++ b/tango/integrations/transformers/__init__.py @@ -44,78 +44,11 @@ from tango.integrations.torch import Model from tango.integrations.transformers import * + available_models = [] + for name in sorted(Model.list_available()): if name.startswith("transformers::AutoModel"): - print(name) - - .. testoutput:: - - transformers::AutoModel::from_config - transformers::AutoModel::from_pretrained - transformers::AutoModelForAudioClassification::from_config - transformers::AutoModelForAudioClassification::from_pretrained - transformers::AutoModelForAudioFrameClassification::from_config - transformers::AutoModelForAudioFrameClassification::from_pretrained - transformers::AutoModelForAudioXVector::from_config - transformers::AutoModelForAudioXVector::from_pretrained - transformers::AutoModelForCTC::from_config - transformers::AutoModelForCTC::from_pretrained - transformers::AutoModelForCausalLM::from_config - transformers::AutoModelForCausalLM::from_pretrained - transformers::AutoModelForDepthEstimation::from_config - transformers::AutoModelForDepthEstimation::from_pretrained - transformers::AutoModelForDocumentQuestionAnswering::from_config - transformers::AutoModelForDocumentQuestionAnswering::from_pretrained - transformers::AutoModelForImageClassification::from_config - transformers::AutoModelForImageClassification::from_pretrained - transformers::AutoModelForImageSegmentation::from_config - transformers::AutoModelForImageSegmentation::from_pretrained - transformers::AutoModelForInstanceSegmentation::from_config - transformers::AutoModelForInstanceSegmentation::from_pretrained - transformers::AutoModelForMaskGeneration::from_config - transformers::AutoModelForMaskGeneration::from_pretrained - transformers::AutoModelForMaskedImageModeling::from_config - transformers::AutoModelForMaskedImageModeling::from_pretrained - transformers::AutoModelForMaskedLM::from_config - transformers::AutoModelForMaskedLM::from_pretrained - transformers::AutoModelForMultipleChoice::from_config - transformers::AutoModelForMultipleChoice::from_pretrained - transformers::AutoModelForNextSentencePrediction::from_config - transformers::AutoModelForNextSentencePrediction::from_pretrained - transformers::AutoModelForObjectDetection::from_config - transformers::AutoModelForObjectDetection::from_pretrained - transformers::AutoModelForPreTraining::from_config - transformers::AutoModelForPreTraining::from_pretrained - transformers::AutoModelForQuestionAnswering::from_config - transformers::AutoModelForQuestionAnswering::from_pretrained - transformers::AutoModelForSemanticSegmentation::from_config - transformers::AutoModelForSemanticSegmentation::from_pretrained - transformers::AutoModelForSeq2SeqLM::from_config - transformers::AutoModelForSeq2SeqLM::from_pretrained - transformers::AutoModelForSequenceClassification::from_config - transformers::AutoModelForSequenceClassification::from_pretrained - transformers::AutoModelForSpeechSeq2Seq::from_config - transformers::AutoModelForSpeechSeq2Seq::from_pretrained - transformers::AutoModelForTableQuestionAnswering::from_config - transformers::AutoModelForTableQuestionAnswering::from_pretrained - transformers::AutoModelForTextEncoding::from_config - transformers::AutoModelForTextEncoding::from_pretrained - transformers::AutoModelForTokenClassification::from_config - transformers::AutoModelForTokenClassification::from_pretrained - transformers::AutoModelForUniversalSegmentation::from_config - transformers::AutoModelForUniversalSegmentation::from_pretrained - transformers::AutoModelForVideoClassification::from_config - transformers::AutoModelForVideoClassification::from_pretrained - transformers::AutoModelForVision2Seq::from_config - transformers::AutoModelForVision2Seq::from_pretrained - transformers::AutoModelForVisualQuestionAnswering::from_config - transformers::AutoModelForVisualQuestionAnswering::from_pretrained - transformers::AutoModelForZeroShotImageClassification::from_config - transformers::AutoModelForZeroShotImageClassification::from_pretrained - transformers::AutoModelForZeroShotObjectDetection::from_config - transformers::AutoModelForZeroShotObjectDetection::from_pretrained - transformers::AutoModelWithLMHead::from_config - transformers::AutoModelWithLMHead::from_pretrained + available_models.append(name) - :class:`~tango.integrations.torch.Optimizer`: All optimizers from transformers are registered according to their class names (e.g. "transformers::AdaFactor"). From 945451ba1bef90795c014e812b60085c4b91dc09 Mon Sep 17 00:00:00 2001 From: Akshita Bhagia Date: Fri, 15 Sep 2023 16:01:31 -0700 Subject: [PATCH 32/37] ignore type error --- tango/common/file_lock.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tango/common/file_lock.py b/tango/common/file_lock.py index b76c2858d..45874a26a 100644 --- a/tango/common/file_lock.py +++ b/tango/common/file_lock.py @@ -39,9 +39,9 @@ def acquire( # type: ignore[override] if err.errno not in (1, 13, 30): raise - if os.path.isfile(self._lock_file) and self._read_only_ok: + if os.path.isfile(self._lock_file) and self._read_only_ok: # type: ignore warnings.warn( - f"Lacking permissions required to obtain lock '{self._lock_file}'. " + f"Lacking permissions required to obtain lock '{self._lock_file}'. " # type: ignore "Race conditions are possible if other processes are writing to the same resource.", UserWarning, ) @@ -62,7 +62,7 @@ def acquire_with_updates(self, desc: Optional[str] = None) -> AcquireReturnProxy from .tqdm import Tqdm if desc is None: - desc = f"acquiring lock at {self._lock_file}" + desc = f"acquiring lock at {self._lock_file}" # type: ignore progress = Tqdm.tqdm(desc=desc, bar_format="{desc} [{elapsed}]") while True: From 0294f8dd0c1300de9cefca0227ebe9685eb0e094 Mon Sep 17 00:00:00 2001 From: Akshita Bhagia Date: Fri, 15 Sep 2023 16:04:07 -0700 Subject: [PATCH 33/37] explicitly add jaxlib --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 5548dfd91..e8d6822b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,6 +90,7 @@ fairscale = [ flax = [ "datasets>=1.12,<3.0", "jax>=0.3.13", + "jaxlib>=0.4.11", "flax>=0.5.0", "optax>=0.1.2", "tensorflow-cpu>=2.9.1" From 107dd945dc3f9eb0ccc4ce8d8fd64ec295d555e7 Mon Sep 17 00:00:00 2001 From: Akshita Bhagia Date: Fri, 15 Sep 2023 16:13:36 -0700 Subject: [PATCH 34/37] wrong place --- .github/workflows/main.yml | 2 +- pyproject.toml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d1b7b4a0c..b29e50605 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -211,7 +211,7 @@ jobs: if: steps.virtualenv-cache.outputs.cache-hit != 'true' && (contains(matrix.task.extras, 'flax') || contains(matrix.task.extras, 'all')) run: | . .venv/bin/activate - pip install flax==0.5.0 jax==0.3.13 jaxlib==0.3.10 tensorflow-cpu==2.9.1 optax==0.1.3 + pip install flax==0.5.0 jax==0.3.13 jaxlib==0.4.11 tensorflow-cpu==2.9.1 optax==0.1.3 - name: Install editable (no cache hit) if: steps.virtualenv-cache.outputs.cache-hit != 'true' diff --git a/pyproject.toml b/pyproject.toml index e8d6822b0..5548dfd91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,7 +90,6 @@ fairscale = [ flax = [ "datasets>=1.12,<3.0", "jax>=0.3.13", - "jaxlib>=0.4.11", "flax>=0.5.0", "optax>=0.1.2", "tensorflow-cpu>=2.9.1" From d03a50b9f8c9dc64236a3c4dc7b5390f78384001 Mon Sep 17 00:00:00 2001 From: Pranjali Basmatkar Date: Fri, 15 Sep 2023 16:43:46 -0700 Subject: [PATCH 35/37] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0939be634..1967a52d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + - Added the `Workspace.remove_step()` method to safely remove steps. + ### Fixed - Removed unnecessary code coverage dev requirements. From 93dafdef3cd89778af9ba4e3a7b00a17c6995f4c Mon Sep 17 00:00:00 2001 From: Akshita Bhagia Date: Mon, 18 Sep 2023 11:21:39 -0700 Subject: [PATCH 36/37] update cache --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b29e50605..d69b4cf06 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,7 @@ on: - "v*.*.*" env: - CACHE_PREFIX: v3 # Change this to invalidate existing cache. + CACHE_PREFIX: v4 # Change this to invalidate existing cache. PYTHON_PATH: ./ DEFAULT_PYTHON: 3.9 WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }} From dd8e852429b0b54301ac8060b3cbf18925d3e5ef Mon Sep 17 00:00:00 2001 From: Akshita Bhagia Date: Mon, 18 Sep 2023 11:37:08 -0700 Subject: [PATCH 37/37] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d69b4cf06..7c2e1d065 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,7 @@ on: - "v*.*.*" env: - CACHE_PREFIX: v4 # Change this to invalidate existing cache. + CACHE_PREFIX: v5 # Change this to invalidate existing cache. PYTHON_PATH: ./ DEFAULT_PYTHON: 3.9 WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }} @@ -211,7 +211,7 @@ jobs: if: steps.virtualenv-cache.outputs.cache-hit != 'true' && (contains(matrix.task.extras, 'flax') || contains(matrix.task.extras, 'all')) run: | . .venv/bin/activate - pip install flax==0.5.0 jax==0.3.13 jaxlib==0.4.11 tensorflow-cpu==2.9.1 optax==0.1.3 + pip install flax==0.5.0 jax==0.3.13 jaxlib==0.3.10 tensorflow-cpu==2.9.1 optax==0.1.3 - name: Install editable (no cache hit) if: steps.virtualenv-cache.outputs.cache-hit != 'true'