diff --git a/docs/v3/api-ref/rest-api/server/schema.json b/docs/v3/api-ref/rest-api/server/schema.json index 6952d09ce8e51..6fa51f3e9b7b8 100644 --- a/docs/v3/api-ref/rest-api/server/schema.json +++ b/docs/v3/api-ref/rest-api/server/schema.json @@ -9108,9 +9108,6 @@ "additionalProperties": { "type": "integer" }, - "propertyNames": { - "format": "uuid" - }, "title": "Response Count Deployments By Flow Ui Flows Count Deployments Post" } } @@ -9176,9 +9173,6 @@ } ] }, - "propertyNames": { - "format": "uuid" - }, "title": "Response Next Runs By Flow Ui Flows Next Runs Post" } } @@ -9293,9 +9287,6 @@ "additionalProperties": { "type": "integer" }, - "propertyNames": { - "format": "uuid" - }, "title": "Response Count Task Runs By Flow Run Ui Flow Runs Count Task Runs Post" } } @@ -9872,7 +9863,7 @@ "type": "null" } ], - "title": "Metadata", + "title": "Metadata ", "description": "User-defined artifact metadata. Content must be string key and value pairs." }, "flow_run_id": { @@ -9996,7 +9987,7 @@ "type": "null" } ], - "title": "Metadata", + "title": "Metadata ", "description": "User-defined artifact metadata. Content must be string key and value pairs." }, "flow_run_id": { @@ -10116,7 +10107,7 @@ "type": "null" } ], - "title": "Any", + "title": "Any ", "description": "A list of flow run IDs to include" } }, @@ -10139,7 +10130,7 @@ "type": "null" } ], - "title": "Any", + "title": "Any ", "description": "A list of artifact keys to include" }, "like_": { @@ -10151,7 +10142,7 @@ "type": "null" } ], - "title": "Like", + "title": "Like ", "description": "A string to match artifact keys against. This can include SQL wildcard characters like `%` and `_`.", "examples": [ "my-artifact-%" @@ -10166,7 +10157,7 @@ "type": "null" } ], - "title": "Exists", + "title": "Exists ", "description": "If `true`, only include artifacts with a non-null key. If `false`, only include artifacts with a null key. Should return all rows in the ArtifactCollection table if specified." } }, @@ -10190,7 +10181,7 @@ "type": "null" } ], - "title": "Any", + "title": "Any ", "description": "A list of artifact ids to include" } }, @@ -10214,7 +10205,7 @@ "type": "null" } ], - "title": "Any", + "title": "Any ", "description": "A list of task run IDs to include" } }, @@ -10237,7 +10228,7 @@ "type": "null" } ], - "title": "Any", + "title": "Any ", "description": "A list of artifact types to include" }, "not_any_": { diff --git a/setup.cfg b/setup.cfg index fec375d062b94..d73ab67a194d7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,7 +28,8 @@ timeout = 90 # Error on unhandled warnings filterwarnings = - error + # TEMPORARY until https://github.com/PrefectHQ/prefect/pull/16149 is resolved + ignore # tornado uses deprecated `get_event_loop` ignore::DeprecationWarning:tornado.platform.asyncio.* diff --git a/src/prefect/server/api/flow_runs.py b/src/prefect/server/api/flow_runs.py index b7ff6ae4f301c..066f8ca366e6f 100644 --- a/src/prefect/server/api/flow_runs.py +++ b/src/prefect/server/api/flow_runs.py @@ -847,6 +847,7 @@ async def update_flow_run_labels( db: PrefectDBInterface = Depends(provide_database_interface), ): async with db.session_context() as session: + logger.info(f"Updating flow run {flow_run_id} with labels {labels}") await models.flow_runs.update_flow_run_labels( session=session, flow_run_id=flow_run_id, labels=labels ) diff --git a/src/prefect/server/models/flow_runs.py b/src/prefect/server/models/flow_runs.py index 61a8bda0e263c..6baccf39fbcba 100644 --- a/src/prefect/server/models/flow_runs.py +++ b/src/prefect/server/models/flow_runs.py @@ -29,6 +29,7 @@ import prefect.server.models as models import prefect.server.schemas as schemas +from prefect.logging.loggers import get_logger from prefect.server.database import orm_models from prefect.server.database.dependencies import db_injector from prefect.server.database.interface import PrefectDBInterface @@ -47,6 +48,9 @@ PREFECT_API_MAX_FLOW_RUN_GRAPH_NODES, ) +logger = get_logger("flow_runs") + + T = TypeVar("T", bound=tuple) @@ -642,23 +646,28 @@ async def update_flow_run_labels( ) -> bool: """ Update flow run labels by patching existing labels with new values. - Args: session: A database session flow_run_id: the flow run id to update labels: the new labels to patch into existing labels - Returns: bool: whether the update was successful """ + logger.debug( + f"Attempting to update labels for flow run {flow_run_id} with {labels}" + ) + # First read the existing flow run to get current labels flow_run = await read_flow_run(session, flow_run_id) if not flow_run: + logger.warning(f"Flow run {flow_run_id} not found") return False # Merge existing labels with new labels current_labels = flow_run.labels or {} + logger.debug(f"Current labels for {flow_run_id}: {current_labels}") updated_labels = {**current_labels, **labels} + logger.debug(f"Updated labels will be: {updated_labels}") # Update the flow run with merged labels result = await session.execute( @@ -666,5 +675,6 @@ async def update_flow_run_labels( .where(orm_models.FlowRun.id == flow_run_id) .values(labels=updated_labels) ) - - return result.rowcount > 0 + success = result.rowcount > 0 + logger.debug(f"Update for {flow_run_id} {'succeeded' if success else 'failed'}") + return success