Skip to content

Commit

Permalink
remove deprecation methods and dependency. We have decided to make a …
Browse files Browse the repository at this point in the history
…clean break with pyscicat versions. If the method does not exist in the new backend it will be deleted from pyscicat.
  • Loading branch information
LAShemilt committed May 11, 2023
1 parent 1291d99 commit b373c11
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 160 deletions.
159 changes: 0 additions & 159 deletions pyscicat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from pydantic import BaseModel
import requests

from deprecation import deprecated

from pyscicat.model import (
Attachment,
Expand Down Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ include_package_data = True
install_requires =
pydantic
requests
deprecation

packages = find:
python_requires = >=3.7

Expand Down

0 comments on commit b373c11

Please sign in to comment.