Skip to content

Commit 910edb2

Browse files
committed
Proper repo2data handling
1 parent ed00412 commit 910edb2

File tree

7 files changed

+23
-8
lines changed

7 files changed

+23
-8
lines changed

example.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
from myst_libre.rees import REES
33
from myst_libre.builders import MystBuilder
44

5+
6+
57
resources = REES(dict(
68
registry_url="https://binder-registry.conp.cloud",
79
gh_user_repo_name = "agahkarakuzu/mriscope",
810
gh_repo_commit_hash = "ae64d9ed17e6ce66ecf94d585d7b68a19a435d70",
9-
binder_image_tag = "489ae0eb0d08fe30e45bc31201524a6570b9b7dd",
10-
dotenv = "/where/dotenv/is/located"))
11+
binder_image_tag = "489ae0eb0d08fe30e45bc31201524a6570b9b7dd"))
1112

1213

1314
hub = JupyterHubLocalSpawner(resources,
14-
host_data_parent_dir = "/Users/agah/Desktop/neurolibre/mriscope/data",
15+
host_data_parent_dir = "/Users/agah/Desktop/tmp/DATA",
1516
host_build_source_parent_dir = '/Users/agah/Desktop/tmp',
1617
container_data_mount_dir = '/home/jovyan/data',
1718
container_build_source_mount_dir = '/home/jovyan')

myst_libre/builders/myst_builder.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ def __init__(self, hub):
66
if not isinstance(hub, JupyterHubLocalSpawner):
77
raise TypeError(f"Expected 'hub' to be an instance of JupyterHubLocalSpawner, got {type(hub).__name__} instead")
88
super().__init__()
9-
#aa = MystMD('/Users/agah/Desktop', {"anan":5})
109
self.env_vars = {}
1110
self.build_dir = ""
1211
self.hub = hub

myst_libre/rees/rees.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def __init__(self, rees_dict):
2626
self.use_public_registry = False
2727
self.repo_commit_info = {}
2828
self.binder_commit_info = {}
29+
# CHECK: This may not work properly without
30+
# logging in to the registry on the host machine
31+
# which keeps that auth info on the config file.
2932
self.docker_client = docker.from_env()
3033

3134
def check_docker_installed(self):

myst_libre/tools/build_source_manager.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from git import Repo
1111
from datetime import datetime
1212
from myst_libre.abstract_class import AbstractClass
13+
from repo2data.repo2data import Repo2Data
1314

1415
class BuildSourceManager(AbstractClass):
1516
"""
@@ -84,6 +85,16 @@ def get_project_name(self):
8485
data = json.load(file)
8586
self.dataset_name = data['projectName']
8687

88+
def repo2data_download(self,target_directory):
89+
data_req_path = os.path.join(self.build_dir, 'binder', 'data_requirement.json')
90+
if not os.path.isfile(data_req_path):
91+
self.logger.info(f'Skipping repo2data download')
92+
else:
93+
self.logger.info(f'Starting repo2data download')
94+
repo2data = Repo2Data(data_req_path, server=True)
95+
repo2data.set_server_dst_folder(target_directory)
96+
repo2data.install()
97+
8798
def set_commit_info(self):
8899
self.binder_commit_info['datetime'] = self.repo_object.commit(self.binder_image_tag).committed_datetime
89100
self.binder_commit_info['message'] = self.repo_object.commit(self.binder_image_tag).message

myst_libre/tools/jupyter_hub_local_spawner.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ def spawn_jupyter_hub(self):
9090
self.rees.get_project_name()
9191

9292
if self.rees.dataset_name:
93-
print(self.container_data_mount_dir)
94-
print(self.rees.dataset_name)
93+
self.rees.repo2data_download(self.host_data_parent_dir)
9594
mnt_vol = {f'{os.path.join(self.host_data_parent_dir,self.rees.dataset_name)}': {'bind': os.path.join(self.container_data_mount_dir,self.rees.dataset_name), 'mode': 'ro'},
9695
self.rees.build_dir: {'bind': f'{self.container_build_source_mount_dir}', 'mode': 'rw'}}
9796
else:

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ dependencies = [
2424
"python-dotenv",
2525
"PyGithub",
2626
"termcolor",
27-
"mystmd"
27+
"mystmd",
28+
"repo2data"
2829
]
2930

3031
[project.urls]

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ docker
55
hashlib
66
termcolor
77
mystmd
8-
requests
8+
requests
9+
repo2data==2.9.2

0 commit comments

Comments
 (0)