Skip to content

Commit

Permalink
add sample id to install
Browse files Browse the repository at this point in the history
  • Loading branch information
AntSimi committed Nov 20, 2024
1 parent 24a4094 commit 2dc4043
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions doc/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies:
- pip
- pip:
- -r ../requirements.txt
- git+https://github.com/AntSimi/py-eddy-tracker-sample-id.git
- sphinx-gallery
- sphinx_rtd_theme
- sphinx>=3.1
Expand Down
20 changes: 14 additions & 6 deletions src/py_eddy_tracker/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
20160515 adt None None longitude latitude . \
--cut 800 --fil 1
"""

import io
import lzma
from os import path
Expand All @@ -26,14 +27,21 @@ def get_remote_demo_sample(path):
if path.endswith(".nc"):
return io.BytesIO(content)
else:
if path.endswith(".nc"):
try:
import py_eddy_tracker_sample_id
py_eddy_tracker_sample_id.get_remote_demo_sample()
if path.endswith(".nc"):
return py_eddy_tracker_sample_id.get_remote_demo_sample(path)
content = open(py_eddy_tracker_sample_id.get_remote_demo_sample(f"{path}.tar.xz"), "rb").read()
except:
if path.endswith(".nc"):
content = requests.get(
f"https://github.com/AntSimi/py-eddy-tracker-sample-id/raw/master/{path}"
).content
return io.BytesIO(content)
content = requests.get(
f"https://github.com/AntSimi/py-eddy-tracker-sample-id/raw/master/{path}"
f"https://github.com/AntSimi/py-eddy-tracker-sample-id/raw/master/{path}.tar.xz"
).content
return io.BytesIO(content)
content = requests.get(
f"https://github.com/AntSimi/py-eddy-tracker-sample-id/raw/master/{path}.tar.xz"
).content

# Tar module could manage lzma tar, but it will apply uncompress for each extractfile
tar = tarfile.open(mode="r", fileobj=io.BytesIO(lzma.decompress(content)))
Expand Down

0 comments on commit 2dc4043

Please sign in to comment.