-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add funcs for getting stored source #590
Merged
JoranAngevaare
merged 8 commits into
AxFoundation:master
from
JoranAngevaare:get_source_plugins
Nov 18, 2021
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
12c5f4e
add funcs for getting stored source
JoranAngevaare a0e91f9
add tests
JoranAngevaare 03e75f3
reshuffle
JoranAngevaare ec1cc5c
Update test_context.py
JoranAngevaare ad6712c
Merge branch 'master' into get_source_plugins
JoranAngevaare 75396fc
Reviews are nice
JoranAngevaare 46b20cf
reformat
JoranAngevaare 662a14a
stupid codefactor
JoranAngevaare File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -457,7 +457,7 @@ def _context_hash(self): | |
{data_type: (plugin.__version__, plugin.compressor, plugin.input_timeout) | ||
for data_type, plugin in self._plugin_class_registry.items() | ||
if not data_type.startswith('_temp_') | ||
}) | ||
}) | ||
return strax.deterministic_hash(base_hash_on_config) | ||
|
||
def _plugins_are_cached(self, targets: ty.Tuple[str],) -> bool: | ||
|
@@ -1381,10 +1381,9 @@ def get_df(self, run_id: ty.Union[str, tuple, list], | |
f"array fields. Please use get_array.") | ||
raise | ||
|
||
|
||
def get_zarr(self, run_ids, targets, storage='./strax_temp_data', | ||
progress_bar=False, overwrite=True, **kwargs): | ||
"""get perisistant arrays using zarr. This is useful when | ||
def get_zarr(self, run_ids, targets, storage='./strax_temp_data', | ||
progress_bar=False, overwrite=True, **kwargs): | ||
"""get persistent arrays using zarr. This is useful when | ||
loading large amounts of data that cannot fit in memory | ||
zarr is very compatible with dask. | ||
Targets are loaded into separate arrays and runs are merged. | ||
|
@@ -1656,6 +1655,52 @@ def copy_to_frontend(self, | |
f'Trying to write {data_key} to {t_sf} which already exists, ' | ||
'do you have two storage frontends writing to the same place?') | ||
|
||
def get_source(self, | ||
run_id: str, | ||
target: str, | ||
check_forbidden: bool = True, | ||
) -> ty.Union[set, None]: | ||
""" | ||
For a given run_id and target get the stored bases where we can | ||
start processing from, if no base is available, return None. | ||
|
||
:param run_id: run_id | ||
:param target: target | ||
:param check_forbidden: Check that we are not requesting to make | ||
a plugin that is forbidden by the context to be created. | ||
:return: set of plugin names that are needed to start processing | ||
from and are needed in order to build this target. | ||
""" | ||
if self.is_stored(run_id, target): | ||
return {target} | ||
|
||
deps = strax.to_str_tuple(self._plugin_class_registry[target].depends_on) | ||
if not deps: | ||
return None | ||
|
||
forbidden = strax.to_str_tuple(self.context_config['forbid_creation_of']) | ||
if check_forbidden and target in forbidden: | ||
return None | ||
|
||
stored_sources = set() | ||
for dep in deps: | ||
if self.is_stored(run_id, dep): | ||
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. isnt this redundent? shouldnt the recursive call to self.get_source check if its stored or not? 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. Ah great point! |
||
stored_sources |= {dep} | ||
elif check_forbidden and dep in forbidden: | ||
self.log.warning(f'For run {run_id}:{target}, you are not ' | ||
f'allowed to make {dep} and it is not stored. ' | ||
f'Disable with check_forbidden=False' | ||
) | ||
return None | ||
else: | ||
deeper = self.get_source(run_id, dep, check_forbidden=check_forbidden) | ||
if deeper is None: | ||
self.log.info(f'For run {run_id}, requested dependency ' | ||
f'{dep} for {target} is not stored') | ||
return None | ||
stored_sources |= deeper | ||
return stored_sources | ||
|
||
def _is_stored_in_sf(self, run_id, target, | ||
storage_frontend: strax.StorageFrontend) -> bool: | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe be more explicit in this case and raise an error or make a warning. Like you have further down.
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.
good point!