prefect: Using Artifact with .map raises ClientError
Description
Hey everyone, currently I am trying out the new artifact api. But when I am using the api in mapped tasks the following error is being thrown:
File “/…/create-city-flow.py”, line 44, in get_wikipedia_summary create_markdown_artifact(artifact_document) File “/…/python3.8/site-packages/prefect/backend/artifacts.py”, line 85, in create_markdown_artifact return _create_task_run_artifact(“markdown”, {“markdown”: markdown}) File “/…/python3.8/site-packages/prefect/backend/artifacts.py”, line 28, in _create_task_run_artifact return client.create_task_run_artifact( File “/…/python3.8/site-packages/prefect/client/client.py”, line 2160, in create_task_run_artifact result = self.graphql( File “/…/python3.8/site-packages/prefect/client/client.py”, line 570, in graphql raise ClientError(result[“errors”]) prefect.exceptions.ClientError: [{‘message’: ‘[{'extensions': {'path': '$.selectionSet.insert_task_run_artifact.args.objects', 'code': 'constraint-violation'}, 'message': 'Not-NULL violation. null value in column “tenant_id” violates not-null constraint'}]’, ‘locations’: [{‘line’: 2, ‘column’: 5}], ‘path’: [‘create_task_run_artifact’], ‘extensions’: {‘code’: ‘INTERNAL_SERVER_ERROR’, ‘exception’: {‘message’: ‘[{'extensions': {'path': '$.selectionSet.insert_task_run_artifact.args.objects', 'code': 'constraint-violation'}, 'message': 'Not-NULL violation. null value in column “tenant_id” violates not-null constraint'}]’}}}]
Expected Behavior
No error is being raised and artifacts for mapped tasks work like for unmapped tasks.
Reproduction
from prefect import Flow, task
from prefect.backend import create_markdown_artifact
@task
def add_ten(x):
create_markdown_artifact(x)
return x + 10
with Flow('simple map') as flow:
mapped_result = add_ten.map([1, 2, 3])
Environment
{
"config_overrides": {
"backend": true
},
"env_vars": [],
"system_information": {
"platform": "macOS-12.0.1-x86_64-i386-64bit",
"prefect_backend": "server",
"prefect_version": "0.15.11",
"python_version": "3.8.12"
}
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (12 by maintainers)
Nice work! I can confirm that registering this way indeed causes that issue.
This could indicate a storage issue because the CLI registers the flow with script storage while flow.register() pickles the flow. See this page for more details on that. In any case, this looks like a bug.
So I reproduced all your steps @anna-geller and does indeed work.
What has changed is that I registered the component with the CLI. From my understanding this seems like there is a bug in the
flow.register()
function. Could this be the problem?@anna-geller would you be so kind and try to delete it and register the flow with python like this:
I do not mind leaving this issue open so we can track this in our primary repository.