Skip to content
This repository was archived by the owner on Oct 21, 2021. It is now read-only.
This repository was archived by the owner on Oct 21, 2021. It is now read-only.

Some workflow cannot be compiled twice #5

@hadim

Description

@hadim

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'

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions