diff --git a/src/rapidata/rapidata_client/config/_qr_preview.py b/src/rapidata/rapidata_client/config/_qr_preview.py index ac4c321fd..e88ef3e86 100644 --- a/src/rapidata/rapidata_client/config/_qr_preview.py +++ b/src/rapidata/rapidata_client/config/_qr_preview.py @@ -21,6 +21,10 @@ _PREVIEW_URL_TEMPLATE = "https://rapids.{environment}/preview/campaign?id={campaign_id}" +_APP_JOB_DEFINITION_URL_TEMPLATE = ( + "https://app.{environment}/definitions/{job_definition_id}" +) +_APP_ORDER_URL_TEMPLATE = "https://app.{environment}/order/detail/{order_id}" def build_campaign_preview_url(environment: str, campaign_id: str) -> str: @@ -30,6 +34,38 @@ def build_campaign_preview_url(environment: str, campaign_id: str) -> str: ) +def build_job_definition_preview_url(environment: str, job_definition_id: str) -> str: + """Return the app URL for previewing the given job definition.""" + return _APP_JOB_DEFINITION_URL_TEMPLATE.format( + environment=environment, job_definition_id=job_definition_id + ) + + +def build_order_preview_url(environment: str, order_id: str) -> str: + """Return the app URL for the given order's detail page.""" + return _APP_ORDER_URL_TEMPLATE.format(environment=environment, order_id=order_id) + + +def print_job_definition_preview_link( + environment: str, job_definition_id: str +) -> None: + """Print the app URL for previewing the given job definition.""" + if rapidata_config.logging.silent_mode: + return + + url = build_job_definition_preview_url(environment, job_definition_id) + managed_print(f"Preview in dashboard: {url}") + + +def print_order_preview_link(environment: str, order_id: str) -> None: + """Print the app URL for the given order's detail page.""" + if rapidata_config.logging.silent_mode: + return + + url = build_order_preview_url(environment, order_id) + managed_print(f"Preview in dashboard: {url}") + + def print_campaign_preview_qr(environment: str, campaign_id: str) -> None: """Print a terminal QR code that links to the campaign preview page. diff --git a/src/rapidata/rapidata_client/job/rapidata_job_manager.py b/src/rapidata/rapidata_client/job/rapidata_job_manager.py index da2ff9f63..4bc01ae4f 100644 --- a/src/rapidata/rapidata_client/job/rapidata_job_manager.py +++ b/src/rapidata/rapidata_client/job/rapidata_job_manager.py @@ -4,6 +4,7 @@ from rapidata.rapidata_client.config import logger, tracer from rapidata.rapidata_client.config._qr_preview import ( print_campaign_preview_qr_for_pipeline, + print_job_definition_preview_link, ) from rapidata.rapidata_client.datapoints._datapoint import Datapoint from rapidata.rapidata_client.workflow import Workflow @@ -143,6 +144,10 @@ def _create_general_job_definition( openapi_service=self._openapi_service, pipeline_id=job_definition_response.pipeline_id, ) + print_job_definition_preview_link( + environment=self._openapi_service.environment, + job_definition_id=job_model.id, + ) return job_model diff --git a/src/rapidata/rapidata_client/order/_rapidata_order_builder.py b/src/rapidata/rapidata_client/order/_rapidata_order_builder.py index 50b4f6e8f..f347b5b03 100644 --- a/src/rapidata/rapidata_client/order/_rapidata_order_builder.py +++ b/src/rapidata/rapidata_client/order/_rapidata_order_builder.py @@ -18,6 +18,7 @@ ) from rapidata.rapidata_client.config._qr_preview import ( print_campaign_preview_qr_for_pipeline, + print_order_preview_link, ) from rapidata.rapidata_client.validation.validation_set_manager import ( ValidationSetManager, @@ -191,6 +192,10 @@ def _create(self) -> RapidataOrder: openapi_service=self._openapi_service, pipeline_id=result.pipeline_id, ) + print_order_preview_link( + environment=self._openapi_service.environment, + order_id=order.id, + ) return order def _set_workflow(self, workflow: Workflow) -> RapidataOrderBuilder: