예제 #1
0
파일: node.py 프로젝트: flyteorg/flytekit
 def with_overrides(self, *args, **kwargs):
     if "node_name" in kwargs:
         self._id = kwargs["node_name"]
     if "aliases" in kwargs:
         alias_dict = kwargs["aliases"]
         if not isinstance(alias_dict, dict):
             raise AssertionError("Aliases should be specified as dict[str, str]")
         self._aliases = []
         for k, v in alias_dict.items():
             self._aliases.append(_workflow_model.Alias(var=k, alias=v))
     if "requests" in kwargs or "limits" in kwargs:
         requests = _convert_resource_overrides(kwargs.get("requests"), "requests")
         limits = _convert_resource_overrides(kwargs.get("limits"), "limits")
         self._resources = _resources_model(requests=requests, limits=limits)
     if "timeout" in kwargs:
         timeout = kwargs["timeout"]
         if timeout is None:
             self._metadata._timeout = datetime.timedelta()
         elif isinstance(timeout, int):
             self._metadata._timeout = datetime.timedelta(seconds=timeout)
         elif isinstance(timeout, datetime.timedelta):
             self._metadata._timeout = timeout
         else:
             raise ValueError("timeout should be duration represented as either a datetime.timedelta or int seconds")
     if "retries" in kwargs:
         retries = kwargs["retries"]
         self._metadata._retries = (
             _literal_models.RetryStrategy(0) if retries is None else _literal_models.RetryStrategy(retries)
         )
     if "interruptible" in kwargs:
         self._metadata._interruptible = kwargs["interruptible"]
     return self
예제 #2
0
def test_alias():
    obj = _workflow.Alias(var="myvar", alias="myalias")
    assert obj.alias == "myalias"
    assert obj.var == "myvar"
    obj2 = _workflow.Alias.from_flyte_idl(obj.to_flyte_idl())
    assert obj == obj2
    assert obj2.alias == "myalias"
    assert obj2.var == "myvar"
예제 #3
0
def test_alias():
    obj = _workflow.Alias(var='myvar', alias='myalias')
    assert obj.alias == 'myalias'
    assert obj.var == 'myvar'
    obj2 = _workflow.Alias.from_flyte_idl(obj.to_flyte_idl())
    assert obj == obj2
    assert obj2.alias == 'myalias'
    assert obj2.var == 'myvar'
예제 #4
0
 def with_overrides(self, *args, **kwargs):
     if "node_name" in kwargs:
         self._id = kwargs["node_name"]
     if "aliases" in kwargs:
         alias_dict = kwargs["aliases"]
         if not isinstance(alias_dict, dict):
             raise AssertionError(
                 "Aliases should be specified as dict[str, str]")
         self._aliases = []
         for k, v in alias_dict.items():
             self._aliases.append(_workflow_model.Alias(var=k, alias=v))
예제 #5
0
파일: node.py 프로젝트: fediazgon/flytekit
 def with_overrides(self, *args, **kwargs):
     if "node_name" in kwargs:
         self._id = kwargs["node_name"]
     if "aliases" in kwargs:
         alias_dict = kwargs["aliases"]
         if not isinstance(alias_dict, dict):
             raise AssertionError(
                 "Aliases should be specified as dict[str, str]")
         self._aliases = []
         for k, v in alias_dict.items():
             self._aliases.append(_workflow_model.Alias(var=k, alias=v))
     if "requests" in kwargs or "limits" in kwargs:
         requests = _convert_resource_overrides(kwargs["requests"],
                                                "requests")
         limits = _convert_resource_overrides(kwargs["limits"], "limits")
         self._resources = _resources_model(requests=requests,
                                            limits=limits)
     return self