Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rettigl committed Jan 14, 2025
1 parent 6f04b9c commit 5c7cc0e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/sed/loader/mpes/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from sed.core.config import save_env_var
from sed.core.logging import setup_logging

logger = setup_logging("flash_metadata_retriever")
logger = setup_logging("mpes_metadata_retriever")


class MetadataRetriever:
Expand All @@ -43,12 +43,6 @@ def __init__(self, metadata_config: dict, token: str = None) -> None:
# Try to load token from config or .env file
self.token = read_env_var("ELAB_TOKEN")

if not self.token:
raise ValueError(
"Token is required for metadata collection. Either provide a token "
"parameter or set the ELAB_TOKEN environment variable.",
)

self._config = metadata_config

self.url = str(metadata_config.get("elab_url"))
Expand Down Expand Up @@ -229,6 +223,12 @@ def fetch_elab_metadata(self, runs: list[str], metadata: dict) -> dict:
Returns:
dict: Updated metadata dictionary
"""
if not self.token:
logger.warning(
"No valid token found. Token is required for metadata collection. Either provide "
"a token parameter or set the ELAB_TOKEN environment variable.",
)
return metadata
logger.info("Collecting data from the elabFTW instance...")
# Get the experiment
try:
Expand Down Expand Up @@ -270,7 +270,7 @@ def fetch_elab_metadata(self, runs: list[str], metadata: dict) -> dict:
if item.metadata is not None:
metadata_json = json.loads(item.metadata)
for key, val in metadata_json["extra_fields"].items():
if val["value"] and val["value"] != ["None"]:
if val["value"] is not None and val["value"] != "" and val["value"] != ["None"]:
try:
metadata["elabFTW"][category][key] = float(val["value"])
except ValueError:
Expand Down

0 comments on commit 5c7cc0e

Please sign in to comment.