-
Notifications
You must be signed in to change notification settings - Fork 0
Cache fragment metadata for workspaces on the cloud #63
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bd47434
Cache fragment metadata for workspaces on the cloud
de50b33
Add examples workspace for testing
c6000b9
Run test.sh for the non-cloud case
9452be4
Remove AZURE_CLI_DISABLE_CONNECTION_VERIFICATION variable
0897fde
Cleanup
1df8d8b
Revert to develop
b8b79ba
Cache metadata per array rather than the entire workspace based on in…
2fb7850
Fix paths
7d80e8e
Add genomicsdb_common.py
22eee80
No need for examples in PYTHONPATH
9c56f4f
License
7be55e6
Fix scripts
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 hidden or 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,64 @@ | ||
| #!/bin/bash | ||
|
|
||
| # The MIT License (MIT) | ||
| # Copyright (c) 2024 dātma, inc™ | ||
| # | ||
| # Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| # this software and associated documentation files (the "Software"), to deal in | ||
| # the Software without restriction, including without limitation the rights to | ||
| # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| # the Software, and to permit persons to whom the Software is furnished to do so, | ||
| # subject to the following conditions: | ||
| # | ||
| # The above copyright notice and this permission notice shall be included in all | ||
| # copies or substantial portions of the Software. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| # | ||
|
|
||
| set -e | ||
|
|
||
| # Install Dependencies | ||
| sudo apt-get update | ||
| sudo apt-get -y install azure-cli | ||
|
|
||
| # Install Azurite | ||
| sudo npm install -g azurite | ||
| which azurite | ||
| echo "azurite version = $(azurite --version)" | ||
|
|
||
| AZURITE_DIR=$GITHUB_WORKSPACE/azurite | ||
| mkdir -p $AZURITE_DIR | ||
| pushd $AZURITE_DIR | ||
|
|
||
| # Generate certificates | ||
| openssl req -newkey rsa:2048 -x509 -nodes -keyout key.pem -new -out cert.pem -sha256 -days 365 -addext "subjectAltName=IP:127.0.0.1" -subj "/C=CO/ST=ST/L=LO/O=OR/OU=OU/CN=CN" | ||
| sudo cp $AZURITE_DIR/cert.pem /usr/local/share/ca-certificates/ca-certificates.crt | ||
| sudo update-ca-certificates | ||
|
|
||
| # Start azurite | ||
| azurite --silent --skipApiVersionCheck --loose --location $AZURITE_DIR --cert cert.pem --key key.pem &> /dev/null & | ||
|
|
||
| # Env to run tests | ||
| export AZURE_STORAGE_ACCOUNT=devstoreaccount1 | ||
| export AZURE_STORAGE_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw== | ||
| export AZURE_STORAGE_SERVICE_ENDPOINT="https://127.0.0.1:10000/devstoreaccount1" | ||
| export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt | ||
|
|
||
| # Create container called test as TileDB expects the container to be already created | ||
| AZURE_CONNECTION_STRING="DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=https://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=https://127.0.0.1:10001/devstoreaccount1;" | ||
| az storage container create -n test --connection-string $AZURE_CONNECTION_STRING | ||
|
|
||
| # Setup examples workspace on azurite | ||
| cd $GITHUB_WORKSPACE/examples | ||
| tar xzvf examples_ws.tgz | ||
| echo "Azure Storage Blob upload-batch..." | ||
| az storage blob upload-batch -d test/ws -s ws --connection-string $AZURE_CONNECTION_STRING | ||
| echo "Azure Storage Blob upload-batch DONE" | ||
|
|
||
| popd |
This file contains hidden or 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
Binary file not shown.
This file contains hidden or 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 hidden or 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,101 @@ | ||
| # | ||
| # genomicsdb_common python script | ||
| # | ||
| # The MIT License | ||
| # | ||
| # Copyright (c) 2024 dātma, inc™ | ||
| # | ||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| # of this software and associated documentation files (the "Software"), to deal | ||
| # in the Software without restriction, including without limitation the rights | ||
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| # copies of the Software, and to permit persons to whom the Software is | ||
| # furnished to do so, subject to the following conditions: | ||
| # | ||
| # The above copyright notice and this permission notice shall be included in | ||
| # all copies or substantial portions of the Software. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| # THE SOFTWARE. | ||
| # | ||
|
|
||
| import json | ||
| import os | ||
| import re | ||
|
|
||
| import genomicsdb | ||
|
|
||
|
|
||
| def normalize_path(path): | ||
| if "://" in path: | ||
| return path | ||
| else: | ||
| return os.path.abspath(path) | ||
|
|
||
|
|
||
| def parse_vidmap_json(vidmap_file, intervals=None): | ||
| if isinstance(intervals, str): | ||
| is_file = True | ||
| else: | ||
| is_file = False | ||
| contigs_map = {} | ||
| vidmap = json.loads(genomicsdb.read_entire_file(vidmap_file)) | ||
| contigs = vidmap["contigs"] | ||
| if intervals and is_file: | ||
| with open(intervals) as file: | ||
| intervals = [line.rstrip() for line in file] | ||
| all_intervals = not intervals | ||
| if not intervals: | ||
| intervals = [] | ||
| for contig in contigs: | ||
| contigs_map[contig["name"]] = contig | ||
| if all_intervals: | ||
| intervals.append(contig["name"]) | ||
| return contigs_map, intervals | ||
|
|
||
|
|
||
| interval_pattern = re.compile(r"(.*):(.*)-(.*)|(.*):(.*)|(.*)") | ||
|
|
||
|
|
||
| # get tiledb offsets for interval | ||
| def parse_interval(interval: str): | ||
| result = re.match(interval_pattern, interval) | ||
| if result: | ||
| length = len(result.groups()) | ||
| if length == 6: | ||
| if result.group(1) and result.group(2) and result.group(3): | ||
| return result.group(1), int(result.group(2)), int(result.group(3)) | ||
| elif result.group(4) and result.group(5): | ||
| return result.group(4), int(result.group(5)), None | ||
| elif result.group(6): | ||
| return result.group(6), 1, None | ||
| raise RuntimeError(f"Interval {interval} could not be parsed") | ||
|
|
||
|
|
||
| def get_arrays(contigs_map, intervals, partitions): | ||
| arrays = set() | ||
| for interval in intervals: | ||
| contig, start, end = parse_interval(interval) | ||
| if contig in contigs_map: | ||
| contig_offset = contigs_map[contig]["tiledb_column_offset"] + start - 1 | ||
| length = contigs_map[contig]["length"] | ||
| if end and end < length + 1: | ||
| contig_end = contigs_map[contig]["tiledb_column_offset"] + end - 1 | ||
| else: | ||
| end = length | ||
| contig_end = contigs_map[contig]["tiledb_column_offset"] + length - 1 | ||
| else: | ||
| print(f"Contig({contig}) not found in vidmap.json") | ||
| continue | ||
|
|
||
| for partition in partitions: | ||
| if contig_end < partition["begin"]["tiledb_column"] or contig_offset > partition["end"]["tiledb_column"]: | ||
| continue | ||
| arrays.add(partition["array_name"]) | ||
|
|
||
| return arrays | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
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.
I dunno if this is better or worse than regex -- but maybe we could consider using string
split(plus check for existence of the delimiter). Might be simplerThere 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.
This is done just while parsing intervals for the cli. I don't expect much time spent on this function. Guess using split is simpler.