myst-libre 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. myst_libre-0.1.0/.github/workflows/publish.yml +32 -0
  2. myst_libre-0.1.0/.gitignore +162 -0
  3. myst_libre-0.1.0/LICENSE +21 -0
  4. myst_libre-0.1.0/PKG-INFO +207 -0
  5. myst_libre-0.1.0/README.md +165 -0
  6. myst_libre-0.1.0/example.py +20 -0
  7. myst_libre-0.1.0/myst_libre/__init__.py +3 -0
  8. myst_libre-0.1.0/myst_libre/abstract_class.py +47 -0
  9. myst_libre-0.1.0/myst_libre/builders/__init__.py +1 -0
  10. myst_libre-0.1.0/myst_libre/builders/myst_builder.py +21 -0
  11. myst_libre-0.1.0/myst_libre/rees/__init__.py +1 -0
  12. myst_libre-0.1.0/myst_libre/rees/rees.py +60 -0
  13. myst_libre-0.1.0/myst_libre/test/__init__.py +0 -0
  14. myst_libre-0.1.0/myst_libre/test/test_myst_libre.py +107 -0
  15. myst_libre-0.1.0/myst_libre/tools/__init__.py +8 -0
  16. myst_libre-0.1.0/myst_libre/tools/authenticator.py +24 -0
  17. myst_libre-0.1.0/myst_libre/tools/build_source_manager.py +114 -0
  18. myst_libre-0.1.0/myst_libre/tools/decorators.py +18 -0
  19. myst_libre-0.1.0/myst_libre/tools/docker_registry_client.py +89 -0
  20. myst_libre-0.1.0/myst_libre/tools/jupyter_hub_local_spawner.py +147 -0
  21. myst_libre-0.1.0/myst_libre/tools/myst_client.py +133 -0
  22. myst_libre-0.1.0/myst_libre/tools/rest_client.py +51 -0
  23. myst_libre-0.1.0/myst_libre.egg-info/PKG-INFO +207 -0
  24. myst_libre-0.1.0/myst_libre.egg-info/SOURCES.txt +28 -0
  25. myst_libre-0.1.0/myst_libre.egg-info/dependency_links.txt +1 -0
  26. myst_libre-0.1.0/myst_libre.egg-info/requires.txt +6 -0
  27. myst_libre-0.1.0/myst_libre.egg-info/top_level.txt +1 -0
  28. myst_libre-0.1.0/pyproject.toml +35 -0
  29. myst_libre-0.1.0/requirements.txt +7 -0
  30. myst_libre-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,32 @@
1
+ name: publish
2
+ on:
3
+ push:
4
+ tags:
5
+ - 'v*.*.*'
6
+
7
+ jobs:
8
+ pypi-publish:
9
+ name: upload release to PyPI
10
+ runs-on: ubuntu-latest
11
+ # Specifying a GitHub environment is optional, but strongly encouraged
12
+ environment: release
13
+ permissions:
14
+ # IMPORTANT: this permission is mandatory for trusted publishing
15
+ id-token: write
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: '3.10.4'
22
+ cache: pip
23
+ cache-dependency-path: '**/pyproject.toml'
24
+ - name: Install dependencies
25
+ run: |
26
+ pip install setuptools wheel build twine setuptools_scm
27
+ - name: Build
28
+ run: |
29
+ python -m build
30
+ # retrieve your distributions here
31
+ - name: Publish package distributions to PyPI
32
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,162 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ .DS_Store
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110
+ .pdm.toml
111
+ .pdm-python
112
+ .pdm-build/
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ #.idea/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Agah Karakuzu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,207 @@
1
+ Metadata-Version: 2.1
2
+ Name: myst_libre
3
+ Version: 0.1.0
4
+ Summary: A Python library for managing source code repositories, interacting with Docker registries, handling MyST markdown operations, and spawning JupyterHub instances locally.
5
+ Author-email: agahkarakuzu <agahkarakuzu@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 Agah Karakuzu
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/agahkarakuzu/myst_libre
29
+ Keywords: myst,docker,jupyterhub,markdown,repository
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Operating System :: OS Independent
33
+ Requires-Python: >=3.7
34
+ Description-Content-Type: text/markdown
35
+ License-File: LICENSE
36
+ Requires-Dist: requests
37
+ Requires-Dist: docker
38
+ Requires-Dist: python-dotenv
39
+ Requires-Dist: PyGithub
40
+ Requires-Dist: termcolor
41
+ Requires-Dist: mystmd
42
+
43
+
44
+ # MyST Libre
45
+
46
+ ![PyPI - Version](https://img.shields.io/pypi/v/myst-libre?style=flat&logo=python&logoColor=white&logoSize=8&labelColor=rgb(255%2C0%2C0)&color=white)
47
+
48
+ ## JupyterHub in Docker for MyST
49
+
50
+ A small library to manage reproducible execution environments using Docker and JupyterHub
51
+ to build MyST articles in containers.
52
+
53
+ ## Table of Contents
54
+
55
+ - [Myst Libre](#myst-libre)
56
+ - [Table of Contents](#table-of-contents)
57
+ - [Installation](#installation)
58
+ - [Usage](#usage)
59
+ - [Authentication](#authentication)
60
+ - [Docker Registry Client](#docker-registry-client)
61
+ - [Build Source Manager](#build-source-manager)
62
+ - [JupyterHub Local Spawner](#jupyterhub-local-spawner)
63
+ - [MyST Markdown Client](#myst-markdown-client)
64
+ - [Module and Class Descriptions](#module-and-class-descriptions)
65
+ - [Contributing](#contributing)
66
+ - [License](#license)
67
+
68
+ ## Installation
69
+
70
+ 1. **Clone the repository:**
71
+ ```sh
72
+ git clone https://github.com/yourusername/myst_libre.git
73
+ cd myst_libre
74
+ ```
75
+
76
+ 2. **Create a virtual environment:**
77
+ ```sh
78
+ python -m venv venv
79
+ source venv/bin/activate # On Windows use `venv\Scripts\activate`
80
+ ```
81
+
82
+ 3. **Install the required packages:**
83
+ ```sh
84
+ pip install -r requirements.txt
85
+ ```
86
+
87
+ 4. **Set up environment variables:**
88
+ Create a `.env` file in the project root and add the following:
89
+ ```env
90
+ DOCKER_PRIVATE_REGISTRY_USERNAME=your_username
91
+ DOCKER_PRIVATE_REGISTRY_PASSWORD=your_password
92
+ ```
93
+
94
+ ## External requirements
95
+
96
+ - Node.js (For MyST)
97
+ - Docker
98
+
99
+ ## Quick Start
100
+
101
+ ```python
102
+ from myst_libre.rees import REES
103
+ from myst_libre.tools import JupyterHubLocalSpawner
104
+
105
+ resources = REES(dict(registry_url="https://binder-registry.conp.cloud",
106
+ gh_user_repo_name = "agahkarakuzu/mriscope",
107
+ gh_repo_commit_hash = "6d3f64da214441bbb55b2005234fd4fd745fb372",
108
+ binder_image_tag = "489ae0eb0d08fe30e45bc31201524a6570b9b7dd"))
109
+
110
+ hub = JupyterHubLocalSpawner(resources,
111
+ host_data_parent_dir = "~/neurolibre/mriscope/data",
112
+ host_build_source_parent_dir = '~/Desktop/tmp',
113
+ container_data_mount_dir = '/home/jovyan/data',
114
+ container_build_source_mount_dir = '/home/jovyan')
115
+
116
+ hub.spawn_jupyter_hub()
117
+ ```
118
+ ## Usage
119
+
120
+ ### Authentication
121
+
122
+ The `Authenticator` class handles loading authentication credentials from environment variables.
123
+
124
+ ```python
125
+ from myst_libre.tools.authenticator import Authenticator
126
+
127
+ auth = Authenticator()
128
+ print(auth._auth)
129
+ ```
130
+
131
+
132
+ ### Docker Registry Client
133
+
134
+ The DockerRegistryClient class provides methods to interact with a Docker registry.
135
+
136
+ ```python
137
+ from myst_libre.tools.docker_registry_client import DockerRegistryClient
138
+
139
+ client = DockerRegistryClient(registry_url='https://my-registry.example.com', gh_user_repo_name='user/repo')
140
+ token = client.get_token()
141
+ print(token)
142
+ ```
143
+
144
+ ### Build Source Manager
145
+
146
+ The BuildSourceManager class manages source code repositories.
147
+
148
+ ```python
149
+ from myst_libre.tools.build_source_manager import BuildSourceManager
150
+
151
+ manager = BuildSourceManager(gh_user_repo_name='user/repo', gh_repo_commit_hash='commit_hash')
152
+ manager.git_clone_repo('/path/to/clone')
153
+ project_name = manager.get_project_name()
154
+ print(project_name)
155
+ ```
156
+
157
+ ## Module and Class Descriptions
158
+
159
+ ### AbstractClass
160
+ **Description**: Provides basic logging functionality and colored printing capabilities.
161
+
162
+ ### Authenticator
163
+ **Description**: Handles authentication by loading credentials from environment variables.
164
+ **Inherited from**: AbstractClass
165
+ **Inputs**: Environment variables `DOCKER_PRIVATE_REGISTRY_USERNAME` and `DOCKER_PRIVATE_REGISTRY_PASSWORD`
166
+
167
+ ### RestClient
168
+ **Description**: Provides a client for making REST API calls.
169
+ **Inherited from**: Authenticator
170
+
171
+ ### DockerRegistryClient
172
+ **Description**: Manages interactions with a Docker registry.
173
+ **Inherited from**: Authenticator
174
+ **Inputs**:
175
+ - `registry_url`: URL of the Docker registry
176
+ - `gh_user_repo_name`: GitHub user/repository name
177
+ - `auth`: Authentication credentials
178
+
179
+ ### BuildSourceManager
180
+ **Description**: Manages source code repositories.
181
+ **Inherited from**: AbstractClass
182
+ **Inputs**:
183
+ - `gh_user_repo_name`: GitHub user/repository name
184
+ - `gh_repo_commit_hash`: Commit hash of the repository
185
+
186
+ ### JupyterHubLocalSpawner
187
+ **Description**: Manages JupyterHub instances locally.
188
+ **Inherited from**: AbstractClass
189
+ **Inputs**:
190
+ - `rees`: Instance of the REES class
191
+ - `registry_url`: URL of the Docker registry
192
+ - `gh_user_repo_name`: GitHub user/repository name
193
+ - `auth`: Authentication credentials
194
+ - `binder_image_tag`: Docker image tag
195
+ - `build_src_commit_hash`: Commit hash of the repository
196
+ - `container_data_mount_dir`: Directory to mount data in the container
197
+ - `container_build_source_mount_dir`: Directory to mount build source in the container
198
+ - `host_data_parent_dir`: Host directory for data
199
+ - `host_build_source_parent_dir`: Host directory for build source
200
+
201
+ ### MystMD
202
+ **Description**: Manages MyST markdown operations such as building and converting files.
203
+ **Inherited from**: AbstractClass
204
+ **Inputs**:
205
+ - `build_dir`: Directory where the build will take place
206
+ - `env_vars`: Environment variables needed for the build process
207
+ - `executable`: Name of the MyST executable (default is 'myst')
@@ -0,0 +1,165 @@
1
+
2
+ # MyST Libre
3
+
4
+ ![PyPI - Version](https://img.shields.io/pypi/v/myst-libre?style=flat&logo=python&logoColor=white&logoSize=8&labelColor=rgb(255%2C0%2C0)&color=white)
5
+
6
+ ## JupyterHub in Docker for MyST
7
+
8
+ A small library to manage reproducible execution environments using Docker and JupyterHub
9
+ to build MyST articles in containers.
10
+
11
+ ## Table of Contents
12
+
13
+ - [Myst Libre](#myst-libre)
14
+ - [Table of Contents](#table-of-contents)
15
+ - [Installation](#installation)
16
+ - [Usage](#usage)
17
+ - [Authentication](#authentication)
18
+ - [Docker Registry Client](#docker-registry-client)
19
+ - [Build Source Manager](#build-source-manager)
20
+ - [JupyterHub Local Spawner](#jupyterhub-local-spawner)
21
+ - [MyST Markdown Client](#myst-markdown-client)
22
+ - [Module and Class Descriptions](#module-and-class-descriptions)
23
+ - [Contributing](#contributing)
24
+ - [License](#license)
25
+
26
+ ## Installation
27
+
28
+ 1. **Clone the repository:**
29
+ ```sh
30
+ git clone https://github.com/yourusername/myst_libre.git
31
+ cd myst_libre
32
+ ```
33
+
34
+ 2. **Create a virtual environment:**
35
+ ```sh
36
+ python -m venv venv
37
+ source venv/bin/activate # On Windows use `venv\Scripts\activate`
38
+ ```
39
+
40
+ 3. **Install the required packages:**
41
+ ```sh
42
+ pip install -r requirements.txt
43
+ ```
44
+
45
+ 4. **Set up environment variables:**
46
+ Create a `.env` file in the project root and add the following:
47
+ ```env
48
+ DOCKER_PRIVATE_REGISTRY_USERNAME=your_username
49
+ DOCKER_PRIVATE_REGISTRY_PASSWORD=your_password
50
+ ```
51
+
52
+ ## External requirements
53
+
54
+ - Node.js (For MyST)
55
+ - Docker
56
+
57
+ ## Quick Start
58
+
59
+ ```python
60
+ from myst_libre.rees import REES
61
+ from myst_libre.tools import JupyterHubLocalSpawner
62
+
63
+ resources = REES(dict(registry_url="https://binder-registry.conp.cloud",
64
+ gh_user_repo_name = "agahkarakuzu/mriscope",
65
+ gh_repo_commit_hash = "6d3f64da214441bbb55b2005234fd4fd745fb372",
66
+ binder_image_tag = "489ae0eb0d08fe30e45bc31201524a6570b9b7dd"))
67
+
68
+ hub = JupyterHubLocalSpawner(resources,
69
+ host_data_parent_dir = "~/neurolibre/mriscope/data",
70
+ host_build_source_parent_dir = '~/Desktop/tmp',
71
+ container_data_mount_dir = '/home/jovyan/data',
72
+ container_build_source_mount_dir = '/home/jovyan')
73
+
74
+ hub.spawn_jupyter_hub()
75
+ ```
76
+ ## Usage
77
+
78
+ ### Authentication
79
+
80
+ The `Authenticator` class handles loading authentication credentials from environment variables.
81
+
82
+ ```python
83
+ from myst_libre.tools.authenticator import Authenticator
84
+
85
+ auth = Authenticator()
86
+ print(auth._auth)
87
+ ```
88
+
89
+
90
+ ### Docker Registry Client
91
+
92
+ The DockerRegistryClient class provides methods to interact with a Docker registry.
93
+
94
+ ```python
95
+ from myst_libre.tools.docker_registry_client import DockerRegistryClient
96
+
97
+ client = DockerRegistryClient(registry_url='https://my-registry.example.com', gh_user_repo_name='user/repo')
98
+ token = client.get_token()
99
+ print(token)
100
+ ```
101
+
102
+ ### Build Source Manager
103
+
104
+ The BuildSourceManager class manages source code repositories.
105
+
106
+ ```python
107
+ from myst_libre.tools.build_source_manager import BuildSourceManager
108
+
109
+ manager = BuildSourceManager(gh_user_repo_name='user/repo', gh_repo_commit_hash='commit_hash')
110
+ manager.git_clone_repo('/path/to/clone')
111
+ project_name = manager.get_project_name()
112
+ print(project_name)
113
+ ```
114
+
115
+ ## Module and Class Descriptions
116
+
117
+ ### AbstractClass
118
+ **Description**: Provides basic logging functionality and colored printing capabilities.
119
+
120
+ ### Authenticator
121
+ **Description**: Handles authentication by loading credentials from environment variables.
122
+ **Inherited from**: AbstractClass
123
+ **Inputs**: Environment variables `DOCKER_PRIVATE_REGISTRY_USERNAME` and `DOCKER_PRIVATE_REGISTRY_PASSWORD`
124
+
125
+ ### RestClient
126
+ **Description**: Provides a client for making REST API calls.
127
+ **Inherited from**: Authenticator
128
+
129
+ ### DockerRegistryClient
130
+ **Description**: Manages interactions with a Docker registry.
131
+ **Inherited from**: Authenticator
132
+ **Inputs**:
133
+ - `registry_url`: URL of the Docker registry
134
+ - `gh_user_repo_name`: GitHub user/repository name
135
+ - `auth`: Authentication credentials
136
+
137
+ ### BuildSourceManager
138
+ **Description**: Manages source code repositories.
139
+ **Inherited from**: AbstractClass
140
+ **Inputs**:
141
+ - `gh_user_repo_name`: GitHub user/repository name
142
+ - `gh_repo_commit_hash`: Commit hash of the repository
143
+
144
+ ### JupyterHubLocalSpawner
145
+ **Description**: Manages JupyterHub instances locally.
146
+ **Inherited from**: AbstractClass
147
+ **Inputs**:
148
+ - `rees`: Instance of the REES class
149
+ - `registry_url`: URL of the Docker registry
150
+ - `gh_user_repo_name`: GitHub user/repository name
151
+ - `auth`: Authentication credentials
152
+ - `binder_image_tag`: Docker image tag
153
+ - `build_src_commit_hash`: Commit hash of the repository
154
+ - `container_data_mount_dir`: Directory to mount data in the container
155
+ - `container_build_source_mount_dir`: Directory to mount build source in the container
156
+ - `host_data_parent_dir`: Host directory for data
157
+ - `host_build_source_parent_dir`: Host directory for build source
158
+
159
+ ### MystMD
160
+ **Description**: Manages MyST markdown operations such as building and converting files.
161
+ **Inherited from**: AbstractClass
162
+ **Inputs**:
163
+ - `build_dir`: Directory where the build will take place
164
+ - `env_vars`: Environment variables needed for the build process
165
+ - `executable`: Name of the MyST executable (default is 'myst')
@@ -0,0 +1,20 @@
1
+ from myst_libre.tools import JupyterHubLocalSpawner, MystMD
2
+ from myst_libre.rees import REES
3
+ from myst_libre.builders import MystBuilder
4
+
5
+ resources = REES(dict(
6
+ registry_url="https://binder-registry.conp.cloud",
7
+ gh_user_repo_name = "agahkarakuzu/mriscope",
8
+ gh_repo_commit_hash = "ae64d9ed17e6ce66ecf94d585d7b68a19a435d70",
9
+ binder_image_tag = "489ae0eb0d08fe30e45bc31201524a6570b9b7dd"))
10
+
11
+
12
+ hub = JupyterHubLocalSpawner(resources,
13
+ host_data_parent_dir = "/Users/agah/Desktop/neurolibre/mriscope/data",
14
+ host_build_source_parent_dir = '/Users/agah/Desktop/tmp',
15
+ container_data_mount_dir = '/home/jovyan/data',
16
+ container_build_source_mount_dir = '/home/jovyan')
17
+
18
+ hub.spawn_jupyter_hub()
19
+
20
+ MystBuilder(hub).build()
@@ -0,0 +1,3 @@
1
+ from setuptools_scm import get_version
2
+
3
+ __version__ = get_version()
@@ -0,0 +1,47 @@
1
+ """
2
+ abstract_class.py
3
+
4
+ This module contains the AbstractClass which provides basic logging functionality
5
+ and colored printing capabilities.
6
+ """
7
+
8
+ import logging
9
+ from termcolor import colored
10
+
11
+ class AbstractClass:
12
+ """
13
+ AbstractClass
14
+
15
+ A base class that provides logging functionality and methods for printing colored messages.
16
+ """
17
+ def __init__(self):
18
+ """
19
+ Initialize the AbstractClass with default logging settings.
20
+ """
21
+ self.logging_level = logging.INFO
22
+ self.logger = logging.getLogger(self.__class__.__name__)
23
+ self.logger.setLevel(self.logging_level)
24
+ handler = logging.StreamHandler()
25
+ handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
26
+ if not self.logger.handlers: # Avoid adding multiple handlers if already set
27
+ self.logger.addHandler(handler)
28
+
29
+ def set_log_level(self, level):
30
+ """
31
+ Set the logging level.
32
+
33
+ Args:
34
+ level (str): Logging level.
35
+ """
36
+ self.logging_level = level
37
+ self.logger = logging.basicConfig(level=self.logging_level, format='%(asctime)s - %(levelname)s - %(message)s')
38
+
39
+ def cprint(self, message, color):
40
+ """
41
+ Print a message in a specified color using termcolor.
42
+
43
+ Args:
44
+ message (str): The message to print.
45
+ color (str): The color to use for printing the message.
46
+ """
47
+ print(colored(message, color))
@@ -0,0 +1 @@
1
+ from .myst_builder import MystBuilder
@@ -0,0 +1,21 @@
1
+ from myst_libre.tools import JupyterHubLocalSpawner, MystMD
2
+ from myst_libre.abstract_class import AbstractClass
3
+
4
+ class MystBuilder(AbstractClass):
5
+ def __init__(self, hub):
6
+ if not isinstance(hub, JupyterHubLocalSpawner):
7
+ raise TypeError(f"Expected 'hub' to be an instance of JupyterHubLocalSpawner, got {type(hub).__name__} instead")
8
+ super().__init__()
9
+ #aa = MystMD('/Users/agah/Desktop', {"anan":5})
10
+ self.env_vars = {}
11
+ self.build_dir = ""
12
+ self.hub = hub
13
+ self.env_vars = {"JUPYTER_BASE_URL":f"{self.hub.jh_url}",
14
+ "JUPYTER_TOKEN":f"{self.hub.jh_token}",
15
+ "port":f"{self.hub.port}"
16
+ }
17
+ self.myst_client = MystMD(hub.rees.build_dir, self.env_vars)
18
+
19
+ def build(self):
20
+ self.cprint(f'Starting MyST build {self.hub.jh_url}','yellow')
21
+ self.myst_client.build()
@@ -0,0 +1 @@
1
+ from .rees import REES