From 5440b6fab2971a51947844c19d33e0f422f23022 Mon Sep 17 00:00:00 2001 From: Casey Jao Date: Sat, 5 Feb 2022 11:04:11 -0500 Subject: [PATCH] Remove Sentinel dependency. (#81) * Remove Sentinel dependency. Sentinel was only being used as a dictionary of default values, so just use a regular dictionary instead. * Update VERSION and Changelog * Updated CHANGELOG date. Co-authored-by: jkanem Co-authored-by: Jalani Kanem --- CHANGELOG.md | 6 ++++++ VERSION | 2 +- covalent/_shared_files/defaults.py | 9 +-------- covalent/_workflow/electron.py | 18 +++++++++--------- covalent/_workflow/lattice.py | 2 +- requirements.txt | 1 - 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ced6ed90e..478867cb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.24.5] - 2022-02-05 + +### Fixed + +- Removed dependence on Sentinel module + ## [0.24.4] - 2022-02-04 ### Added diff --git a/VERSION b/VERSION index 4b8c9a554..7a8169a27 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.24.4 +0.24.5 diff --git a/covalent/_shared_files/defaults.py b/covalent/_shared_files/defaults.py index b8fb26e9d..d3f4d9e9e 100644 --- a/covalent/_shared_files/defaults.py +++ b/covalent/_shared_files/defaults.py @@ -22,8 +22,6 @@ import os -import sentinel - prefix_separator = ":" parameter_prefix = f"{prefix_separator}parameter{prefix_separator}" @@ -73,7 +71,7 @@ } # Metadata which may influence execution behavior -default_constraints_dict = { +_DEFAULT_CONSTRAINT_VALUES = { "schedule": False, "num_cpu": 1, "cpu_feature_set": [], @@ -86,8 +84,3 @@ "budget": 0, "conda_env": "", } - -_DEFAULT_CONSTRAINT_VALUES = sentinel.create( - "_DEFAULT_CONSTRAINT_VALUES", - cls_dict=default_constraints_dict.copy(), -) diff --git a/covalent/_workflow/electron.py b/covalent/_workflow/electron.py index ff0ac3a26..efaf70a9e 100644 --- a/covalent/_workflow/electron.py +++ b/covalent/_workflow/electron.py @@ -30,7 +30,6 @@ from .._shared_files.defaults import ( _DEFAULT_CONSTRAINT_VALUES, attr_prefix, - default_constraints_dict, electron_dict_prefix, electron_list_prefix, generator_prefix, @@ -236,7 +235,7 @@ def __iter__(self): kwargs={"key": i}, name=node_name, function=None, - metadata=default_constraints_dict.copy(), + metadata=_DEFAULT_CONSTRAINT_VALUES.copy(), ) active_lattice.transport_graph.add_edge(self.node_id, node_id, f"[{i}]") @@ -272,7 +271,7 @@ def __getattr__(self, attr: str) -> "Electron": kwargs={"attr": attr}, name=node_name, function=None, - metadata=default_constraints_dict.copy(), + metadata=_DEFAULT_CONSTRAINT_VALUES.copy(), ) active_lattice.transport_graph.add_edge(self.node_id, node_id, f".{attr}") @@ -299,7 +298,7 @@ def __getitem__(self, key: Union[int, str]) -> "Electron": kwargs={"key": key}, name=node_name, function=None, - metadata=default_constraints_dict.copy(), + metadata=_DEFAULT_CONSTRAINT_VALUES.copy(), ) active_lattice.transport_graph.add_edge(self.node_id, node_id, f"[{key}]") @@ -350,8 +349,9 @@ def __call__(self, *args, **kwargs) -> Union[Any, "Electron"]: # Setting metadata for default values according to lattice's metadata # If metadata is default, then set it to lattice's default for k in self.metadata: - if k not in consumable_constraints and self.get_metadata(k) is getattr( - _DEFAULT_CONSTRAINT_VALUES, k + if ( + k not in consumable_constraints + and self.get_metadata(k) is _DEFAULT_CONSTRAINT_VALUES[k] ): self.set_metadata(k, active_lattice.get_metadata(k)) @@ -408,7 +408,7 @@ def to_electron_collection(**x): kwargs={key: value}, name=prefix, function=to_electron_collection, - metadata=default_constraints_dict.copy(), + metadata=_DEFAULT_CONSTRAINT_VALUES.copy(), ) graph.set_node_value( @@ -466,7 +466,7 @@ def add_node_for_nested_iterables( kwargs=argument_kwargs, name=parameter_prefix + str(some_value), function=None, - metadata=default_constraints_dict.copy(), + metadata=_DEFAULT_CONSTRAINT_VALUES.copy(), ) transport_graph.add_edge(argument_node, node_id, variable=key) @@ -476,7 +476,7 @@ def electron( *, backend: Optional[ Union[List[Union[str, "BaseExecutor"]], Union[str, "BaseExecutor"]] - ] = _DEFAULT_CONSTRAINT_VALUES.backend, + ] = _DEFAULT_CONSTRAINT_VALUES["backend"], # Add custom metadata fields here ) -> Callable: """Electron decorator to be called upon a function. Returns a new :obj:`Electron ` object. diff --git a/covalent/_workflow/lattice.py b/covalent/_workflow/lattice.py index bccd28bf7..5288fa4f5 100644 --- a/covalent/_workflow/lattice.py +++ b/covalent/_workflow/lattice.py @@ -334,7 +334,7 @@ def lattice( *, backend: Optional[ Union[List[Union[str, "BaseExecutor"]], Union[str, "BaseExecutor"]] - ] = _DEFAULT_CONSTRAINT_VALUES.backend, + ] = _DEFAULT_CONSTRAINT_VALUES["backend"], results_dir: Optional[str] = get_config("dispatcher.results_dir"), # Add custom metadata fields here # e.g. schedule: True, whether to use a custom scheduling logic or not diff --git a/requirements.txt b/requirements.txt index b34eef3c1..ce549a074 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,6 @@ gunicorn==20.1.0 matplotlib==3.5.1 networkx==2.5 requests==2.24.0 -sentinel==0.3.0 simplejson==3.17.6 tailer==0.4.1 toml==0.10.2