Skip to content

Commit

Permalink
Use attributes instead of key.
Browse files Browse the repository at this point in the history
  • Loading branch information
YooSunYoung committed Oct 31, 2024
1 parent 19a3e11 commit 5cc22a7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion resources/config.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"scicat": {
"host": "https://scicat.host",
"token": "JWT_TOKEN",
"headers": {},
"additional_headers": {},
"timeout": 0,
"stream": true,
"verify": false,
Expand Down
8 changes: 4 additions & 4 deletions src/scicat_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def create_scicat_dataset(
"""
logger.info("Sending POST request to create new dataset")
response = _post_to_scicat(
url=config.urls["datasets"],
url=config.urls.datasets,
posting_obj=dataset,
headers=config.additional_headers,
timeout=config.timeout,
Expand Down Expand Up @@ -84,7 +84,7 @@ def create_scicat_origdatablock(
"""
logger.info("Sending POST request to create new origdatablock")
response = _post_to_scicat(
url=config.urls["origdatablocks"],
url=config.urls.origdatablocks,
posting_obj=origdatablock,
headers=config.additional_headers,
timeout=config.timeout,
Expand Down Expand Up @@ -123,7 +123,7 @@ def check_dataset_by_pid(
pid: str, config: SciCatOptions, logger: logging.Logger
) -> bool:
response = _get_from_scicat(
url=urljoin(config.host, f"datasets/{quote(pid)}"),
url=urljoin(config.host_address, f"datasets/{quote(pid)}"),
headers=config.additional_headers,
timeout=config.timeout,
stream=config.stream,
Expand Down Expand Up @@ -157,7 +157,7 @@ def check_dataset_by_metadata(
) -> bool:
metadata_dict = {f"scientificMetadata.{metadata_key}.value": metadata_value}
filter_string = '?filter={"where":' + json.dumps(metadata_dict) + "}"
url = urljoin(config.host, "datasets") + filter_string
url = urljoin(config.host_address, "datasets") + filter_string
logger.info("Checking if dataset exists by metadata with url: %s", url)
response = _get_from_scicat(
url=url,
Expand Down
10 changes: 6 additions & 4 deletions src/scicat_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,12 @@ class SciCatOptions:
@property
def urls(self) -> _ScicatAPIURLs:
return _ScicatAPIURLs(
datasets=urljoin(self.host, self.api_endpoints.datasets),
proposals=urljoin(self.host, self.api_endpoints.proposals),
origdatablocks=urljoin(self.host, self.api_endpoints.origdatablocks),
instruments=urljoin(self.host, self.api_endpoints.instruments),
datasets=urljoin(self.host_address, self.api_endpoints.datasets),
proposals=urljoin(self.host_address, self.api_endpoints.proposals),
origdatablocks=urljoin(
self.host_address, self.api_endpoints.origdatablocks
),
instruments=urljoin(self.host_address, self.api_endpoints.instruments),
)

@property
Expand Down

0 comments on commit 5cc22a7

Please sign in to comment.