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

Enhancement: Track flow run id when generating task run results #8674

Merged
merged 2 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/prefect/server/orchestration/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ async def _validate_proposed_state(
if state_data is not None:
state_result_artifact = core.Artifact.from_result(state_data)
state_result_artifact.task_run_id = self.run.id

flow_run = await self.flow_run()
state_result_artifact.flow_run_id = flow_run.id

await artifacts.create_artifact(self.session, state_result_artifact)
state_payload["result_artifact_id"] = state_result_artifact.id

Expand Down
6 changes: 6 additions & 0 deletions tests/server/orchestration/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,12 @@ async def test_context_validation_writes_result_artifact(
orm_artifact = await models.artifacts.read_artifact(ctx.session, artifact_id)
assert orm_artifact.data == {"value": "some special data"}

if run_type == "task":
assert orm_artifact.task_run_id == ctx.run.id
assert orm_artifact.flow_run_id == ctx.run.flow_run_id
else:
assert orm_artifact.flow_run_id == ctx.run.id

async def test_context_validation_writes_result_artifact_with_metadata(
self, session, run_type, initialize_orchestration
):
Expand Down