-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workflow): major refactor of core work to support multiple projects
- Loading branch information
Showing
29 changed files
with
1,583 additions
and
614 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
name = "workflow" | ||
version = "0.1.0" | ||
description = "Workflow Core" | ||
authors = ["Shiny Brar <[email protected]>"] | ||
authors = ["Shiny Brar <[email protected]>"] | ||
license = "MIT" | ||
readme = "README.md" | ||
|
||
|
@@ -12,6 +12,10 @@ tenacity = "^8.2" | |
pydantic = "^2.0" | ||
requests = "^2.31" | ||
pyyaml = "^6.0" | ||
click = "^8.1" | ||
toml = "^0.10" | ||
rich = "^13.4" | ||
mergedeep = "^1.3" | ||
pydantic-settings = "^2.0" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
|
@@ -20,6 +24,9 @@ pytest = "^7.4" | |
pytest-cov = "^4.1" | ||
tomli = "^2.0" | ||
pre-commit = "^3.3" | ||
types-requests = "^2.31" | ||
types-toml = "^0.10" | ||
types-setuptools = "^68.0" | ||
|
||
[tool.poetry.scripts] | ||
workflow = "workflow.cli.main:cli" | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,25 @@ | ||
"""Top-level imports for Tasks API.""" | ||
from .work.work import Work # noqa: F401s | ||
from logging import getLogger | ||
from pathlib import Path | ||
|
||
import toml | ||
from pkg_resources import DistributionNotFound, get_distribution | ||
|
||
# Root path to the Skaha Project | ||
BASE_PATH: Path = Path(__file__).absolute().parent.parent | ||
__version__: str = "unknown" | ||
|
||
logger = getLogger(__name__) | ||
|
||
try: | ||
__version__ = get_distribution("workflow").version | ||
except DistributionNotFound as error: # pragma: no cover | ||
logger.warning(error) | ||
pyproject = toml.load(BASE_PATH / "pyproject.toml") | ||
__version__ = pyproject["tool"]["poetry"]["version"] | ||
except Exception as error: # pragma: no cover | ||
logger.warning(error) | ||
logger.warning("unable to find workflow client version") | ||
|
||
from workflow.utils.logger import get_logger # noqa: F401, E402 isort:skip | ||
from workflow.definitions.work import Work # noqa: F401, E402 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
"""Work Object Configuration.""" | ||
from typing import List, Optional | ||
|
||
from pydantic import Field, field_validator | ||
from pydantic_settings import BaseSettings, SettingsConfigDict | ||
|
||
|
||
class Archive(BaseSettings): | ||
"""Archive Configuration. | ||
This class is used to configure the archive strategy for the work. | ||
Args: | ||
BaseModel (BaseModel): Pydantic BaseModel. | ||
Attributes: | ||
results (bool): Archive results for the work. | ||
products (str): Archive strategy for the products. | ||
plots (str): Archive strategy for the plots. | ||
logs (str): Archive strategy for the logs. | ||
""" | ||
|
||
model_config = SettingsConfigDict( | ||
title="Workflow Archive Object", | ||
validate_default=True, | ||
validate_assignment=True, | ||
validate_return=True, | ||
revalidate_instances="always", | ||
env_prefix="WORKFLOW_CONFIG_ARCHIVE_", | ||
secrets_dir="/run/secrets", | ||
extra="ignore", | ||
) | ||
|
||
results: bool = Field( | ||
default=True, | ||
description="Archive results for the work.", | ||
examples=[True], | ||
) | ||
products: str = Field( | ||
default="copy", | ||
description="Archive strategy for the products.", | ||
examples=["copy"], | ||
) | ||
plots: str = Field( | ||
default="copy", | ||
description="Archive strategy for the plots.", | ||
examples=["move"], | ||
) | ||
logs: str = Field( | ||
default="move", | ||
description="Archive strategy for the logs.", | ||
examples=["delete"], | ||
) | ||
|
||
@field_validator("products", "plots", "logs") | ||
def validate_archive(cls, value: str) -> str: | ||
"""Validate the archive strategy. | ||
Args: | ||
value (str): Archive strategy. | ||
Raises: | ||
ValueError: If the archive strategy is not valid. | ||
Returns: | ||
str: The archive strategy. | ||
""" | ||
strategy = ["pass", "copy", "move", "delete", "upload"] | ||
if value not in strategy: | ||
raise ValueError(f"archive strategy must be one of {strategy}") | ||
return value | ||
|
||
|
||
class Config(BaseSettings): | ||
"""Workflow Configuration Object. | ||
Args: | ||
BaseSettings (BaseSettings): Pydantic BaseModel with settings. | ||
Attributes: | ||
archive (Archive): Archive Configuration. | ||
metrics (bool): Generate metrics from work lifecycle. | ||
parent (Optional[str]): Parent Pipeline ID. None implies no parent. | ||
orgs (List[str]): GitHub organization[s] the work belongs to. | ||
teams (Optional[List[str]]): GitHub Team[s] with access to the work. | ||
""" | ||
|
||
model_config = SettingsConfigDict( | ||
title="Workflow Config Object", | ||
validate_default=True, | ||
validate_assignment=True, | ||
validate_return=True, | ||
revalidate_instances="always", | ||
env_prefix="WORKFLOW_CONFIG_", | ||
secrets_dir="/run/secrets", | ||
extra="ignore", | ||
) | ||
|
||
archive: Archive = Archive() | ||
metrics: bool = Field( | ||
default=False, | ||
description="Generate metrics from work lifecycle.", | ||
) | ||
parent: Optional[str] = Field( | ||
default=None, | ||
description="Parent Pipeline ID. None implies no parent.", | ||
examples=["5f9b5c5d7b54b5a9c5e5b5c5"], | ||
) | ||
orgs: List[str] = Field( | ||
default=["chimefrb"], | ||
description="GitHub organization[s] the work belongs to.", | ||
examples=[["octocat", "chimefrb"]], | ||
) | ||
teams: Optional[List[str]] = Field( | ||
default=None, | ||
description=""" | ||
GitHub Team[s] with access to the work. None implies all org members. | ||
""", | ||
examples=[["developers", "admins"]], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.