Skip to content

Commit

Permalink
Remove Sentinel dependency. (#81)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Jalani Kanem <[email protected]>
  • Loading branch information
3 people authored Feb 5, 2022
1 parent de128fc commit 5440b6f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.24.4
0.24.5
9 changes: 1 addition & 8 deletions covalent/_shared_files/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

import os

import sentinel

prefix_separator = ":"

parameter_prefix = f"{prefix_separator}parameter{prefix_separator}"
Expand Down Expand Up @@ -73,7 +71,7 @@
}

# Metadata which may influence execution behavior
default_constraints_dict = {
_DEFAULT_CONSTRAINT_VALUES = {
"schedule": False,
"num_cpu": 1,
"cpu_feature_set": [],
Expand All @@ -86,8 +84,3 @@
"budget": 0,
"conda_env": "",
}

_DEFAULT_CONSTRAINT_VALUES = sentinel.create(
"_DEFAULT_CONSTRAINT_VALUES",
cls_dict=default_constraints_dict.copy(),
)
18 changes: 9 additions & 9 deletions covalent/_workflow/electron.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}]")
Expand Down Expand Up @@ -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}")
Expand All @@ -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}]")
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)

Expand All @@ -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 <covalent._workflow.electron.Electron>` object.
Expand Down
2 changes: 1 addition & 1 deletion covalent/_workflow/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5440b6f

Please sign in to comment.