Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Artifacts API #121

Merged
merged 14 commits into from
Nov 2, 2020
2 changes: 2 additions & 0 deletions changes/pr121.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feature:
- "Add API for persisting and retrieving task run artifacts - [#121](https://github.com/PrefectHQ/server/pull/121)"
7 changes: 7 additions & 0 deletions services/hasura/migrations/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,13 @@ tables:
table:
name: traversal
schema: utility
- object_relationships:
- name: task_run
using:
foreign_key_constraint_on: task_run_id
table:
name: task_run_artifact
schema: public
- object_relationships:
- name: task_run
using:
Expand Down
265 changes: 265 additions & 0 deletions services/hasura/migrations/versions/metadata-3c87ad7e0b71.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
functions:
- function:
name: downstream_tasks
schema: utility
- function:
name: upstream_tasks
schema: utility
tables:
- array_relationships:
- name: agents
using:
foreign_key_constraint_on:
column: agent_config_id
table:
name: agent
schema: public
table:
name: agent_config
schema: public
- array_relationships:
- name: downstream_edges
using:
foreign_key_constraint_on:
column: upstream_task_id
table:
name: edge
schema: public
- name: task_runs
using:
foreign_key_constraint_on:
column: task_id
table:
name: task_run
schema: public
- name: upstream_edges
using:
foreign_key_constraint_on:
column: downstream_task_id
table:
name: edge
schema: public
object_relationships:
- name: flow
using:
foreign_key_constraint_on: flow_id
table:
name: task
schema: public
- array_relationships:
- name: edges
using:
foreign_key_constraint_on:
column: flow_id
table:
name: edge
schema: public
- name: flow_runs
using:
foreign_key_constraint_on:
column: flow_id
table:
name: flow_run
schema: public
- name: tasks
using:
foreign_key_constraint_on:
column: flow_id
table:
name: task
schema: public
object_relationships:
- name: flow_group
using:
foreign_key_constraint_on: flow_group_id
- name: project
using:
foreign_key_constraint_on: project_id
- name: tenant
using:
foreign_key_constraint_on: tenant_id
table:
name: flow
schema: public
- array_relationships:
- name: flow_groups
using:
foreign_key_constraint_on:
column: tenant_id
table:
name: flow_group
schema: public
- name: flows
using:
foreign_key_constraint_on:
column: tenant_id
table:
name: flow
schema: public
- name: projects
using:
foreign_key_constraint_on:
column: tenant_id
table:
name: project
schema: public
table:
name: tenant
schema: public
- array_relationships:
- name: flow_runs
using:
foreign_key_constraint_on:
column: agent_id
table:
name: flow_run
schema: public
object_relationships:
- name: agent_config
using:
foreign_key_constraint_on: agent_config_id
table:
name: agent
schema: public
- array_relationships:
- name: flows
using:
foreign_key_constraint_on:
column: flow_group_id
table:
name: flow
schema: public
object_relationships:
- name: tenant
using:
foreign_key_constraint_on: tenant_id
table:
name: flow_group
schema: public
- array_relationships:
- name: flows
using:
foreign_key_constraint_on:
column: project_id
table:
name: flow
schema: public
object_relationships:
- name: tenant
using:
foreign_key_constraint_on: tenant_id
table:
name: project
schema: public
- array_relationships:
- name: logs
using:
foreign_key_constraint_on:
column: flow_run_id
table:
name: log
schema: public
- name: states
using:
foreign_key_constraint_on:
column: flow_run_id
table:
name: flow_run_state
schema: public
- name: task_runs
using:
foreign_key_constraint_on:
column: flow_run_id
table:
name: task_run
schema: public
object_relationships:
- name: agent
using:
foreign_key_constraint_on: agent_id
- name: flow
using:
foreign_key_constraint_on: flow_id
- name: tenant
using:
foreign_key_constraint_on: tenant_id
table:
name: flow_run
schema: public
- array_relationships:
- name: logs
using:
foreign_key_constraint_on:
column: task_run_id
table:
name: log
schema: public
- name: states
using:
foreign_key_constraint_on:
column: task_run_id
table:
name: task_run_state
schema: public
object_relationships:
- name: flow_run
using:
foreign_key_constraint_on: flow_run_id
- name: task
using:
foreign_key_constraint_on: task_id
- name: tenant
using:
foreign_key_constraint_on: tenant_id
table:
name: task_run
schema: public
- object_relationships:
- name: downstream_task
using:
foreign_key_constraint_on: downstream_task_id
- name: flow
using:
foreign_key_constraint_on: flow_id
- name: upstream_task
using:
foreign_key_constraint_on: upstream_task_id
table:
name: edge
schema: public
- object_relationships:
- name: flow_run
using:
foreign_key_constraint_on: flow_run_id
table:
name: flow_run_state
schema: public
- object_relationships:
- name: task
using:
manual_configuration:
column_mapping:
task_id: id
remote_table:
name: task
schema: public
table:
name: traversal
schema: utility
- object_relationships:
- name: task_run
using:
foreign_key_constraint_on: task_run_id
table:
name: task_run_state
schema: public
- table:
name: cloud_hook
schema: public
- table:
name: log
schema: public
- table:
name: message
schema: public
version: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""
Add artifact api

Revision ID: 3c87ad7e0b71
Revises: 24f10aeee83e
Create Date: 2020-10-21 14:11:27.409161

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import JSONB, UUID


# revision identifiers, used by Alembic.
revision = "3c87ad7e0b71"
down_revision = "24f10aeee83e"
branch_labels = None
depends_on = None


def upgrade():
op.create_table(
joshmeek marked this conversation as resolved.
Show resolved Hide resolved
"task_run_artifact",
sa.Column(
"id", UUID, primary_key=True, server_default=sa.func.gen_random_uuid()
),
sa.Column(
"created",
sa.TIMESTAMP(timezone=True),
nullable=False,
server_default=sa.func.now(),
),
sa.Column(
"updated",
sa.TIMESTAMP(timezone=True),
nullable=False,
server_default=sa.func.now(),
),
sa.Column(
"tenant_id",
UUID,
sa.ForeignKey("tenant.id", ondelete="CASCADE"),
nullable=False,
index=True,
),
sa.Column(
"task_run_id",
UUID,
sa.ForeignKey("task_run.id", ondelete="CASCADE"),
nullable=False,
index=True,
),
sa.Column("kind", sa.String, nullable=False),
sa.Column("data", JSONB, nullable=False, server_default="{}"),
)

op.execute(
"""
CREATE TRIGGER update_timestamp
BEFORE UPDATE ON task_run_artifact
FOR EACH ROW
EXECUTE PROCEDURE set_updated_timestamp();
"""
)


def downgrade():
op.drop_table("task_run_artifact")
1 change: 1 addition & 0 deletions src/prefect_server/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
import prefect_server.api.runs
import prefect_server.api.messages
import prefect_server.api.agents
import prefect_server.api.artifacts
Loading