argo-python-dsl icon indicating copy to clipboard operation
argo-python-dsl copied to clipboard

Some workflow cannot be compiled twice

Open hadim opened this issue 4 years ago • 4 comments

I am using v0.1.0-rc.

Consider the example below:

from argo.workflows.dsl import Workflow
from argo.workflows.dsl.tasks import task, dependencies
from argo.workflows.dsl.templates import parameter
from argo.workflows.dsl.templates import inputs
from argo.workflows.dsl.templates import template
from argo.workflows.dsl.templates import V1alpha1Parameter
from argo.workflows.dsl.templates import V1alpha1Template
from argo.workflows.dsl.templates import V1Container

# Define your workflow
class DagDiamond(Workflow):

    @task
    @parameter(name="message", value="A")
    def A(self, message: V1alpha1Parameter) -> V1alpha1Template:
        return self.echo(message)

    @template
    @inputs.parameter(name="message")
    def echo(self, message: V1alpha1Parameter) -> V1Container:
        container = V1Container(
            image="alpine:3.7",
            name="echo",
            command=["echo", "{{inputs.parameters.message}}"],
        )

        return container
    
wk1 = DagDiamond()
wk2 = DagDiamond()

The last line wk2 throws this error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-4f976235f896> in <module>
     28 
     29 wk1 = DagDiamond()
---> 30 wk2 = DagDiamond()

~/local/conda/envs/cluster/lib/python3.7/site-packages/argo/workflows/dsl/_workflow.py in __init__(self, compile)
    231 
    232         if compile:
--> 233             self.compile()
    234 
    235     def __hash__(self) -> str:

~/local/conda/envs/cluster/lib/python3.7/site-packages/argo/workflows/dsl/_workflow.py in compile(self)
    372             return obj
    373 
--> 374         self.spec: V1alpha1WorkflowSpec = _compile(self.spec)
    375 
    376         model: V1alpha1Workflow = Workflow.__model__(**self.to_dict(omitempty=False))

~/local/conda/envs/cluster/lib/python3.7/site-packages/argo/workflows/dsl/_workflow.py in _compile(obj)
    367             if hasattr(obj, "attribute_map"):
    368                 for attr in obj.attribute_map:
--> 369                     value: Any = _compile(getattr(obj, attr))
    370                     setattr(obj, attr, value)
    371 

~/local/conda/envs/cluster/lib/python3.7/site-packages/argo/workflows/dsl/_workflow.py in _compile(obj)
    364                 return obj.__get__(self).__call__(**args)
    365             if isinstance(obj, list):
--> 366                 return list(map(_compile, obj))
    367             if hasattr(obj, "attribute_map"):
    368                 for attr in obj.attribute_map:

~/local/conda/envs/cluster/lib/python3.7/site-packages/argo/workflows/dsl/_workflow.py in _compile(obj)
    367             if hasattr(obj, "attribute_map"):
    368                 for attr in obj.attribute_map:
--> 369                     value: Any = _compile(getattr(obj, attr))
    370                     setattr(obj, attr, value)
    371 

~/local/conda/envs/cluster/lib/python3.7/site-packages/argo/workflows/dsl/_workflow.py in _compile(obj)
    367             if hasattr(obj, "attribute_map"):
    368                 for attr in obj.attribute_map:
--> 369                     value: Any = _compile(getattr(obj, attr))
    370                     setattr(obj, attr, value)
    371 

~/local/conda/envs/cluster/lib/python3.7/site-packages/argo/workflows/dsl/_workflow.py in _compile(obj)
    364                 return obj.__get__(self).__call__(**args)
    365             if isinstance(obj, list):
--> 366                 return list(map(_compile, obj))
    367             if hasattr(obj, "attribute_map"):
    368                 for attr in obj.attribute_map:

~/local/conda/envs/cluster/lib/python3.7/site-packages/argo/workflows/dsl/_workflow.py in _compile(obj)
    367             if hasattr(obj, "attribute_map"):
    368                 for attr in obj.attribute_map:
--> 369                     value: Any = _compile(getattr(obj, attr))
    370                     setattr(obj, attr, value)
    371 

~/local/conda/envs/cluster/lib/python3.7/site-packages/argo/workflows/dsl/_workflow.py in _compile(obj)
    367             if hasattr(obj, "attribute_map"):
    368                 for attr in obj.attribute_map:
--> 369                     value: Any = _compile(getattr(obj, attr))
    370                     setattr(obj, attr, value)
    371 

~/local/conda/envs/cluster/lib/python3.7/site-packages/argo/workflows/dsl/_workflow.py in _compile(obj)
    364                 return obj.__get__(self).__call__(**args)
    365             if isinstance(obj, list):
--> 366                 return list(map(_compile, obj))
    367             if hasattr(obj, "attribute_map"):
    368                 for attr in obj.attribute_map:

~/local/conda/envs/cluster/lib/python3.7/site-packages/argo/workflows/dsl/_workflow.py in _compile(obj)
    339         def _compile(obj: Any):
    340             if hasattr(obj, "__model__"):
--> 341                 if obj.model is not None:
    342                     # prevents referenced templates from being compiled again
    343                     return obj.model

AttributeError: 'parameter' object has no attribute 'model'

hadim avatar Jun 04 '20 10:06 hadim

@binarycrayon @asavpatel92 @CermakM is this library still in development?

hadim avatar Jun 10 '20 11:06 hadim

@hadim I am trying to ping @CermakM a couple days back and haven't heard from him. I hope he is fine during the pandemic. I'd like to help but I don't have control over pypi registry or this repo (all the pull requests are currently being delayed)

Can you add what version of argo you are using? From the error log I wonder if it can be fixed with https://github.com/argoproj-labs/argo-python-dsl/pull/1

binarycrayon avatar Jun 10 '20 16:06 binarycrayon

Thank you @binarycrayon. Hope he's fine.

I used the last released one. Will try to do more tests soon.

hadim avatar Jun 10 '20 16:06 hadim

@hadim this problem seems to go away with the latest release (0.4.0), please let me know if you would like to give it a try.

Thanks for the patience!

yxue-kabam avatar Dec 05 '20 20:12 yxue-kabam