Skip to content

Commit

Permalink
Convert env to list in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
natefoo committed Feb 9, 2023
1 parent fadf3f6 commit 32e5f3a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tpv/core/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def __init__(self, loader, id=None, abstract=False, cores=None, mem=None, gpus=N
self.max_cores = max_cores
self.max_mem = max_mem
self.max_gpus = max_gpus
self.env = env
self.env = self.convert_env(env)
self.params = params
self.resubmit = resubmit
self.tpv_tags = TagSetManager.from_dict(tpv_tags or {})
Expand Down Expand Up @@ -234,17 +234,17 @@ def evaluate_complex_property(self, prop, context, stringify=False):
return self.process_complex_property(
prop, context, lambda p, c: self.loader.eval_code_block(p, c, as_f_string=True), stringify=stringify)

def convert_env(self):
if isinstance(self.env, dict):
self.env = [dict(name=k, value=v) for (k, v) in self.env.items()]
def convert_env(self, env):
if isinstance(env, dict):
env = [dict(name=k, value=v) for (k, v) in env.items()]
return env

def validate(self):
"""
Validates each code block and makes sure the code can be compiled.
This process also results in the compiled code being cached by the loader,
so that future evaluations are faster.
"""
self.convert_env()
if self.cores:
self.loader.compile_code_block(self.cores)
if self.mem:
Expand Down

0 comments on commit 32e5f3a

Please sign in to comment.