Skip to content

Commit

Permalink
bring back comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zain-sohail committed Jan 14, 2025
1 parent 977223d commit 25a935b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion .cspell/custom-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ dictionarized
dictmerge
DLDAUX
DOOCS
dotenv
dpkg
dropna
dset
Expand Down
7 changes: 5 additions & 2 deletions src/sed/loader/flash/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_metadata(
pid = f"{beamtime_id}/{run}"
logger.debug(f"Retrieving metadata for PID: {pid}")
metadata_run = self._get_metadata_per_run(pid)
metadata.update(metadata_run)
metadata.update(metadata_run) # TODO: Not correct for multiple runs

logger.debug(f"Retrieved metadata with {len(metadata)} entries")
return metadata
Expand Down Expand Up @@ -111,18 +111,21 @@ def _get_metadata_per_run(self, pid: str) -> dict:
)
dataset_response.raise_for_status()

# Check if response is an empty object because wrong url for older implementation
if not dataset_response.content:
logger.debug("Empty response, trying old URL format")
dataset_response = requests.get(
self._create_old_dataset_url(pid),
headers=headers2,
timeout=10,
)
# If the dataset request is successful, return the retrieved metadata
# as a JSON object
return dataset_response.json()

except requests.exceptions.RequestException as exception:
logger.warning(f"Failed to retrieve metadata for PID {pid}: {str(exception)}")
return {}
return {} # Return an empty dictionary for this run

def _create_old_dataset_url(self, pid: str) -> str:
return "{burl}/{url}/%2F{npid}".format(
Expand Down

0 comments on commit 25a935b

Please sign in to comment.