bug(conditional expression): always false when running `test_conditional_outputs.py`
saltball opened this issue · 0 comments
Checklist
- Checked the syntax is legal within dflow.
- Tested using the latest version. (pydflow=1.2.1)
Summary
What happened/what you expected to happen?
When I run dflow with conditional expressions, such as
examples/test_conditional_outputs.py
, it always output with false conditions.
What version are you running?
pydflow=1.2.1
Diagnostics
Paste the smallest python script that reproduces the bug
Maybe a solution
dflow generate the conditional expression with if_expression
as in examples/test_conditional_outputs.py
(https://github.com/deepmodeling/dflow/blob/master/examples/test_conditional_outputs.py)
dflow/examples/test_conditional_outputs.py
Lines 59 to 67 in 7386566
It seems
src/dflow/io.py
translate the expression to a string for argo api with
Line 171 in 7386566
However, argo api final submit the job with
fromExpression
as :
artifacts:
- name: res
fromExpression: >-
steps['random'].outputs.parameters['is_head'] == true ?
steps['random'].outputs.artifacts['foo'] :
steps['random'].outputs.artifacts['bar']
In where
steps['random'].outputs.parameters['is_head'] == true
comparestring
'true'
with booleantrue
, and always returnfalse
.
Thus I change
Line 171 in 7386566
to quoted
_if = "%s == 'true'" % self._if.expr
. Then no more bugs.
A simple test reproduce
set Line60 and Line65 in examples/test_conditional_outputs.py
with
_if="'true'==true",
or
_if="'true'=='true'",
to skip expr
transferring. Running dflow will give totally different results.
But I'm not sure is there any further side-effect of this expression.