Skip to content

Commit

Permalink
Migrate Hera to Argo Workflows 6.3.0rc2 (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviuvadan authored Feb 8, 2022
1 parent 6914c6d commit b3380b9
Show file tree
Hide file tree
Showing 23 changed files with 593 additions and 367 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ The general format is:
- C from D
```

# 1.8.0rc1 - DATE (08/02/2022)

### Changed

- the underlying SDK from argo-workflows v5 to argo-workflows v6.3rc2

# 1.7.0 - DATE (30/01/2022)

### Added
Expand All @@ -38,7 +45,7 @@ The general format is:

### Changed

- fix where a subclass of a Task could not have the parent type as dependancy
- fix where a subclass of a Task could not have the parent type as dependency

# 1.6.1 - DATE (26/01/2022)

Expand Down
100 changes: 63 additions & 37 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions USERS.md

This file was deleted.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.0
1.8.0rc1
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ check_untyped_defs = True
no_implicit_optional = True
strict_optional = False

[mypy-argo.workflows.*]
[mypy-argo_workflows.*]
ignore_missing_imports = True

[mypy-urllib3.*]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
include_package_data=True,
python_requires='>=3.7',
install_requires=[
"argo-workflows",
"argo-workflows==6.3.0rc2",
"pydantic",
"python-dateutil",
"urllib3",
Expand Down
16 changes: 8 additions & 8 deletions src/hera/artifact.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from argo.workflows.client import V1alpha1Artifact
from argo_workflows.models import IoArgoprojWorkflowV1alpha1Artifact
from pydantic import BaseModel


class Artifact(BaseModel):
class _Artifact(BaseModel):
"""An artifact represents an object that Argo creates for a specific task's output.
The output of a task payload can store specific results at a path, which can then be consumed by
Expand All @@ -25,18 +25,18 @@ class Artifact(BaseModel):
name: str
path: str

def get_spec(self) -> V1alpha1Artifact:
def get_spec(self) -> IoArgoprojWorkflowV1alpha1Artifact:
"""Constructs the corresponding Argo artifact representation"""
return V1alpha1Artifact(name=self.name, path=self.path)
return IoArgoprojWorkflowV1alpha1Artifact(name=self.name, path=self.path)


class OutputArtifact(Artifact):
class OutputArtifact(_Artifact):
"""An output artifact representation"""

pass


class InputArtifact(Artifact):
class InputArtifact(_Artifact):
"""An input artifact representation.
This artifact is used to represent a task's input from the output of another task's artifact.
Expand All @@ -57,7 +57,7 @@ class InputArtifact(Artifact):
from_task: str
artifact_name: str

def get_spec(self) -> V1alpha1Artifact:
def get_spec(self) -> IoArgoprojWorkflowV1alpha1Artifact:
"""Constructs the corresponding Argo artifact representation"""
_from = f"{{{{tasks.{self.from_task}.outputs.artifacts.{self.artifact_name}}}}}"
return V1alpha1Artifact(name=self.name, path=self.path, _from=_from)
return IoArgoprojWorkflowV1alpha1Artifact(name=self.name, path=self.path, _from=_from)
2 changes: 1 addition & 1 deletion src/hera/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Holds client configurations for communicating with Argo APIs"""
from argo.workflows.client import ApiClient as ArgoApiClient
from argo_workflows.api_client import ApiClient as ArgoApiClient

from hera.config import Config

Expand Down
14 changes: 12 additions & 2 deletions src/hera/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Optional

import urllib3
from argo.workflows.client import Configuration as ArgoConfig
from argo_workflows.api_client import Configuration as ArgoConfig

# __get_config() explicitly disables SSL verification, so urllib3 will throw a warning to the user. Since we have
# explicitly asked for it to disable SSL, it's safe to ignore the warning.
Expand All @@ -30,13 +30,18 @@ def __init__(self, host: Optional[str] = None, verify_ssl: bool = True):
self._verify_ssl = verify_ssl
self._config = self.__get_config()

def _assemble_host(self):
def _assemble_host(self) -> str:
"""Assembles a host from the default K8S cluster env variables with Argo's address.
Notes
-----
The pod containers should have an environment variable with the address of the Argo server, and this is
# the default one. Users who wish to assemble this on their own can do so and submit the result via the `host`
Returns
-------
str
Assembled host.
"""
tcp_addr = os.getenv('ARGO_SERVER_PORT_2746_TCP_ADDR', None)
assert tcp_addr is not None, 'A configuration/service host is required for submitting workflows'
Expand All @@ -51,6 +56,11 @@ def __get_config(self) -> ArgoConfig:
shared with all the deployments of K8S. If those are not specified, it uses the passed in domain to configure
the address.
Returns
-------
_ArgoConfig
The Argo service configuration.
Notes
-----
The Argo server runs on HTTPS, so it sends back a certificate. However, this server runs on HTTP, and we have
Expand Down
Loading

0 comments on commit b3380b9

Please sign in to comment.