-
Notifications
You must be signed in to change notification settings - Fork 3
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
WIP: Refactor #3
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4330418
Add SLKFile class
antarcticrainforest 940fc20
Remove requirements.txt file
0f520f4
Import logger from fsspec.core
3c2292b
Add mypy type checking
48b4560
Adjust README
2f01646
Update README
78d178a
Add unit tests
antarcticrainforest 733d6ff
Reformat with black
antarcticrainforest 3ec7048
Set file premissions on correct output file path
antarcticrainforest 4460564
Update slkspec/core.py
antarcticrainforest 5246b11
Update slkspec/core.py
antarcticrainforest 596ff83
Update slkspec/core.py
antarcticrainforest fed9fe0
Update slkspec/tests/conftest.py
antarcticrainforest dce614f
Update slkspec/core.py
antarcticrainforest 7f8a117
Update slkspec/core.py
antarcticrainforest 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[run] | ||
omit = */tests/*, slkspec/_version.py | ||
concurrency = multiprocessing | ||
|
||
[report] | ||
exclude_lines = | ||
pragma: no cover |
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,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" | ||
directory: "/.github/dependabot/" | ||
schedule: | ||
interval: "daily" |
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,2 @@ | ||
fsspec==2022.11.0 | ||
pyslk==1.4.1 |
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,23 @@ | ||
name: Linter | ||
run-name: ${{ github.actor }} is linting the code | ||
|
||
on: [push, pull_request] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Ceckout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Set up Python 3.11 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.11" | ||
- | ||
name: Install packages | ||
run: | | ||
python3 -m pip install -e .[tests] | ||
- | ||
name: Linting | ||
run: make lint |
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,45 @@ | ||
name: Tests | ||
run-name: ${{ github.actor }} is testing the code | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
|
||
jobs: | ||
tests: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 5 | ||
matrix: | ||
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Add conda to system path | ||
run: | | ||
# $CONDA is an environment variable pointing to the root of the miniconda directory | ||
echo $CONDA/bin >> $GITHUB_PATH | ||
|
||
- name: Creating conda environment for ${{ matrix.python-version }} | ||
run: | | ||
conda create -n test -y python=${{matrix.python-version}} pip make | ||
|
||
- name: Install dependencies | ||
run: | | ||
conda run -n test python3 -m pip install -e .[tests] | ||
|
||
- name: Test with pytest | ||
run: | | ||
conda run -n test make test_coverage | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 |
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,32 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# Coverage reports | ||
.coverage | ||
coverage.xml | ||
report.xml |
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,24 @@ | ||
# makefile used for testing | ||
# | ||
# | ||
all: install test | ||
|
||
.PHONY: docs | ||
install: | ||
python3 -m pip install -e .[tests] | ||
|
||
test: | ||
python3 -m pytest -vv $(PWD)/slkspec/tests | ||
|
||
test_coverage: | ||
python3 -m pytest -vv \ | ||
--cov=$(PWD)/slkspec --cov-report html:coverage_report \ | ||
--cov-report=xml --junitxml report.xml | ||
rm -rf '=' | ||
python3 -m coverage report | ||
|
||
|
||
lint: | ||
mypy --install-types --non-interactive | ||
black --check -t py310 . | ||
flake8 slkspec --count --max-complexity=10 --max-line-length=88 --statistics --doctests |
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 |
---|---|---|
|
@@ -7,38 +7,42 @@ Pull requests are welcomed! | |
```python | ||
import fsspec | ||
|
||
with fsspec.open("slk://arch/project/user/file", "r") as f: | ||
with fsspec.open("slk:///arch/project/user/file", "r") as f: | ||
print(f.read()) | ||
``` | ||
### Loading datasets | ||
|
||
```python | ||
|
||
import ffspec | ||
import xarray as xr | ||
|
||
url = fsspec.open("slk:////arch/project/file.nc", slk_cache="/scratch/b/b12346").open() | ||
dset = xr.open_dataset(url) | ||
``` | ||
|
||
|
||
## Usage in combination with preffs | ||
### Installation of additional requirements | ||
``` | ||
git clone [email protected]:observingClouds/slkspec.git | ||
cd slkspec | ||
```console | ||
mamba env create | ||
mamba activate slkspec | ||
pip install . | ||
``` | ||
|
||
### Loading dataset | ||
|
||
Set location for tape archive retrievals on local machine | ||
```bash | ||
export SLK_CACHE="/path/to/local/cache/directory/" | ||
``` | ||
Load the slk module | ||
```bash | ||
module load slk | ||
pip install .[preffs] | ||
``` | ||
|
||
Open parquet referenced zarr-file | ||
```python | ||
import xarray as xr | ||
ds=xr.open_zarr(f"preffs::/path/to/preffs/data.preffs", storage_options={"preffs":{"prefix":"slk:///arch/<project>/<user>/slk/archive/prefix/"} | ||
ds = xr.open_zarr(f"preffs::/path/to/preffs/data.preffs", | ||
storage_options={"preffs":{"prefix":"slk:///arch/<project>/<user>/slk/archive/prefix/"} | ||
``` | ||
Now only those files are retrieved from tape which are needed for any requested dataset operation. In the beginning only the file containing the metadata (e.g. .zattrs, .zmetadata) and coordinates are requested (e.g. time). After the files have been retrieved once, they are saved at the path given in `SLK_CACHE` and accessed directly from there. | ||
|
||
Now only those files are retrieved from tape which are needed for any requested | ||
dataset operation. In the beginning only the file containing the metadata | ||
(e.g. .zattrs, .zmetadata) and coordinates are requested (e.g. time). After the | ||
files have been retrieved once, they are saved at the path given in | ||
`SLK_CACHE` and accessed directly from there. | ||
|
||
|
||
## Current limitations (among others) | ||
- tape retrievals are currently not combined, leading to single/inefficient requests | ||
- tape retrievals are done within the currently selected compute resources, which might not be needed for a simple tape retrieval |
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,21 @@ | ||
[mypy] | ||
files = slkspec/core.py | ||
strict = False | ||
|
||
warn_unused_ignores = True | ||
warn_unreachable = True | ||
show_error_codes = True | ||
install_types = True | ||
non_interactive = True | ||
warn_unused_configs = True | ||
disallow_untyped_defs = True | ||
disallow_incomplete_defs = True | ||
check_untyped_defs = True | ||
disallow_untyped_decorators = True | ||
warn_redundant_casts = True | ||
|
||
[mypy-fsspec.*] | ||
ignore_missing_imports = True | ||
|
||
[mypy-pyslk.*] | ||
ignore_missing_imports = True |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
from fsspec import register_implementation | ||
|
||
from . import _version | ||
from .core import SLKFileSystem | ||
from .core import SLKFileSystem, logger | ||
|
||
__version__ = _version.get_versions()["version"] | ||
|
||
register_implementation(SLKFileSystem.protocol, SLKFileSystem) | ||
|
||
__all__ = ["__version__", "SLKFileSystem"] | ||
__all__ = ["__version__", "SLKFileSystem", "logger"] |
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.
still true, so far ( see one of my other comments)
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.
Actually, the
_retrieve_items
method gets only called once, at which point it has information on all items that need to be downloaded. So the retrievals are combined - somewhat. There are limitations though.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.
We could do a
pyslk.slk_recall(SEARCH_ID_ALL_FILES)
, first, and, then, the individual retrievals.