Skip to content
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] download entities from zenodo and removing tvb_data dependacies #682

Closed
wants to merge 93 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
b21d358
Using pyzenodo3 as a client to connect with Zenodo.
abhi-glitchhg May 10, 2023
1f9ba1e
remove the swp file from git, add .swp extension in gitignore
abhi-glitchhg May 12, 2023
d3a869b
remove the search related methods from zenodo class, currently we wil…
abhi-glitchhg Jun 6, 2023
67331b8
add method `get_latest_version` to fetch the latest version of the Re…
abhi-glitchhg Jun 7, 2023
783aaea
add pooch as a dependancy
abhi-glitchhg Jun 11, 2023
198f0ef
add tvb class and tests
abhi-glitchhg Jun 12, 2023
80f3e3f
minor nits and fixes
abhi-glitchhg Jun 12, 2023
c906f19
added todo in fetch_data method
abhi-glitchhg Jun 16, 2023
faaec3b
Update tvb_library/tvb/datasets/tvb_data.py
abhi-glitchhg Jun 16, 2023
a3e060a
fixed the absolute path error
abhi-glitchhg Jun 16, 2023
ae10817
added header
abhi-glitchhg Jun 17, 2023
c57ed91
added header
abhi-glitchhg Jun 17, 2023
2d7ebdc
added DATASETS_FOLDER attribute to config settings.
abhi-glitchhg Jun 17, 2023
cd536af
some improvements in tests, now from_cls method of connectivity loads…
abhi-glitchhg Jun 17, 2023
cb7c838
Merge branch 'pyzenodo' of https://github.com/abhi-glitchhg/tvb-root …
abhi-glitchhg Jun 17, 2023
96e87cb
fix typos
abhi-glitchhg Jun 17, 2023
1af4cb7
extract dir parameter when instantiating the class.
abhi-glitchhg Jun 20, 2023
2d2188c
change download_dir to .cache/tvb from .cache/pooch
abhi-glitchhg Jun 23, 2023
d9a14f3
.
abhi-glitchhg Jun 29, 2023
ace365f
Merge pull request #675 from abhi-glitchhg/pyzenodo
abhi-glitchhg Jun 29, 2023
51a2f9c
fixed the file not found errors with remaining datatypes'
abhi-glitchhg Jun 30, 2023
d651659
add types
abhi-glitchhg Jun 30, 2023
597d249
Merge pull request #676 from abhi-glitchhg/pyzenodo
abhi-glitchhg Jun 30, 2023
a04b6d9
removed the data setup from build.yml, fix the errors found in tests
abhi-glitchhg Jul 6, 2023
324548f
Merge pull request #677 from abhi-glitchhg/pyzenodo
abhi-glitchhg Jul 6, 2023
7eadc0b
replacing tvb_data package from code.
abhi-glitchhg Jul 8, 2023
3776c0e
Merge branch 'TVB-1999-deo' into pyzenodo
abhi-glitchhg Jul 8, 2023
bf2148e
fix tvb_data not found error and one identation error
abhi-glitchhg Jul 8, 2023
792218b
Merge branch 'pyzenodo' of https://github.com/abhi-glitchhg/tvb-root …
abhi-glitchhg Jul 8, 2023
38b8fab
fix the identation
abhi-glitchhg Jul 8, 2023
4c9a0bb
fix the data loading issues that i missed earlier.
abhi-glitchhg Jul 8, 2023
82046c3
some more fixes..
abhi-glitchhg Jul 8, 2023
33bab6a
fix typo
abhi-glitchhg Jul 11, 2023
19e1d8d
removed the commented lines, removed the tvb_data
abhi-glitchhg Jul 12, 2023
808f991
fix test; reuse tvbzenododataset instance
abhi-glitchhg Jul 12, 2023
6888ca1
fix the notebooks
abhi-glitchhg Jul 16, 2023
08532fc
fixed the notebooks
abhi-glitchhg Jul 16, 2023
b71ea47
trigger for prs as well
abhi-glitchhg Jul 16, 2023
8e38ba5
fix build_step1.py, added ability to unzip whole data.
abhi-glitchhg Jul 22, 2023
4fc4693
revert back to original notebooks metadata
abhi-glitchhg Jul 22, 2023
2ca6c02
add missing `:` to the github workflow files.
abhi-glitchhg Jul 22, 2023
d2aa85a
fixed the silly indentation mistakes in the github actions files.
abhi-glitchhg Jul 22, 2023
58ae3d0
fix the directory path in the tests
abhi-glitchhg Jul 23, 2023
f420d75
Using pyzenodo3 as a client to connect with Zenodo.
abhi-glitchhg May 10, 2023
e7c0eb1
remove the swp file from git, add .swp extension in gitignore
abhi-glitchhg May 12, 2023
594be2a
remove the search related methods from zenodo class, currently we wil…
abhi-glitchhg Jun 6, 2023
906bf03
add method `get_latest_version` to fetch the latest version of the Re…
abhi-glitchhg Jun 7, 2023
34440b7
add pooch as a dependancy
abhi-glitchhg Jun 11, 2023
7a2fcee
add tvb class and tests
abhi-glitchhg Jun 12, 2023
cbeb92b
minor nits and fixes
abhi-glitchhg Jun 12, 2023
b675f92
added todo in fetch_data method
abhi-glitchhg Jun 16, 2023
7c82487
fixed the absolute path error
abhi-glitchhg Jun 16, 2023
7e78f97
added header
abhi-glitchhg Jun 17, 2023
027587f
added header
abhi-glitchhg Jun 17, 2023
16eef16
added DATASETS_FOLDER attribute to config settings.
abhi-glitchhg Jun 17, 2023
696b599
some improvements in tests, now from_cls method of connectivity loads…
abhi-glitchhg Jun 17, 2023
7cbc3f6
Update tvb_library/tvb/datasets/tvb_data.py
abhi-glitchhg Jun 16, 2023
c454341
fix typos
abhi-glitchhg Jun 17, 2023
ce408d4
extract dir parameter when instantiating the class.
abhi-glitchhg Jun 20, 2023
3bdf9db
change download_dir to .cache/tvb from .cache/pooch
abhi-glitchhg Jun 23, 2023
64c2d08
.
abhi-glitchhg Jun 29, 2023
15550d2
fixed the file not found errors with remaining datatypes'
abhi-glitchhg Jun 30, 2023
d6c2c76
add types
abhi-glitchhg Jun 30, 2023
b3d3d63
removed the data setup from build.yml, fix the errors found in tests
abhi-glitchhg Jul 6, 2023
b51a7a1
replacing tvb_data package from code.
abhi-glitchhg Jul 8, 2023
c3f5947
fix tvb_data not found error and one identation error
abhi-glitchhg Jul 8, 2023
f45c69b
fix the identation
abhi-glitchhg Jul 8, 2023
24a21a6
fix the data loading issues that i missed earlier.
abhi-glitchhg Jul 8, 2023
2105be4
some more fixes..
abhi-glitchhg Jul 8, 2023
c4869fc
fix typo
abhi-glitchhg Jul 11, 2023
230f88f
removed the commented lines, removed the tvb_data
abhi-glitchhg Jul 12, 2023
c410999
fix test; reuse tvbzenododataset instance
abhi-glitchhg Jul 12, 2023
50e8125
fix the notebooks
abhi-glitchhg Jul 16, 2023
f19b1ad
fixed the notebooks
abhi-glitchhg Jul 16, 2023
cc5062b
trigger for prs as well
abhi-glitchhg Jul 16, 2023
be5b365
fix build_step1.py, added ability to unzip whole data.
abhi-glitchhg Jul 22, 2023
ba100cc
revert back to original notebooks metadata
abhi-glitchhg Jul 22, 2023
f639109
add missing `:` to the github workflow files.
abhi-glitchhg Jul 22, 2023
7c328f9
fixed the silly indentation mistakes in the github actions files.
abhi-glitchhg Jul 22, 2023
a8b5f70
fix the directory path in the tests
abhi-glitchhg Jul 23, 2023
c63a507
add line which was removed accidentally while resolving the conflict
abhi-glitchhg Jul 28, 2023
c73ac6b
resolve the conflicts
abhi-glitchhg Jul 28, 2023
f6e2e99
typo fix
abhi-glitchhg Jul 28, 2023
02a31b4
api change and fix typo
abhi-glitchhg Jul 31, 2023
ffbe985
getting missing whitespace around operator error
abhi-glitchhg Aug 6, 2023
0918d35
revert the change
abhi-glitchhg Aug 6, 2023
842e764
fix the pycodestyle issue
abhi-glitchhg Aug 6, 2023
033ec3c
Merge branch 'master' into pyzenodo
abhi-glitchhg Aug 6, 2023
294a4d8
minor changes
abhi-glitchhg Aug 21, 2023
f7f7765
Merge branch 'pyzenodo' of https://github.com/abhi-glitchhg/tvb-root …
abhi-glitchhg Aug 21, 2023
6bef087
fix test fix
abhi-glitchhg Aug 22, 2023
59bf03f
Merge branch 'the-virtual-brain:master' into pyzenodo
abhi-glitchhg Aug 23, 2023
b54440f
Merge branch 'the-virtual-brain:master' into pyzenodo
abhi-glitchhg Aug 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Test Py
on: [push]
on:
pull_request:
push:

jobs:
build:
Expand Down Expand Up @@ -47,25 +49,7 @@ jobs:
cd tvb_build
bash install_full_tvb.sh

- name: cache data
id: cache-data
uses: actions/cache@v3
with:
path: tvb_data
key: tvb-data

- name: download data
if: steps.cache-data.outputs.cache-hit != 'true'
run: |
wget -q https://zenodo.org/record/7574266/files/tvb_data.zip?download=1 -O tvb_data.zip
mkdir tvb_data
unzip tvb_data.zip -d tvb_data
rm tvb_data.zip

- name: setup data
run: |
cd tvb_data
python3 setup.py develop

- name: run library tests
run: pytest -v tvb_library --cov --cov-report=xml && mv coverage.xml coverage-library.xml
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/lib-tests.yml_disabled
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Test lib
on: [push]
on:
pull_request:
push:
jobs:
lib-tests:

Expand Down Expand Up @@ -27,16 +29,7 @@ jobs:
pip3 install pipenv
cd tvb_library && pipenv install -d --python $(which python3)

- name: download data
run: |
wget -q https://zenodo.org/record/7574266/files/tvb_data.zip?download=1 -O tvb_data.zip
mkdir tvb_data
unzip tvb_data.zip -d tvb_data
rm tvb_data.zip

- name: setup data
run: |
cd tvb_library && pipenv run bash -c 'cd ../tvb_data && python3 setup.py develop'

- name: importlib_metadata?
run: cd tvb_library && pipenv install importlib_metadata
Expand Down
19 changes: 3 additions & 16 deletions .github/workflows/notebooks.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Test Notebooks
on: [push]
on:
pull_request:
push:

jobs:
build:
Expand Down Expand Up @@ -40,22 +42,7 @@ jobs:
cd tvb_build
cmd /k "install_full_tvb.bat"

- name: cache data
id: cache-data
uses: actions/cache@v3
with:
path: tvb_data
key: tvbdata

- name: download data
if: steps.cache-data.outputs.cache-hit != 'true'
shell: pwsh
run: |
Invoke-WebRequest -OutFile C:\\TEMP\\tvb_data.zip -Uri "https://zenodo.org/record/7574266/files/tvb_data.zip?download=1"
Expand-Archive 'C:\\TEMP\\tvb_data.zip' C:\\tvb_data
del C:\\TEMP\\tvb_data.zip
cd C:\\tvb_data
python setup.py develop

- name: run notebooks
env:
Expand Down
20 changes: 3 additions & 17 deletions .github/workflows/pg-tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Test PG
on: [push]
on:
pull_request:
push:

jobs:
build:
Expand Down Expand Up @@ -52,23 +54,7 @@ jobs:
- name: setup tvb
run: cd tvb_build && bash install_full_tvb.sh

- name: cache data
id: cache-data
uses: actions/cache@v3
with:
path: tvb_data
key: tvb-data

- name: download data
if: steps.cache-data.outputs.cache-hit != 'true'
run: |
wget -q https://zenodo.org/record/7574266/files/tvb_data.zip?download=1 -O tvb_data.zip
mkdir tvb_data
unzip tvb_data.zip -d tvb_data
rm tvb_data.zip

- name: setup data
run: cd tvb_data && python3 setup.py develop

- name: run framework tests
run: |
Expand Down
19 changes: 3 additions & 16 deletions .github/workflows/win-tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Test Win
on: [push]
on:
pull_request:
push:

jobs:
build:
Expand Down Expand Up @@ -34,22 +36,7 @@ jobs:
pip install -r tvb_framework/requirements.txt
pip install --no-build-isolation tvb-gdist

- name: cache data
id: cache-data
uses: actions/cache@v3
with:
path: tvb_data
key: tvbdata

- name: download data
if: steps.cache-data.outputs.cache-hit != 'true'
shell: pwsh
run: |
Invoke-WebRequest -OutFile C:\\TEMP\\tvb_data.zip -Uri "https://zenodo.org/record/7574266/files/tvb_data.zip?download=1"
Expand-Archive 'C:\\TEMP\\tvb_data.zip' C:\\tvb_data
del C:\\TEMP\\tvb_data.zip
cd C:\\tvb_data
pip install -e .

- name: run framework tests
shell: pwsh
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
*.py[cod]
__pycache__

#vim binaries
*.swp

# packaging
*.egg-info/
dist/
Expand Down
83 changes: 2 additions & 81 deletions tvb_build/build_step1.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import requests

import tvb_bin
import tvb_data
from subprocess import Popen, PIPE

# source paths
Expand All @@ -53,90 +52,13 @@
FW_FOLDER = os.path.join(TVB_ROOT, 'tvb_framework')
LICENSE_PATH = os.path.join(FW_FOLDER, 'LICENSE')
RELEASE_NOTES_PATH = os.path.join(TVB_ROOT, 'tvb_documentation', 'RELEASE_NOTES')
DATA_SRC_FOLDER = os.path.dirname(tvb_data.__file__)


DEMOS_MATLAB_FOLDER = os.path.join(TVB_ROOT, 'tvb_documentation', 'matlab')

# dest paths
DIST_FOLDER = os.path.join(os.path.dirname(__file__), 'build', 'TVB_Distribution')

DATA_INSIDE_FOLDER = os.path.join(DIST_FOLDER, '_tvb_data')

INCLUDED_INSIDE_DATA = [
"__init__.py",
"Default_Project.zip",

"connectivity/connectivity_76.zip",
"connectivity/paupau.zip",
"connectivity/connectivity_66.zip",
"connectivity/connectivity_192.zip",
"connectivity/__init__.py",

"projectionMatrix/projection_eeg_62_surface_16k.mat",
"projectionMatrix/projection_eeg_65_surface_16k.npy",
"projectionMatrix/projection_meg_276_surface_16k.npy",
"projectionMatrix/projection_seeg_588_surface_16k.npy",
"projectionMatrix/__init__.py",

"regionMapping/__init__.py",
"regionMapping/regionMapping_16k_76.txt",
"regionMapping/regionMapping_80k_80.txt",
"regionMapping/regionMapping_16k_192.txt",

"sensors/eeg_unitvector_62.txt.bz2",
"sensors/eeg_brainstorm_65.txt",
"sensors/meg_151.txt.bz2",
"sensors/meg_brainstorm_276.txt",
"sensors/seeg_39.txt.bz2",
"sensors/seeg_brainstorm_960.txt",
"sensors/seeg_588.txt",
"sensors/__init__.py",

"surfaceData/__init__.py",
"surfaceData/cortex_80k.zip",
"surfaceData/cortex_16384.zip",
"surfaceData/outer_skin_4096.zip",
"surfaceData/inner_skull_4096.zip",
"surfaceData/outer_skull_4096.zip",
"surfaceData/scalp_1082.zip",
"surfaceData/face_8614.zip",

"local_connectivity/__init__.py",
"local_connectivity/local_connectivity_16384.mat",
"local_connectivity/local_connectivity_80k.mat",

"obj/__init__.py",
"obj/face_surface.obj",
"obj/eeg_cap.obj",

"mouse/allen_2mm/Connectivity.h5",
"mouse/allen_2mm/Volume.h5",
"mouse/allen_2mm/StructuralMRI.h5",
"mouse/allen_2mm/RegionVolumeMapping.h5",
]


def _copy_dataset(dataset_files, dataset_destination):
for pth in dataset_files:
rel_pth = pth.split('/')
origin = os.path.join(DATA_SRC_FOLDER, *rel_pth)
destination = os.path.join(dataset_destination, *rel_pth)
destination_folder = os.path.dirname(destination)
if not os.path.exists(destination_folder):
os.makedirs(destination_folder)
print("Copying %s into %s" % (origin, destination))
shutil.copyfile(origin, destination)


def copy_distribution_dataset():
"""
Copy the required data file from tvb_data folder:
- inside TVB library package (for internal usage).
Will be used during TVB functioning: import default project,
load default for console profile, or code update events
- in tvb_data folder, as example for users.
"""
_copy_dataset(INCLUDED_INSIDE_DATA, DATA_INSIDE_FOLDER)


def _copy_demos_collapsed(to_copy):
"""
Expand Down Expand Up @@ -230,7 +152,6 @@ def build_step1():
shutil.copytree(DEMOS_MATLAB_FOLDER, os.path.join(DIST_FOLDER, 'matlab'),
ignore=shutil.ignore_patterns('.svn', '*.rst'))

copy_distribution_dataset()

_copy_demos_collapsed({os.path.join("..", "tvb_documentation", "demos"): os.path.join(DIST_FOLDER, "demo_scripts"),
os.path.join("..", "tvb_documentation", "tutorials"):
Expand Down
6 changes: 1 addition & 5 deletions tvb_build/docker/Dockerfile-build
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ RUN /bin/bash -c "source activate tvb-run"; \
/opt/conda/envs/tvb-run/bin/jupyter notebook --generate-config; \
echo "c.NotebookApp.password='sha1:12bff019c253:9daecd92c2e9bdb10b3b8a06767a74a0fe078d7c'">>$JUPYTER_CONFIG/jupyter_notebook_config.py

RUN wget https://zenodo.org/record/7574266/files/tvb_data.zip?download=1 -O tvb_data.zip; \
mkdir tvb_data; unzip tvb_data.zip -d tvb_data; rm tvb_data.zip; \
cd tvb_data; \
/opt/conda/envs/tvb-run/bin/python setup.py develop;\
/opt/conda/envs/tvb-docs/bin/python setup.py develop


WORKDIR $USER_HOME
COPY requirements_group requirements.txt
Expand Down
5 changes: 1 addition & 4 deletions tvb_build/docker/Dockerfile-run
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ RUN /bin/bash -c "source activate tvb-run"; \
$ENV_BIN/jupyter notebook --generate-config; \
echo "c.NotebookApp.password='sha1:12bff019c253:9daecd92c2e9bdb10b3b8a06767a74a0fe078d7c'">>$JUPYTER_CONFIG/jupyter_notebook_config.py

RUN wget https://zenodo.org/record/7574266/files/tvb_data.zip?download=1 -O tvb_data.zip; \
mkdir tvb_data; unzip tvb_data.zip -d tvb_data; rm tvb_data.zip; \
cd tvb_data; \
$ENV_BIN/python setup.py develop


WORKDIR $USER_HOME
COPY requirements_group requirements.txt
Expand Down
6 changes: 0 additions & 6 deletions tvb_build/docker/Dockerfile-win
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ RUN activate tvb-run && pip install lockfile scikit-build
RUN activate tvb-run && pip install syncrypto


# Download and install tvb data
RUN mkdir C:\\TVB_CODE
WORKDIR /TVB_CODE
ADD https://zenodo.org/record/7574266/files/tvb_data.zip?download=1 tvb_data.zip
RUN tar -xf tvb_data.zip && dir && del tvb_data.zip
RUN activate tvb-run && python setup.py develop

COPY requirements_group requirements.txt
RUN activate tvb-run && pip install -r requirements.txt
Expand Down
3 changes: 2 additions & 1 deletion tvb_contrib/tvb/contrib/scripts/datatypes/lookup_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"""

import numpy
from tvb.datasets import TVBZenodoDataset
from tvb.basic.readers import try_get_absolute_path
from tvb.basic.neotraits.api import HasTraits, Attr, NArray, Int, Float

Expand Down Expand Up @@ -74,7 +75,7 @@ class LookUpTable(HasTraits):

@staticmethod
def populate_table(result, source_file):
source_full_path = try_get_absolute_path("tvb_data.tables", source_file)
source_full_path = TVBZenodoDataset().fetch_data(source_file)
zip_data = numpy.load(source_full_path)

result.df = zip_data['df']
Expand Down
10 changes: 6 additions & 4 deletions tvb_documentation/demos/encrypt_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@
"outputs": [],
"source": [
"# EDIT paths to data files here inside the list\n",
"import tvb_data, os, tvb\n",
"from tvb.basic.readers import try_get_absolute_path\n",
"import os, tvb\n",
"from tvb.datasets import TVBZenodoDataset\n",
"dataset = TVBZenodoDataset()\n",
"\n",
"paths_to_files = [try_get_absolute_path(\"tvb_data.connectivity\", \"connectivity_76.zip\")]\n",
"\n",
"paths_to_files = [dataset.fetch_data(\"connectivity_76.zip\")]\n",
"import_export_encryption_handler = StorageInterface.get_import_export_encryption_handler()\n",
"\n",
"buffer_size = TvbProfile.current.hpc.CRYPT_BUFFER_SIZE\n",
Expand Down Expand Up @@ -151,7 +153,7 @@
"encrypted_password = import_export_encryption_handler.encrypt_password(public_key, password_bytes)\n",
"\n",
"# EDIT path for saving the encrypted password\n",
"encrypted_password_path = os.path.join(tvb_data.__path__[0], 'connectivity')\n",
"encrypted_password_path = os.path.join(dataset.extract_dir, 'tvb_data','connectivity')\n",
"\n",
"import_export_encryption_handler.save_encrypted_password(encrypted_password, encrypted_password_path)\n",
"\n",
Expand Down
Loading