A Python library for managing source code repositories, interacting with Docker registries, handling MyST markdown operations, and spawning JupyterHub instances locally.
Project description
MyST Libre
JupyterHub in Docker for MyST
A small library to manage reproducible execution environments using Docker and JupyterHub to build MyST articles in containers.
Table of Contents
Installation
-
Clone the repository:
git clone https://github.com/yourusername/myst_libre.git cd myst_libre
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Set up environment variables: Create a
.env
file in the project root and add the following:DOCKER_PRIVATE_REGISTRY_USERNAME=your_username DOCKER_PRIVATE_REGISTRY_PASSWORD=your_password
External requirements
- Node.js (For MyST)
- Docker
Quick Start
from myst_libre.rees import REES
from myst_libre.tools import JupyterHubLocalSpawner
resources = REES(dict(registry_url="https://binder-registry.conp.cloud",
gh_user_repo_name = "agahkarakuzu/mriscope",
gh_repo_commit_hash = "6d3f64da214441bbb55b2005234fd4fd745fb372",
binder_image_tag = "489ae0eb0d08fe30e45bc31201524a6570b9b7dd"))
hub = JupyterHubLocalSpawner(resources,
host_data_parent_dir = "~/neurolibre/mriscope/data",
host_build_source_parent_dir = '~/Desktop/tmp',
container_data_mount_dir = '/home/jovyan/data',
container_build_source_mount_dir = '/home/jovyan')
hub.spawn_jupyter_hub()
Usage
Authentication
The Authenticator
class handles loading authentication credentials from environment variables.
from myst_libre.tools.authenticator import Authenticator
auth = Authenticator()
print(auth._auth)
Docker Registry Client
The DockerRegistryClient class provides methods to interact with a Docker registry.
from myst_libre.tools.docker_registry_client import DockerRegistryClient
client = DockerRegistryClient(registry_url='https://my-registry.example.com', gh_user_repo_name='user/repo')
token = client.get_token()
print(token)
Build Source Manager
The BuildSourceManager class manages source code repositories.
from myst_libre.tools.build_source_manager import BuildSourceManager
manager = BuildSourceManager(gh_user_repo_name='user/repo', gh_repo_commit_hash='commit_hash')
manager.git_clone_repo('/path/to/clone')
project_name = manager.get_project_name()
print(project_name)
Module and Class Descriptions
AbstractClass
Description: Provides basic logging functionality and colored printing capabilities.
Authenticator
Description: Handles authentication by loading credentials from environment variables.
Inherited from: AbstractClass
Inputs: Environment variables DOCKER_PRIVATE_REGISTRY_USERNAME
and DOCKER_PRIVATE_REGISTRY_PASSWORD
RestClient
Description: Provides a client for making REST API calls.
Inherited from: Authenticator
DockerRegistryClient
Description: Manages interactions with a Docker registry.
Inherited from: Authenticator
Inputs:
registry_url
: URL of the Docker registrygh_user_repo_name
: GitHub user/repository nameauth
: Authentication credentials
BuildSourceManager
Description: Manages source code repositories.
Inherited from: AbstractClass
Inputs:
gh_user_repo_name
: GitHub user/repository namegh_repo_commit_hash
: Commit hash of the repository
JupyterHubLocalSpawner
Description: Manages JupyterHub instances locally.
Inherited from: AbstractClass
Inputs:
rees
: Instance of the REES classregistry_url
: URL of the Docker registrygh_user_repo_name
: GitHub user/repository nameauth
: Authentication credentialsbinder_image_tag
: Docker image tagbuild_src_commit_hash
: Commit hash of the repositorycontainer_data_mount_dir
: Directory to mount data in the containercontainer_build_source_mount_dir
: Directory to mount build source in the containerhost_data_parent_dir
: Host directory for datahost_build_source_parent_dir
: Host directory for build source
MystMD
Description: Manages MyST markdown operations such as building and converting files.
Inherited from: AbstractClass
Inputs:
build_dir
: Directory where the build will take placeenv_vars
: Environment variables needed for the build processexecutable
: Name of the MyST executable (default is 'myst')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file myst_libre-0.1.0.tar.gz
.
File metadata
- Download URL: myst_libre-0.1.0.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 910edcf6d79ba6bf8719a1b70de6423b2157599c0daca42db5a01cdfa15fda69 |
|
MD5 | 2e310dbb249c4e95632723da6baf6420 |
|
BLAKE2b-256 | 845446e18b30379b46475ca85c62add323ab8fa48207df49358805149d3604cf |
File details
Details for the file myst_libre-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: myst_libre-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f5a73d335025d9a5e720036871f1754197835ba0d9d4de9021cd8359abe0658 |
|
MD5 | 4266d077a8c795cb4030de95168c4d38 |
|
BLAKE2b-256 | eed6f767a8a01ef3f2e38f5f77d47087967504ff6447e356fe7d99d680bbf5cb |