forked from bluesky/tiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactors pulled from bluesky#668 (bluesky#686)
* Sort enum members. * Move structure_family to the end, matching migration result. * Sort * Only set include_data_sources param if not default (false). * Refactor link-writing into separate module. * Refactor structure family check into dependency * remove server.core.FULL_LINKS * Clarify default data_sources for CatalogNodeAdapter * Add structure_families to dependency check for put '/[node|table]/full' * Create node uses structure_family of data_source * Be robust against __doc__ being None. * Use dask.dataframe.core, not new dask-expr. --------- Co-authored-by: Padraic Shafer <[email protected]>
- Loading branch information
1 parent
cd69a84
commit 7c875b8
Showing
12 changed files
with
174 additions
and
157 deletions.
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
""" | ||
Generate the 'links' section of the response JSON. | ||
The links vary by structure family. | ||
""" | ||
from ..structures.core import StructureFamily | ||
|
||
|
||
def links_for_node(structure_family, structure, base_url, path_str): | ||
links = {} | ||
links = LINKS_BY_STRUCTURE_FAMILY[structure_family]( | ||
structure_family, structure, base_url, path_str | ||
) | ||
links["self"] = f"{base_url}/metadata/{path_str}" | ||
return links | ||
|
||
|
||
def links_for_array(structure_family, structure, base_url, path_str): | ||
links = {} | ||
block_template = ",".join(f"{{{index}}}" for index in range(len(structure.shape))) | ||
links["block"] = f"{base_url}/array/block/{path_str}?block={block_template}" | ||
links["full"] = f"{base_url}/array/full/{path_str}" | ||
return links | ||
|
||
|
||
def links_for_awkward(structure_family, structure, base_url, path_str): | ||
links = {} | ||
links["buffers"] = f"{base_url}/awkward/buffers/{path_str}" | ||
links["full"] = f"{base_url}/awkward/full/{path_str}" | ||
return links | ||
|
||
|
||
def links_for_container(structure_family, structure, base_url, path_str): | ||
links = {} | ||
links["full"] = f"{base_url}/container/full/{path_str}" | ||
links["search"] = f"{base_url}/search/{path_str}" | ||
return links | ||
|
||
|
||
def links_for_table(structure_family, structure, base_url, path_str): | ||
links = {} | ||
links["partition"] = f"{base_url}/table/partition/{path_str}?partition={{index}}" | ||
links["full"] = f"{base_url}/table/full/{path_str}" | ||
return links | ||
|
||
|
||
LINKS_BY_STRUCTURE_FAMILY = { | ||
StructureFamily.array: links_for_array, | ||
StructureFamily.awkward: links_for_awkward, | ||
StructureFamily.container: links_for_container, | ||
StructureFamily.sparse: links_for_array, # spare and array are the same | ||
StructureFamily.table: links_for_table, | ||
} |
Oops, something went wrong.