From b373c1109f2e109d571b73767919005981e08df4 Mon Sep 17 00:00:00 2001 From: vpf26432 Date: Thu, 11 May 2023 12:26:10 +0000 Subject: [PATCH] remove deprecation methods and dependency. We have decided to make a clean break with pyscicat versions. If the method does not exist in the new backend it will be deleted from pyscicat. --- pyscicat/client.py | 159 --------------------------------------------- setup.cfg | 2 +- 2 files changed, 1 insertion(+), 160 deletions(-) diff --git a/pyscicat/client.py b/pyscicat/client.py index f7ce80d..46e0412 100644 --- a/pyscicat/client.py +++ b/pyscicat/client.py @@ -11,7 +11,6 @@ from pydantic import BaseModel import requests -from deprecation import deprecated from pyscicat.model import ( Attachment, @@ -143,49 +142,6 @@ def _call_endpoint( ) return result - @deprecated(deprecated_in='1.0.0', details='this method no longer works with the new Scicat ' - 'backend, which does not have a method to ' - 'replaceOrCreate dataset. update_dataset or ' - 'upload_dataset should be used' - ) - def datasets_replace(self, dataset: Dataset) -> str: - """ - Create a new dataset or update an existing one - This function was renamed. - It is still accessible with the original name for backward compatibility - The original names were upload_dataset replace_datasets - This function is obsoleteand it will be remove in next relesases - - - Parameters - ---------- - dataset : Dataset - Dataset to create or update - - Returns - ------- - str - pid of the dataset - """ - - if isinstance(dataset, RawDataset): - dataset_url = "RawDataSets/replaceOrCreate" - elif isinstance(dataset, DerivedDataset): - dataset_url = "DerivedDatasets/replaceOrCreate" - else: - raise TypeError( - "Dataset type not recognized (not Derived or Raw dataset instances)" - ) - return self._call_endpoint( - cmd="post", endpoint=dataset_url, data=dataset, operation="datasets_replace" - ) - - """ - Upload or create a new dataset - Original name, kept for for backward compatibility - """ - upload_dataset = datasets_replace - replace_dataset = datasets_replace def datasets_create(self, dataset: Dataset) -> str: """ @@ -225,82 +181,6 @@ def datasets_create(self, dataset: Dataset) -> str: upload_new_dataset = datasets_create create_dataset = datasets_create - @deprecated(deprecated_in='1.0.0', details='this method no longer works with the new' - ' Scicat backend, which only has' - ' one end point for Datasets and does not' - ' retain separate RawDataset and' - ' DerivedDatasetEndpoints. update_dataset' - 'or upload_dataset should be used') - def datasets_raw_replace(self, dataset: Dataset) -> str: - """ - Create a new raw dataset or update an existing one - This function was renamed. - It is still accessible with the original name for backward compatibility - The original names were repalce_raw_dataset and upload_raw_dataset - This function is obsolete and it will be removed in future releases - - Parameters - ---------- - dataset : Dataset - Dataset to load - - Returns - ------- - str - pid (or unique identifier) of the newly created dataset - - Raises - ------ - ScicatCommError - Raises if a non-20x message is returned - """ - return self._call_endpoint( - cmd="post", - endpoint="RawDataSets/replaceOrCreate", - data=dataset, - operation="datasets_raw_replace", - ) - - """ - Upload a raw dataset - Original name, kept for for backward compatibility - """ - upload_raw_dataset = datasets_raw_replace - replace_raw_dataset = datasets_raw_replace - - @deprecated(deprecated_in='1.0.0', details='this method no longer works with the new Scicat ' - 'backend,which only has one end point for ' - 'Datasets and does not retain separate RawDataset' - ' and DerivedDatasetEndpoints.' - 'update_datsets or upload_dataset should be used') - def datasets_derived_replace(self, dataset: Dataset) -> str: - """ - Create a new derived dataset or update an existing one. This function was renamed. - It is still accessible with the original name for backward compatibility - The original names were replace_derived_dataset and upload_derived_dataset - - - Parameters - ---------- - dataset : Dataset - Dataset to upload - - Returns - ------- - str - pid (or unique identifier) of the newly created dataset - - Raises - ------ - ScicatCommError - Raises if a non-20x message is returned - """ - return self._call_endpoint( - cmd="post", - endpoint="DerivedDataSets/replaceOrCreate", - data=dataset, - operation="datasets_derived_replace", - ) def datasets_update(self, dataset: Dataset, pid: str) -> str: """Updates an existing dataset @@ -338,46 +218,7 @@ def datasets_update(self, dataset: Dataset, pid: str) -> str: """ update_dataset = datasets_update - @deprecated(deprecated_in='1.0.0', details='this method no longer works with the new Scicat backend,' - ' function datasets_origdatablock should be used.') - def datasets_datablock_create( - self, datablock: Datablock, datasetType: str = "RawDatasets" - ) -> dict: - """ - Create a new datablock for a dataset. - The dataset can be both Raw or Derived. - It is still accessible with the original name for backward compatibility - The original names were create_dataset_datablock and upload_datablock - This function is obsolete and will be removed in future releases - Function datasets_datablock_create should be used. - - Parameters - ---------- - datablock : Datablock - Datablock to upload - - Returns - ------- - datablock : Datablock - The created Datablock with id - - Raises - ------ - ScicatCommError - Raises if a non-20x message is returned - """ - endpoint = f"{datasetType}/{quote_plus(datablock.datasetId)}/origdatablocks" - return self._call_endpoint( - cmd="post", - endpoint=endpoint, - data=datablock, - operation="datasets_datablock_create", - ) - """ - Upload a Datablock - Original name, kept for for backward compatibility - """ upload_datablock = datasets_datablock_create create_dataset_datablock = datasets_datablock_create diff --git a/setup.cfg b/setup.cfg index 1b1c247..7264ad5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -27,7 +27,7 @@ include_package_data = True install_requires = pydantic requests - deprecation + packages = find: python_requires = >=3.7