Repository navigation
Add an auto_packaging switch so entries are packaged only on Update Package (0.21.5) #421
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -300,6 +300,7 @@ function buildSecretValue(config: ProfileConfig, clientSecret: string): string { | |
| pkg_prefix: config.packages.prefix, | ||
| pkg_key: config.packages.metadataKey, | ||
| ...(config.packages.workflow ? { workflow: config.packages.workflow } : {}), | ||
| auto_packaging: config.packages.autoPackaging === false ? "false" : "true", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-running setup with Knowledge Base Used: |
||
| log_level: config.logging?.level || "INFO", | ||
| webhook_allow_list: config.security?.webhookAllowList || "", | ||
| enable_webhook_verification: config.security?.enableVerification !== false ? "true" : "false", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -710,12 +710,13 @@ def _send_updating_canvas_best_effort(payload: Payload) -> None: | |
| error=str(exc), | ||
| ) | ||
|
|
||
| def _send_bucketless_final_canvas_best_effort(payload: Payload) -> None: | ||
| """Start the final bucketless Canvas render after the quick acknowledgment. | ||
| def _send_final_canvas_best_effort(payload: Payload) -> None: | ||
|
|
||
| """Start the final Canvas render after the quick acknowledgment. | ||
|
|
||
| Bucketless mode has no packaging workflow to produce a later package | ||
| revision event, so the Canvas handler must render the final linked-package | ||
| view itself. Run it asynchronously to keep the webhook response fast. | ||
| Used when no packaging request is queued (bucketless mode, or automatic | ||
| packaging turned off), so no later package-revision event will redraw | ||
| the Canvas: render the current package and linked-package view now. | ||
| Run it asynchronously to keep the webhook response fast. | ||
| """ | ||
| if not payload.canvas_id or benchling is None or config is None: | ||
| return | ||
|
|
@@ -745,6 +746,22 @@ def _bucketless_response(payload: Payload, message: str) -> JSONResponse: | |
| status_code=202, | ||
| ) | ||
|
|
||
| def _manual_packaging_response(payload: Payload, message: str) -> JSONResponse: | ||
| logger.info( | ||
| "Automatic packaging is off; skipped package creation", | ||
| entry_id=payload.entry_id, | ||
| event_type=payload.event_type, | ||
| ) | ||
| return JSONResponse( | ||
| { | ||
| "entry_id": payload.entry_id, | ||
| "status": "SKIPPED", | ||
| "mode": "manual", | ||
| "message": message, | ||
| }, | ||
| status_code=202, | ||
| ) | ||
|
|
||
| async def _handle_event_impl(request: Request, _verified: None = None): | ||
| """Shared event webhook handling implementation.""" | ||
| try: | ||
|
|
@@ -774,11 +791,17 @@ async def _handle_event_impl(request: Request, _verified: None = None): | |
| ) | ||
| _send_updating_canvas_best_effort(payload) | ||
| if not config.s3_bucket_name: | ||
| _send_bucketless_final_canvas_best_effort(payload) | ||
| _send_final_canvas_best_effort(payload) | ||
| return _bucketless_response( | ||
| payload, | ||
| "Bucketless mode does not create a default package for canvas events.", | ||
| ) | ||
| if not config.auto_packaging: | ||
| _send_final_canvas_best_effort(payload) | ||
| return _manual_packaging_response( | ||
| payload, | ||
| "Automatic packaging is off; the Canvas shows the current package.", | ||
| ) | ||
| publish_packaging_request(entry_packager.sqs_client, packaging_queue_url, payload) | ||
|
|
||
| logger.info("Canvas update initiated from /event endpoint", canvas_id=payload.canvas_id) | ||
|
|
@@ -804,6 +827,13 @@ async def _handle_event_impl(request: Request, _verified: None = None): | |
| payload, | ||
| "Bucketless mode does not create a default package for entry events.", | ||
| ) | ||
| # A review event seals the package on acceptance and unseals it when the | ||
| # review is reopened, so it must run even when automatic packaging is off. | ||
| if not config.auto_packaging and payload.event_type != "v2.entry.updated.reviewRecord": | ||
|
|
||
| return _manual_packaging_response( | ||
| payload, | ||
| "Automatic packaging is off; click Update Package on the entry's Canvas to package it.", | ||
| ) | ||
|
|
||
| publish_packaging_request(entry_packager.sqs_client, packaging_queue_url, payload) | ||
|
|
||
|
|
@@ -948,11 +978,17 @@ async def _handle_canvas_impl(request: Request, _verified: None = None): | |
|
|
||
| _send_updating_canvas_best_effort(payload) | ||
| if not config.s3_bucket_name: | ||
| _send_bucketless_final_canvas_best_effort(payload) | ||
| _send_final_canvas_best_effort(payload) | ||
| return _bucketless_response( | ||
| payload, | ||
| "Bucketless mode does not create a default package for canvas initialization.", | ||
| ) | ||
| if not config.auto_packaging: | ||
| _send_final_canvas_best_effort(payload) | ||
|
Comment on lines
+986
to
+987
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A new Canvas in manual mode uses a renderer that always draws package links when a bucket is configured, even when no package exists. It also receives no update time, so the final footer says “Pending update.” Nothing is queued to clear that state. Check for the current package and show “Package Not Created” when it is absent. Knowledge Base Used: Webhook event and canvas handling
Comment on lines
+986
to
+987
|
||
| return _manual_packaging_response( | ||
| payload, | ||
| "Automatic packaging is off; the Canvas shows the current package.", | ||
| ) | ||
| sqs_message_id = publish_packaging_request(entry_packager.sqs_client, packaging_queue_url, payload) | ||
|
|
||
| logger.info( | ||
|
|
@@ -1193,13 +1229,14 @@ def handle_refresh_canvas(payload, button_id, benchling, config): | |
| webhook was reconfigured and restarted with a bucket after this canvas | ||
| was drawn), transition to the bucketed flow — enqueue a packaging | ||
| request to create the default package and render the standard canvas. | ||
| Otherwise, re-run the bucketless linked-package lookup. | ||
| Otherwise, or when automatic packaging is off, re-render the Canvas | ||
| from the current package and linked-package lookup without enqueuing. | ||
| """ | ||
| logger.info("Refresh canvas requested", entry_id=payload.entry_id, button_id=button_id) | ||
|
|
||
| _send_updating_canvas_best_effort(payload) | ||
|
|
||
| if config.s3_bucket_name: | ||
| if config.s3_bucket_name and config.auto_packaging: | ||
| # A bucket was configured after this (bucketless) canvas was drawn: | ||
| # initiate default package creation instead of re-rendering bucketless. | ||
| assert entry_packager is not None | ||
|
|
@@ -1221,7 +1258,7 @@ def handle_refresh_canvas(payload, button_id, benchling, config): | |
| status_code=202, | ||
| ) | ||
|
|
||
| _send_bucketless_final_canvas_best_effort(payload) | ||
| _send_final_canvas_best_effort(payload) | ||
| return JSONResponse({"status": "ACCEPTED", "message": "Refreshing canvas..."}, status_code=202) | ||
|
|
||
| def handle_view_metadata(payload, button_id, benchling, config): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documented Refresh Canvas action is not available on a normal bucketed Canvas.
create_main_navigation_buttonsstill offers only Browse Package and Update Package whenever a bucket is configured. Add a refresh button for manual mode, or explain that this action only exists on bucketless Canvases.Knowledge Base Used: Webhook event and canvas handling
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!