Skip to content

Commit

Permalink
deprecating methods that cannot be used in the new backend with the d…
Browse files Browse the repository at this point in the history
…eprecation package.
  • Loading branch information
LAShemilt committed Mar 20, 2023
1 parent c7dc17c commit 9935ad4
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions pyscicat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import hashlib
import logging
import json
import re
from typing import Optional
from urllib.parse import urljoin, quote_plus

from pydantic import BaseModel
import requests

from deprecation import deprecated

from pyscicat.model import (
Attachment,
Datablock,
Expand Down Expand Up @@ -128,7 +129,6 @@ def _call_endpoint(
if (
allow_404
and response.status_code == 404
and re.match(r"Unknown (.+ )?id", err.get("message", ""))
):
# The operation failed but because the object does not exist in SciCat.
logger.error("Error in operation %s: %s", operation, err)
Expand All @@ -141,13 +141,18 @@ 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 obsolete and it will be remove in next relesases
This function is obsoleteand it will be remove in next relesases
Parameters
Expand Down Expand Up @@ -218,6 +223,12 @@ 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
Expand Down Expand Up @@ -255,10 +266,14 @@ def datasets_raw_replace(self, dataset: Dataset) -> str:
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.
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
Expand Down Expand Up @@ -321,6 +336,8 @@ 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:
Expand Down

0 comments on commit 9935ad4

Please sign in to comment.