Skip to content

Commit

Permalink
cleanup conda/pypi usage of _user_defined_attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
saikonen committed Dec 9, 2024
1 parent 3c5a3f2 commit ff1c433
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
21 changes: 3 additions & 18 deletions metaflow/plugins/pypi/conda_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,9 @@ class CondaStepDecorator(StepDecorator):
# CONDA_CHANNELS in their environment. For pinning specific packages to specific
# conda channels, users can specify channel::package as the package name.

def __init__(self, attributes=None, statically_defined=False):
self._user_defined_attributes = (
attributes.copy() if attributes is not None else {}
)
super(CondaStepDecorator, self).__init__(attributes, statically_defined)

def init(self):
super(CondaStepDecorator, self).init()

# We have to go back and fixup _user_defined_attributes for potential
# config resolution
self._user_defined_attributes = {
k: v
for k, v in self.attributes.items()
if k in self._user_defined_attributes
}

# Support legacy 'libraries=' attribute for the decorator.
self.attributes["packages"] = {
**self.attributes["libraries"],
Expand Down Expand Up @@ -94,10 +80,9 @@ def step_init(self, flow, graph, step, decos, environment, flow_datastore, logge
**super_attributes["packages"],
**self.attributes["packages"],
}
self._user_defined_attributes = {
**self._user_defined_attributes,
**conda_base._user_defined_attributes,
}
self._user_defined_attributes = self._user_defined_attributes.union(
conda_base._user_defined_attributes
)
self.attributes["python"] = (
self.attributes["python"] or super_attributes["python"]
)
Expand Down
13 changes: 3 additions & 10 deletions metaflow/plugins/pypi/pypi_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ class PyPIStepDecorator(StepDecorator):
name = "pypi"
defaults = {"packages": {}, "python": None, "disabled": None} # wheels

def __init__(self, attributes=None, statically_defined=False):
self._user_defined_attributes = (
attributes.copy() if attributes is not None else {}
)
super().__init__(attributes, statically_defined)

def step_init(self, flow, graph, step, decos, environment, flow_datastore, logger):
# The init_environment hook for Environment creates the relevant virtual
# environments. The step_init hook sets up the relevant state for that hook to
Expand All @@ -42,10 +36,9 @@ def step_init(self, flow, graph, step, decos, environment, flow_datastore, logge
if "pypi_base" in self.flow._flow_decorators:
pypi_base = self.flow._flow_decorators["pypi_base"][0]
super_attributes = pypi_base.attributes
self._user_defined_attributes = {
**self._user_defined_attributes,
**pypi_base._user_defined_attributes,
}
self._user_defined_attributes = self._user_defined_attributes.union(
pypi_base._user_defined_attributes
)
self.attributes["packages"] = {
**super_attributes["packages"],
**self.attributes["packages"],
Expand Down

0 comments on commit ff1c433

Please sign in to comment.