-
Notifications
You must be signed in to change notification settings - Fork 3
Hextof lab loader #534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Hextof lab loader #534
Changes from 1 commit
ceeb637
1c23973
e8965ee
d14bc95
289d037
dcfe456
788d189
69e4595
f4fd755
053bc60
dbb7e94
df78f69
5cd23b4
5b411d1
3739505
a571fa2
73d7b5f
aa42cd8
4734fea
ec2160f
4a6ec53
227dfb1
ef3dcda
dda08a9
475eb8c
a145bea
5da3928
4acc465
32e0643
2721a2b
6c7c23e
e13577a
fb47cd3
528e6aa
bf1dda1
f817476
4e07271
fdeacbf
58c8e01
87ec0cf
2b9372e
45e72a2
aa8dd76
45b33a0
cf71927
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,8 +56,10 @@ | |
| set_verbosity(logger, self._verbose) | ||
|
|
||
| self.instrument: str = self._config["core"].get("instrument", "hextof") # default is hextof | ||
| self.beamtime_dir: str = None | ||
| self.raw_dir: str = None | ||
| self.processed_dir: str = None | ||
| self.meta_dir: str = None | ||
|
|
||
| @property | ||
| def verbose(self) -> bool: | ||
|
|
@@ -94,9 +96,14 @@ | |
| # Only raw_dir is necessary, processed_dir can be based on raw_dir, if not provided | ||
| if "paths" in self._config["core"]: | ||
| raw_dir = Path(self._config["core"]["paths"].get("raw", "")) | ||
| print(raw_dir) | ||
| processed_dir = Path( | ||
| self._config["core"]["paths"].get("processed", raw_dir.joinpath("processed")), | ||
| ) | ||
| meta_dir = Path( | ||
| self._config["core"]["paths"].get("meta", raw_dir.joinpath("meta")), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The path logic is confusing right now as there is too many possibilities. I'd put the default as archiver_url in lab default config, and one automatic option.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part is also confusing for me, as don't really see how you can get from raw_dir to e.g. processed_dir with |
||
| ) | ||
| beamtime_dir = Path(raw_dir).parent | ||
|
|
||
| else: | ||
| try: | ||
|
|
@@ -130,11 +137,14 @@ | |
| raw_dir = raw_paths[0].resolve() | ||
|
|
||
| processed_dir = beamtime_dir.joinpath("processed") | ||
| meta_dir = beamtime_dir.joinpath("meta/fabtrack/") | ||
|
|
||
| processed_dir.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| self.beamtime_dir = str(beamtime_dir) | ||
| self.raw_dir = str(raw_dir) | ||
| self.processed_dir = str(processed_dir) | ||
| self.meta_dir = str(meta_dir) | ||
|
|
||
| @property | ||
| def available_runs(self) -> list[int]: | ||
|
|
@@ -209,7 +219,7 @@ | |
| # Return the list of found files | ||
| return [str(file.resolve()) for file in files] | ||
|
|
||
| def parse_metadata(self, token: str = None) -> dict: | ||
| def parse_scicat_metadata(self, token: str = None) -> dict: | ||
| """Uses the MetadataRetriever class to fetch metadata from scicat for each run. | ||
|
|
||
| Returns: | ||
|
|
@@ -225,6 +235,23 @@ | |
|
|
||
| return metadata | ||
|
|
||
| def parse_local_metadata(self) -> dict: | ||
| """Uses the MetadataRetriever class to fetch metadata from local folder for each run. | ||
|
|
||
| Returns: | ||
| dict: Metadata dictionary | ||
| """ | ||
| metadata_retriever = MetadataRetriever(self._config["metadata"]) | ||
| metadata = metadata_retriever.get_local_metadata( | ||
| beamtime_id=self._config["core"]["beamtime_id"], | ||
| beamtime_dir=self.beamtime_dir, | ||
| meta_dir=self.meta_dir, | ||
| runs=self.runs, | ||
| metadata=self.metadata, | ||
| ) | ||
|
|
||
| return metadata | ||
|
|
||
| def get_count_rate( | ||
| self, | ||
| fids: Sequence[int] = None, # noqa: ARG002 | ||
|
|
@@ -403,7 +430,12 @@ | |
| filter_timed_by_electron=filter_timed_by_electron, | ||
| ) | ||
|
|
||
| self.metadata.update(self.parse_metadata(token) if collect_metadata else {}) | ||
| if len(self.parse_scicat_metadata(token)) == 0: | ||
| print("No SciCat metadata available, checking local folder") | ||
| self.metadata.update(self.parse_local_metadata()) | ||
| else: | ||
| print("Metadata taken from SciCat") | ||
| self.metadata.update(self.parse_scicat_metadata(token) if collect_metadata else {}) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessarily a big issue but the parse_scicat_metadata is called twice in case it exists, once during if and once during else. scicat_metadata = self.parse_scicat_metadata(token) if collect_metadata else {})
self.metadata.update(scicat_metadata)
if len(scicat_metadata) == 0:
print("No SciCat metadata available, checking local folder")
self.metadata.update(self.parse_local_metadata())
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine for me. Just wanted to implement check if SciCat entries available then go for it, if not then check local folder to be compatible to older beamtimes. |
||
| self.metadata.update(bh.metadata) | ||
|
|
||
| print(f"loading complete in {time.time() - t0: .2f} s") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding a new entry to the config model, I'd suggest we just allow directory paths in
sed/src/sed/core/config_model.py
Line 327 in 4a6ec53
what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine for me. I just thought as it anyway would be one of the main folders inside the beamtime folder.