Skip to content

Commit

Permalink
[CZID-9248] update loader signatures (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
morsecodist authored Jan 31, 2024
1 parent 321d8d3 commit 139b53f
Show file tree
Hide file tree
Showing 21 changed files with 201 additions and 148 deletions.
12 changes: 6 additions & 6 deletions workflows/api/loader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
from sqlalchemy.ext.asyncio import AsyncSession
from entity_interface import create_entities

from plugins.plugin_types import EventBus, EntityInputLoader, EntityOutputLoader, WorkflowSucceededMessage
from plugins.plugin_types import EventBus, InputLoader, OutputLoader, WorkflowSucceededMessage
from database.models import WorkflowRun
from manifest.manifest import EntityInputArgument, Manifest, RawInputArgument

T = TypeVar("T", bound=Type[EntityInputLoader] | Type[EntityOutputLoader])
T = TypeVar("T", bound=Type[InputLoader] | Type[OutputLoader])


def load_loader_plugins(input_or_output: Literal["input", "output"], cls: T) -> Dict[str, List[Tuple[Version, T]]]:
Expand All @@ -35,10 +35,10 @@ def load_loader_plugins(input_or_output: Literal["input", "output"], cls: T) ->
return loaders


input_loaders = load_loader_plugins("input", EntityInputLoader)
input_loaders = load_loader_plugins("input", InputLoader)


def resolve_entity_input_loaders(workflow_manifest: Manifest) -> List[type[EntityInputLoader]]:
def resolve_entity_input_loaders(workflow_manifest: Manifest) -> List[type[InputLoader]]:
"""
Given a manifest, resolve input loaders
"""
Expand All @@ -55,11 +55,11 @@ def resolve_entity_input_loaders(workflow_manifest: Manifest) -> List[type[Entit
return resolved_loaders


output_loaders = load_loader_plugins("output", EntityOutputLoader)
output_loaders = load_loader_plugins("output", OutputLoader)


# TODO: DRY with above but make the types work poperly
def resolve_entity_output_loaders(workflow_manifest: Manifest) -> List[type[EntityOutputLoader]]:
def resolve_entity_output_loaders(workflow_manifest: Manifest) -> List[type[OutputLoader]]:
"""
Given a manifest, resolve output loaders
"""
Expand Down
15 changes: 15 additions & 0 deletions workflows/api/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ enum WorkflowCountColumns {
producing_run_id
owner_user_id
collection_id
created_at
updated_at
deleted_at
}

input WorkflowCreateInput {
Expand Down Expand Up @@ -293,6 +296,9 @@ enum WorkflowRunCountColumns {
producing_run_id
owner_user_id
collection_id
created_at
updated_at
deleted_at
}

input WorkflowRunCreateInput {
Expand Down Expand Up @@ -360,6 +366,9 @@ enum WorkflowRunEntityInputCountColumns {
producing_run_id
owner_user_id
collection_id
created_at
updated_at
deleted_at
}

input WorkflowRunEntityInputCreateInput {
Expand Down Expand Up @@ -494,6 +503,9 @@ enum WorkflowRunStepCountColumns {
producing_run_id
owner_user_id
collection_id
created_at
updated_at
deleted_at
}

input WorkflowRunStepCreateInput {
Expand Down Expand Up @@ -673,6 +685,9 @@ enum WorkflowVersionCountColumns {
producing_run_id
owner_user_id
collection_id
created_at
updated_at
deleted_at
}

input WorkflowVersionCreateInput {
Expand Down
45 changes: 45 additions & 0 deletions workflows/api/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2948,6 +2948,15 @@
},
{
"name": "collection_id"
},
{
"name": "created_at"
},
{
"name": "updated_at"
},
{
"name": "deleted_at"
}
],
"fields": null,
Expand Down Expand Up @@ -3325,6 +3334,15 @@
},
{
"name": "collection_id"
},
{
"name": "created_at"
},
{
"name": "updated_at"
},
{
"name": "deleted_at"
}
],
"fields": null,
Expand Down Expand Up @@ -3773,6 +3791,15 @@
},
{
"name": "collection_id"
},
{
"name": "created_at"
},
{
"name": "updated_at"
},
{
"name": "deleted_at"
}
],
"fields": null,
Expand Down Expand Up @@ -4200,6 +4227,15 @@
},
{
"name": "collection_id"
},
{
"name": "created_at"
},
{
"name": "updated_at"
},
{
"name": "deleted_at"
}
],
"fields": null,
Expand Down Expand Up @@ -4449,6 +4485,15 @@
},
{
"name": "collection_id"
},
{
"name": "created_at"
},
{
"name": "updated_at"
},
{
"name": "deleted_at"
}
],
"fields": null,
Expand Down
3 changes: 3 additions & 0 deletions workflows/api/types/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ class WorkflowCountColumns(enum.Enum):
producing_run_id = "producing_run_id"
owner_user_id = "owner_user_id"
collection_id = "collection_id"
created_at = "created_at"
updated_at = "updated_at"
deleted_at = "deleted_at"


"""
Expand Down
3 changes: 3 additions & 0 deletions workflows/api/types/workflow_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ class WorkflowRunCountColumns(enum.Enum):
producing_run_id = "producing_run_id"
owner_user_id = "owner_user_id"
collection_id = "collection_id"
created_at = "created_at"
updated_at = "updated_at"
deleted_at = "deleted_at"


"""
Expand Down
3 changes: 3 additions & 0 deletions workflows/api/types/workflow_run_entity_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ class WorkflowRunEntityInputCountColumns(enum.Enum):
producing_run_id = "producing_run_id"
owner_user_id = "owner_user_id"
collection_id = "collection_id"
created_at = "created_at"
updated_at = "updated_at"
deleted_at = "deleted_at"


"""
Expand Down
3 changes: 3 additions & 0 deletions workflows/api/types/workflow_run_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ class WorkflowRunStepCountColumns(enum.Enum):
producing_run_id = "producing_run_id"
owner_user_id = "owner_user_id"
collection_id = "collection_id"
created_at = "created_at"
updated_at = "updated_at"
deleted_at = "deleted_at"


"""
Expand Down
3 changes: 3 additions & 0 deletions workflows/api/types/workflow_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ class WorkflowVersionCountColumns(enum.Enum):
producing_run_id = "producing_run_id"
owner_user_id = "owner_user_id"
collection_id = "collection_id"
created_at = "created_at"
updated_at = "updated_at"
deleted_at = "deleted_at"


"""
Expand Down
15 changes: 15 additions & 0 deletions workflows/cli/gql_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ class WorkflowCountColumns(sgqlc.types.Enum):
__schema__ = gql_schema
__choices__ = (
"collection_id",
"created_at",
"default_version",
"deleted_at",
"entity_id",
"id",
"minimum_supported_version",
"name",
"owner_user_id",
"producing_run_id",
"updated_at",
"versions",
)

Expand All @@ -53,6 +56,8 @@ class WorkflowRunCountColumns(sgqlc.types.Enum):
__schema__ = gql_schema
__choices__ = (
"collection_id",
"created_at",
"deleted_at",
"deprecated_by",
"ended_at",
"entity_id",
Expand All @@ -66,6 +71,7 @@ class WorkflowRunCountColumns(sgqlc.types.Enum):
"started_at",
"status",
"steps",
"updated_at",
"workflow_runner_inputs_json",
"workflow_version",
)
Expand All @@ -75,12 +81,15 @@ class WorkflowRunEntityInputCountColumns(sgqlc.types.Enum):
__schema__ = gql_schema
__choices__ = (
"collection_id",
"created_at",
"deleted_at",
"entity_id",
"field_name",
"id",
"input_entity_id",
"owner_user_id",
"producing_run_id",
"updated_at",
"workflow_run",
)

Expand All @@ -94,13 +103,16 @@ class WorkflowRunStepCountColumns(sgqlc.types.Enum):
__schema__ = gql_schema
__choices__ = (
"collection_id",
"created_at",
"deleted_at",
"ended_at",
"entity_id",
"id",
"owner_user_id",
"producing_run_id",
"started_at",
"status",
"updated_at",
"workflow_run",
)

Expand All @@ -114,13 +126,16 @@ class WorkflowVersionCountColumns(sgqlc.types.Enum):
__schema__ = gql_schema
__choices__ = (
"collection_id",
"created_at",
"deleted_at",
"entity_id",
"graph_json",
"id",
"manifest",
"owner_user_id",
"producing_run_id",
"runs",
"updated_at",
"version",
"workflow",
"workflow_uri",
Expand Down
33 changes: 33 additions & 0 deletions workflows/database_migrations/versions/20240130_195510_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
Revision ID: 20240130_195510
Revises: 20240128_222905
Create Date: 2024-01-31 03:55:11.432738
"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "20240130_195510"
down_revision = "20240128_222905"
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"entity", sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False)
)
op.add_column("entity", sa.Column("updated_at", sa.DateTime(timezone=True), nullable=True))
op.add_column("entity", sa.Column("deleted_at", sa.DateTime(timezone=True), nullable=True))
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("entity", "deleted_at")
op.drop_column("entity", "updated_at")
op.drop_column("entity", "created_at")
# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion workflows/manifest/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def _unique_input_names(self): # type: ignore

@model_validator(mode="after")
def _validate_references(self): # type: ignore
errors: list[InvalidInputReference] = []
errors = []
inputs = set(self.entity_inputs.keys()) | set(self.raw_inputs.keys())
for input_loader in self.input_loaders:
errors += list(input_loader._check_references("input", input_loader.name, inputs))
Expand Down
22 changes: 0 additions & 22 deletions workflows/plugins/entity_input_loaders/fasta/loader_fasta.py

This file was deleted.

23 changes: 0 additions & 23 deletions workflows/plugins/entity_input_loaders/fasta/setup.py

This file was deleted.

Loading

0 comments on commit 139b53f

Please sign in to comment.