Skip to content

Commit

Permalink
change get_environment_manifest_path to an instance variable
Browse files Browse the repository at this point in the history
  • Loading branch information
saikonen committed Sep 20, 2023
1 parent ac4fcbb commit 892ed10
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions metaflow/plugins/pypi/conda_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class CondaEnvironment(MetaflowEnvironment):
def __init__(self, flow, echo):
super(CondaEnvironment, self).__init__(flow, echo)
self.flow = flow
self.environment_manifest_path = os.path.join(
self.local_root, self.flow.name, MAGIC_FILE
)

def decospecs(self):
# Apply conda decorator to manage the task execution lifecycle.
Expand Down Expand Up @@ -267,7 +270,7 @@ def get_client_info(cls, flow_name, metadata):
def add_to_package(self):
# Add manifest file to job package at the top level.
files = []
manifest = self.get_environment_manifest_path()
manifest = self.environment_manifest_path
if os.path.exists(manifest):
files.append((manifest, os.path.basename(manifest)))
return files
Expand All @@ -283,13 +286,8 @@ def bootstrap_commands(self, step_name, datastore_type):
"echo 'Environment bootstrapped.'",
]

# TODO: Make this an instance variable once local_root is part of the object
# constructor.
def get_environment_manifest_path(self):
return os.path.join(self.local_root, self.flow.name, MAGIC_FILE)

def read_from_environment_manifest(self, keys):
path = self.get_environment_manifest_path()
path = self.environment_manifest_path
if os.path.exists(path) and os.path.getsize(path) > 0:
with open(path) as f:
data = json.load(f)
Expand All @@ -301,7 +299,7 @@ def read_from_environment_manifest(self, keys):
return data

def write_to_environment_manifest(self, keys, value):
path = self.get_environment_manifest_path()
path = self.environment_manifest_path
try:
os.makedirs(os.path.dirname(path))
except OSError as x:
Expand Down

0 comments on commit 892ed10

Please sign in to comment.