Skip to content

[SYNPY-1760] Add ability to link Grid to CurationTask#1383

Merged
andrewelamb merged 85 commits into
developfrom
SYNPY-1760
Jun 4, 2026
Merged

[SYNPY-1760] Add ability to link Grid to CurationTask#1383
andrewelamb merged 85 commits into
developfrom
SYNPY-1760

Conversation

@andrewelamb
Copy link
Copy Markdown
Contributor

@andrewelamb andrewelamb commented May 18, 2026

Problem:

  • Python Client users could not link a Grid session to a CurationTask
  • Curator Extension Docs were out of date

Solution:

Added these methods to CurationTask:

  • get_status
  • update_status
  • set_active_grid_session
  • set_task_state_async
  • create_grid_session_async

Added owner_principal_id to Grid

Separated Curator docs into one for data managers and one for contributors

Testing:

All new methods have unit and integration tests

Comment thread synapseclient/models/curation.py
Comment thread docs/guides/extensions/curator/metadata_contribution.md
Comment thread docs/guides/extensions/curator/metadata_curation.md
Comment thread synapseclient/models/curation.py Outdated
Comment on lines +1089 to +1091
"taskProperties was not found in the Synapse response for this CurationTask. "
"This means it is likely an older CurationTask from before taskProperties was added. "
"It is recommended that this task be deleted: task.delete(delete_source=False)"
Copy link
Copy Markdown
Member

@thomasyu888 thomasyu888 May 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to the message to recreate the task with the existing source entity

await self.set_active_grid_session_async(
active_session_id=grid.session_id, synapse_client=synapse_client
)
except Exception:
Copy link
Copy Markdown
Member

@thomasyu888 thomasyu888 May 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be the one that catches the 412 error. Should we have a "finally" clause to delete the grid sesison for all other errors on this active grid session command?

Comment on lines +1754 to +1767
try:
await self.set_active_grid_session_async(
active_session_id=grid.session_id, synapse_client=synapse_client
)
except Exception:
try:
await grid.delete_async(synapse_client=synapse_client)
except Exception:
Synapse.get_client(synapse_client=synapse_client).logger.warning(
"Failed to delete orphan grid session %s after status "
"update failure; manual cleanup may be required.",
grid.session_id,
)
raise
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment

  1. There can only be one grid session that is active, but there can be multiple grid sessions. So multiple users running this command may run into the 412 error.

Copy link
Copy Markdown
Member

@thomasyu888 thomasyu888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 LGTM! just some minor comments, and will defer to @BryanFauble for a final pass next sprint for the code and @cconrad8 on the documentation.

Comment thread docs/guides/extensions/curator/metadata_contribution.md Outdated
Comment thread docs/guides/extensions/curator/metadata_contribution.md Outdated

### Step 5: Upsert your edits back into the grid

`import_csv` upserts rows into the grid based on the `upsert_keys` the administrator configured on the curation task. Existing rows matching on those keys are updated; new rows are inserted.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the task has the upsert key as a property?



@dataclass
class TaskExecutionDetails(ABC):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although Synapse is representing this with inheritance and a base class, we do not have to follow this pattern exactly. In fact this would be the first usage of an abstract base class in the python code. Ideally - If possible I would rather this not exist.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a case to be said that there are going to be many more of these, then that would be a reason to keep this. If this is all we will have, then I do not think we need to have this extra layer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

John has mentioned that they plan on having more of these, but I don't have any firm timeline. I'm happy to keep or change this.

Comment thread synapseclient/models/curation.py Outdated
Comment thread synapseclient/models/curation.py Outdated
)
grid = Grid(
initial_query=Query(
sql=f"SELECT * FROM {self.task_properties.file_view_id}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there cases where this should be user controlled to set the query to something like, like SELECT col_1, col_2, col_3 ...?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a product perspective, this is not supported within the UI flow when people "Open Curator" from a task. opening curator from a task will always select * on the underlying source id (recordset and/or fileview)

await self.set_active_grid_session_async(
active_session_id=grid.session_id, synapse_client=synapse_client
)
except Exception:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception is way too wide to catch here for this logic. You need to catch for the specific exception (I assume an HTTP type exception), and inspect the message for the specific one that you care about. That should be the only case where you clean this up automatically.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't we want to clean up this grid everytime Synapse was unable to set it as the active grid on the CurationTask?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make any sense for the Grid created during this process to stay under any circumstances? If no, then keep as is. If yes, change the behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. In my opinion, the user would be trying to create a grid and attach it with one method. If the attachment didn't work, they would probably try to call this method again, which would leave the grid from the first try.

Copy link
Copy Markdown
Member

@BryanFauble BryanFauble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes.

Approving, however please look to at least address #1383 (comment) before merge.

Comment thread docs/guides/extensions/curator/metadata_curation.md
Comment thread docs/guides/extensions/curator/metadata_curation.md
@andrewelamb andrewelamb requested a review from cconrad8 June 4, 2026 15:28
@andrewelamb andrewelamb merged commit 2243452 into develop Jun 4, 2026
20 of 23 checks passed
@andrewelamb andrewelamb deleted the SYNPY-1760 branch June 4, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants