diff --git a/cads_processing_api_service/adaptors.py b/cads_processing_api_service/adaptors.py index 896a510..846c491 100644 --- a/cads_processing_api_service/adaptors.py +++ b/cads_processing_api_service/adaptors.py @@ -24,7 +24,6 @@ def get_adaptor_properties( dataset: cads_catalogue.database.Resource, - dataset_data: cads_catalogue.database.ResourceData, ) -> dict[str, Any]: config: dict[str, Any] = dataset.adaptor_configuration if config: @@ -36,10 +35,10 @@ def get_adaptor_properties( setup_code = dataset.adaptor resources = config.pop("resources", {}) - constraints = dataset_data.constraints_data + constraints = dataset.constraints_data if constraints is not None: config["constraints"] = constraints - mapping = dataset_data.mapping + mapping = dataset.mapping if mapping is not None: config["mapping"] = mapping licences: list[cads_catalogue.database.Licence] = dataset.licences @@ -47,7 +46,7 @@ def get_adaptor_properties( config["licences"] = [ (licence.licence_uid, licence.revision) for licence in licences ] - form = dataset_data.form_data + form = dataset.form_data hash = dataset.adaptor_properties_hash adaptor_properties: dict[str, Any] = { @@ -64,11 +63,10 @@ def get_adaptor_properties( def make_system_job_kwargs( dataset: cads_catalogue.database.Resource, - dataset_data: cads_catalogue.database.ResourceData, request: dict[str, Any], adaptor_resources: dict[str, int], ) -> dict[str, Any]: - adaptor_properties = get_adaptor_properties(dataset, dataset_data) + adaptor_properties = get_adaptor_properties(dataset) # merge adaptor and dataset resources resources = dict(adaptor_resources, **adaptor_properties["resources"]) system_job_kwargs = { @@ -85,9 +83,8 @@ def make_system_job_kwargs( def instantiate_adaptor( dataset: cads_catalogue.database.Resource, - dataset_data: cads_catalogue.database.ResourceData, ) -> cads_adaptors.AbstractAdaptor: - adaptor_properties = get_adaptor_properties(dataset, dataset_data) + adaptor_properties = get_adaptor_properties(dataset) adaptor_class = cads_adaptors.get_adaptor_class( entry_point=adaptor_properties["entry_point"], setup_code=adaptor_properties["setup_code"], diff --git a/cads_processing_api_service/clients.py b/cads_processing_api_service/clients.py index e37169d..6938f16 100644 --- a/cads_processing_api_service/clients.py +++ b/cads_processing_api_service/clients.py @@ -60,9 +60,6 @@ class DatabaseClient(ogc_api_processes_fastapi.clients.BaseClient): job_table: type[cads_broker.database.SystemRequest] = attrs.field( default=cads_broker.database.SystemRequest ) - process_data_table: type[cads_catalogue.database.ResourceData] = attrs.field( - default=cads_catalogue.database.ResourceData - ) def get_processes( self, @@ -143,14 +140,12 @@ def get_process( db_utils.ConnectionMode.read ) with catalogue_sessionmaker() as catalogue_session: - resource, resource_data = utils.lookup_resource_by_id( + resource = utils.lookup_resource_by_id( resource_id=process_id, table=self.process_table, session=catalogue_session, ) - process_description = serializers.serialize_process_description( - resource, resource_data - ) + process_description = serializers.serialize_process_description(resource) process_description.outputs = { "asset": ogc_api_processes_fastapi.models.OutputDescription( title="Asset", @@ -204,18 +199,18 @@ def post_process_execution( db_utils.ConnectionMode.read ) with catalogue_sessionmaker() as catalogue_session: - resource, resource_data = utils.lookup_resource_by_id( + resource: cads_catalogue.database.Resource = utils.lookup_resource_by_id( resource_id=process_id, table=self.process_table, session=catalogue_session, ) - adaptor = adaptors.instantiate_adaptor(resource, resource_data) + adaptor = adaptors.instantiate_adaptor(resource) licences = adaptor.get_licences(execution_content) auth.validate_licences(execution_content, stored_accepted_licences, licences) job_id = str(uuid.uuid4()) structlog.contextvars.bind_contextvars(job_id=job_id) job_kwargs = adaptors.make_system_job_kwargs( - resource, resource_data, execution_content, adaptor.resources + resource, execution_content, adaptor.resources ) compute_sessionmaker = db_utils.get_compute_sessionmaker( mode=db_utils.ConnectionMode.write @@ -407,7 +402,7 @@ def get_job( (form_data,) = utils.get_resource_properties( resource_id=job.process_id, properties="form_data", - table=self.process_data_table, + table=self.process_table, session=catalogue_session, ) kwargs["request"] = { diff --git a/cads_processing_api_service/constraints.py b/cads_processing_api_service/constraints.py index c73d0ad..41726c8 100644 --- a/cads_processing_api_service/constraints.py +++ b/cads_processing_api_service/constraints.py @@ -17,12 +17,10 @@ def apply_constraints( db_utils.ConnectionMode.read ) with catalogue_sessionmaker() as catalogue_session: - dataset, dataset_data = utils.lookup_resource_by_id( + dataset = utils.lookup_resource_by_id( resource_id=process_id, table=table, session=catalogue_session ) - adaptor: cads_adaptors.AbstractAdaptor = adaptors.instantiate_adaptor( - dataset, dataset_data - ) + adaptor: cads_adaptors.AbstractAdaptor = adaptors.instantiate_adaptor(dataset) try: constraints: dict[str, Any] = adaptor.apply_constraints(request=request) except cads_adaptors.constraints.ParameterError as exc: diff --git a/cads_processing_api_service/serializers.py b/cads_processing_api_service/serializers.py index c1fed1f..610706e 100644 --- a/cads_processing_api_service/serializers.py +++ b/cads_processing_api_service/serializers.py @@ -53,7 +53,6 @@ def serialize_process_summary( def serialize_process_description( db_model: cads_catalogue.database.Resource, - db_data_model: cads_catalogue.database.ResourceData, ) -> ogc_api_processes_fastapi.models.ProcessDescription: """Convert provided database entry into a representation of the related process description. @@ -68,7 +67,7 @@ def serialize_process_description( Process description representation. """ process_summary = serialize_process_summary(db_model) - cds_form = db_data_model.form_data + cds_form = db_model.form_data process_inputs = {} if cds_form: process_inputs = translators.translate_cds_form(cds_form) diff --git a/cads_processing_api_service/utils.py b/cads_processing_api_service/utils.py index 621f6fd..4ba707e 100644 --- a/cads_processing_api_service/utils.py +++ b/cads_processing_api_service/utils.py @@ -91,12 +91,10 @@ def lookup_resource_by_id( row: cads_catalogue.database.Resource = ( session.execute(statement).unique().scalar_one() ) - row_data: cads_catalogue.database.ResourceData = row.resource_data except sqlalchemy.exc.NoResultFound: raise ogc_api_processes_fastapi.exceptions.NoSuchProcess() session.expunge(row) - session.expunge(row_data) - return row, row_data + return row @cachetools.cached( # type: ignore @@ -111,8 +109,7 @@ def lookup_resource_by_id( def get_resource_properties( resource_id: str, properties: str | tuple[str], - table: type[cads_catalogue.database.Resource] - | type[cads_catalogue.database.ResourceData], + table: type[cads_catalogue.database.Resource], session: sqlalchemy.orm.Session, ) -> tuple[Any, ...]: """Look for the resource identified by `id` into the Catalogue database.