Skip to content

Commit

Permalink
Merge pull request #713 from deepmodeling/zjgemi
Browse files Browse the repository at this point in the history
fix: subpath when parsing yaml fix: with_param in debug mode fix: parse type in yaml
  • Loading branch information
zjgemi authored Nov 22, 2023
2 parents 65d5ae3 + 847251f commit 003f16d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/dflow/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,11 @@ def __init__(

@classmethod
def from_dict(cls, d):
_type = json.loads(d.get("description", "{}")).get("type")
kwargs = {
"name": d.get("name", None),
# for backward compatible
"type": str if json.loads(d.get("description", "{}")).get(
"type", "str") in ["str", str(str)] else None,
"type": str if _type in ["str", str(str)] else _type,
}
if "value" in d:
kwargs["value"] = d["value"]
Expand Down Expand Up @@ -854,12 +854,12 @@ def __init__(

@classmethod
def from_dict(cls, d):
_type = json.loads(d.get("description", "{}")).get("type")
kwargs = {
"name": d.get("name", None),
"value_from_path": d.get("valueFrom", {}).get("path", None),
# for backward compatible
"type": str if json.loads(d.get("description", "{}")).get(
"type", "str") in ["str", str(str)] else None,
"type": str if _type in ["str", str(str)] else _type,
"global_name": d.get("globalName", None),
"value_from_expression": d.get("valueFrom", {}).get("expression",
None),
Expand Down
6 changes: 6 additions & 0 deletions src/dflow/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,10 @@ def set_artifacts(self, artifacts):
del self.inputs.artifacts[k]
else:
self.inputs.artifacts[k].source = v
if isinstance(v, str) and "}}/" in v:
i = v.find("}}/")
self.inputs.artifacts[k].source = v[:i+2]
self.inputs.artifacts[k].sp = v[i+3:]
if getattr(v, "slice", None) is not None:
self.template = self.template.copy()
if isinstance(v.slice, (InputParameter, OutputParameter)):
Expand Down Expand Up @@ -1494,6 +1498,8 @@ def handle_expr(val, scope):
elif isinstance(self.with_param, (InputParameter,
OutputParameter)):
item_list = self.with_param.value
elif isinstance(self.with_param, ArgoVar):
item_list = Expression(self.with_param.expr).eval(scope)
elif isinstance(self.with_param, str):
self.with_param = render_expr(self.with_param, scope)
item_list = eval(self.with_param)
Expand Down

0 comments on commit 003f16d

Please sign in to comment.