A Python project created with pyscaf for importing and managing variables in OpenSILEX.
Use curl to download the script and run it with sh:
curl -LsSf https://astral.sh/uv/install.sh | shIf your system does not have curl, you can use wget:
wget -qO- https://astral.sh/uv/install.sh | shTo install a specific version, specify it in the URL:
curl -LsSf https://astral.sh/uv/0.10.9/install.sh | sh
uv venv
# or python -m venv .venvYou must create an SSH key associated with GitLab.
uv pip install git+ssh://git@forge.inrae.fr/opensilex/data-analysis-visualisation/opensilex-clients/opensilex-ws-python-client.git
# specific version
# uv pip install git+ssh://git@forge.inrae.fr/OpenSILEX/opensilex-generator.git@develop
- Auto-generation of URIs from component names (no manual calculation needed)
- Automatic component creation (Entity, Characteristic, Method, Unit)
- Group management with support for up to 2 groups per variable
- Modular architecture with reusable components
- Jupyter notebook examples included realpython
### Download Variable Config Example
| Argument | Meaning | Default value | Comment |
|---|---|---|---|
--dest |
Destination directory where example files will be copied. | . (current directory) |
Directory is created automatically if it does not exist; can be relative or absolute path. |
# default – copies files into the current directory
uv run download-variable-config-example
# specify a custom destination
uv run download-variable-config-example --dest ./config### Import Variables Example
| Argument | Meaning | Default value | Comment |
|---|---|---|---|
--host |
Base URL of the OpenSILEX REST API (must include /rest). |
http://localhost:8666/rest |
Can also be supplied via the OPENSILEX_HOST environment variable. |
--identifier |
Email address of the OpenSILEX account. | admin@opensilex.org |
Can also be supplied via OPENSILEX_IDENTIFIER. |
--password |
Password of the OpenSILEX account. | None (required) | Can also be supplied via OPENSILEX_PASSWORD. Avoid passing the password in clear text on the command line; prefer the environment variable. |
--csv |
Path to the CSV input file. | – | Required – the file must exist and be readable. |
--config |
Path to the YAML configuration file. | – | Required – the file must exist and be readable. |
--skip-groups |
Do not attach the imported variables to groups defined in the YAML file. | False |
Useful for quick or test imports. |
--verbose / -v |
Print detailed logs. | False |
Adds emojis and progress messages. |
# guest credentials example
uv run run-variable-import --host http://localhost:8666/rest --identifier guest@opensilex.org --password guest --csv test_variables.csv --config test_config.yaml
uv run python run-variable-import.py
--host http://localhost:8666/rest
--identifier admin@opensilex.org
--password secret
--csv variables.csv
--config config.yaml
--verbose
- Detailed execution flow
┌─────────────────────┐
│ Parse arguments │
└───────┬─────────────┘
│
▼
┌─────────────────────┐
│ Verify CSV & YAML │
│ files existence │
└───────┬─────────────┘
│
▼
┌─────────────────────┐
│ Authentication │
│ connect_to_opensilex│
│ (host, identifier, │
│ password) │
└───────┬─────────────┘
│
│ (failure) → error message → exit 1
▼
┌─────────────────────┐
│ Import variables │
│ from CSV (import_from_csv.run) │
└───────┬─────────────┘
│
▼
┌─────────────────────┐
│ Attach to groups │
│ (update.attach_to_groups) │
│ – unless --skip-groups │
└───────┬─────────────┘
│
▼
┌─────────────────────┐
│ End of script – │
│ exit code 0 │
└─────────────────────┘
## uv Integration
This project uses uv for dependency management and packaging. uv provides a modern and extremely fast way to manage Python dependencies and build packages.
### Features
- **Dependency Management**: uv manages project dependencies through `pyproject.toml`
- **Virtual Environment**: Automatically creates and manages a virtual environment
- **Build System**: Integrated build system for creating Python packages
- **Lock File**: Generates a `uv.lock` file for reproducible installations
### Common Commands
```bash
# Install dependencies
uv sync
# Add a new dependency
uv add package-name
# Add a development dependency
uv add --dev package-name
# Update dependencies
uv sync --upgrade
# Run a command within the virtual environment
uv run python script.py
# Activate the virtual environment
uv run shell
The project follows a standard Python package structure:
pyproject.toml: Project configuration and dependenciesuv.lock: Locked dependencies for reproducible buildssrc/: Source code directorytests/: Test files directory
To start developing:
- Ensure uv is installed
- Run
uv syncto install all dependencies - Use
uv runto execute scripts in the environment - Start coding!
For more information, visit uv's official documentation.
Ruff is an extremely fast Python linter and code formatter, written in Rust. It can replace Flake8, Black, isort, pyupgrade, and more, while being much faster than any individual tool.
The file .vscode/default_settings.json provides a recommended configuration for using Ruff in VSCode:
{
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "charliermarsh.ruff"
},
"notebook.formatOnSave.enabled": true,
"notebook.codeActionsOnSave": {
"notebook.source.fixAll": "explicit",
"notebook.source.organizeImports": "explicit"
},
"ruff.lineLength": 88
}editor.formatOnSave: Enables automatic formatting on save for all files.[python].editor.defaultFormatter: Sets Ruff as the default formatter for Python files.[python]editor.codeActionsOnSave.source.organizeImports: Organizes Python imports automatically on save.[python]editor.codeActionsOnSave.source.fixAll: Applies all available code fixes (including linting) on save.ruff.lineLength: Line length for your python files
You can run the following commands commands directly in the shell
# Lint all Python files in the current directory
ruff check .
# Format all Python files in the current directory
ruff format .
# Automatically fix all auto-fixable problems
ruff check . --fixFor more information, see the official Ruff VSCode extension documentation and the Ruff documentation.
You can enable specific rules over a catalog of over 800+ rules, depending on your needs or framework of choice. Check it out at the Ruff documentation.
This action uses pdoc to generate and serve documentation for your Python project.
The documentation configuration is managed in your pyproject.toml file:
[tool.pyscaf.documentation]
output_path = "docs"
[tool.pyscaf.documentation.pdoc]
# pdoc arguments are automatically converted to CLI arguments
# Boolean values: true -> --flag, false -> --no-flag
# Lists: ["value1", "value2"] -> --flag value1 --flag value2
# Strings: "value" -> --flag valueTwo scripts are available to manage documentation. Both scripts use the configuration defined in the [tool.pyscaf.documentation.pdoc]:
Generates static documentation files to the directory specified in tool.pyscaf.documentation.output_path.
uv run gen-docStarts a local documentation server for interactive browsing.
uv run serve-docAll arguments in the [tool.pyscaf.documentation.pdoc] section are automatically converted to pdoc CLI arguments:
- Boolean values:
truebecomes--flag,falsebecomes--no-flag - Lists:
["value1", "value2"]becomes--flag value1 --flag value2 - Strings:
"value"becomes--flag value
output argument is droped, as the behaviour to write instead of serve depends on the script use.
For example:
[tool.pyscaf.documentation.pdoc]
html = true
show_source = false
template_directory = "custom_templates"
external_links = ["https://example.com"]Becomes:
pdoc --html --no-show-source --template-directory custom_templates --external-links https://example.comThis project uses Git for version control, providing a robust system for tracking changes, collaborating, and managing code history.
- Version Control: Track changes and manage code history
- Branching: Create and manage feature branches
- Collaboration: Work with remote repositories
- Git Hooks: Automated scripts for repository events
# Initialize repository
git init
# Clone repository
git clone <repository-url>
# Create and switch to new branch
git checkout -b feature-name
# Stage changes
git add .
# Commit changes
git commit -m "commit message"
# Push changes
git push origin branch-name
# Pull latest changes
git pull origin branch-nameThe project includes:
.git/: Git repository data.gitignore: Specifies intentionally untracked files.gitattributes: Defines attributes for pathshooks/: Custom Git hooks (if present)
- Create a new branch for features/fixes
- Make changes and commit regularly
- Push changes to remote repository
- Create pull requests for code review
- Merge approved changes to main branch
- Write clear commit messages
- Keep commits focused and atomic
- Use meaningful branch names
- Regularly pull from main branch
- Review changes before committing
For more information, visit Git's official documentation.
This action configures python-semantic-release for automated versioning, changelog generation, and package publishing.
Semantic release automates the process of:
- Version management: Automatically bump version numbers based on commit messages
- Changelog generation: Create detailed changelogs from conventional commits
- Package publishing: Deploy to PyPI (TestPyPI automatically, Production PyPI manually)
- GitHub releases: Create GitHub releases with assets
- Git repository with versioning enabled
- GitHub repository (for workflows)
- Credential for the publisher repository
- PyPI credentials configured as GitHub secrets:
TEST_PYPI_PASSWORDfor TestPyPIPYPI_PASSWORDfor Production PyPI
-
TestPyPI (https://test.pypi.org):
- Go to Account Settings → API tokens
- Create a new token with "Entire account" scope
- Copy the token value
-
Production PyPI (https://pypi.org):
- Go to Account Settings → API tokens
- Create a new token with "Entire account" scope
- Copy the token value
-
Add to GitHub Secrets:
- Go to your repository → Settings → Secrets and variables → Actions
- Add
TEST_PYPI_PASSWORDwith your TestPyPI token - Add
PYPI_PASSWORDwith your production PyPI token
Configures pyproject.toml with some default semantic-release settings
- Release workflow: Automatically triggers on pushes to main branch
- Manual deploy workflow: Allows manual deployment to production PyPI
Uses Conventional Commits format:
feat:- New features (minor version bump)fix:- Bug fixes (patch version bump)BREAKING CHANGE:- Breaking changes (major version bump)docs:,style:,refactor:,test:,chore:- No version bump
The action automatically configures:
[tool.semantic_release]
version_variables = ["src/your_project/__init__.py:__version__"]
upload_to_pypi = true
upload_to_release = true
branch = "main"
[tool.semantic_release.remote]
type = "github" # or "gitlab"- Automatic releases: Push conventional commits to main branch
- Manual deployment: Use GitHub Actions "Manual Deploy to Production PyPI" workflow
- Commitizen - Interactive commit creation
- Semantic Release CLI - JavaScript version
- GitHub Actions for Python
- Keep a Changelog - Changelog format guidelines
- Semantic Versioning - Version numbering specification
- Git Flow - Git branching strategy
# Make changes
git add .
git commit -m "feat: add new feature"
git push origin main
# Automatic release happens on GitHub
# Package published to TestPyPI
# GitHub release created
# Manual deployment to Production PyPI via GitHub ActionsA Python project created with pyscaf
This project uses uv for dependency management and packaging. uv provides a modern and extremely fast way to manage Python dependencies and build packages.
- Dependency Management: uv manages project dependencies through
pyproject.toml - Virtual Environment: Automatically creates and manages a virtual environment
- Build System: Integrated build system for creating Python packages
- Lock File: Generates a
uv.lockfile for reproducible installations
# Install dependencies
uv sync
# Add a new dependency
uv add package-name
# Add a development dependency
uv add --dev package-name
# Update dependencies
uv sync --upgrade
# Run a command within the virtual environment
uv run python script.py
# Activate the virtual environment
uv run shellThe project follows a standard Python package structure:
pyproject.toml: Project configuration and dependenciesuv.lock: Locked dependencies for reproducible buildssrc/: Source code directorytests/: Test files directory
To start developing:
- Ensure uv is installed
- Run
uv syncto install all dependencies - Use
uv runto execute scripts in the environment - Start coding!
For more information, visit uv's official documentation.
Ruff is an extremely fast Python linter and code formatter, written in Rust. It can replace Flake8, Black, isort, pyupgrade, and more, while being much faster than any individual tool.
The file .vscode/default_settings.json provides a recommended configuration for using Ruff in VSCode:
{
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "charliermarsh.ruff"
},
"notebook.formatOnSave.enabled": true,
"notebook.codeActionsOnSave": {
"notebook.source.fixAll": "explicit",
"notebook.source.organizeImports": "explicit"
},
"ruff.lineLength": 88
}editor.formatOnSave: Enables automatic formatting on save for all files.[python].editor.defaultFormatter: Sets Ruff as the default formatter for Python files.[python]editor.codeActionsOnSave.source.organizeImports: Organizes Python imports automatically on save.[python]editor.codeActionsOnSave.source.fixAll: Applies all available code fixes (including linting) on save.ruff.lineLength: Line length for your python files
You can run the following commands commands directly in the shell
# Lint all Python files in the current directory
ruff check .
# Format all Python files in the current directory
ruff format .
# Automatically fix all auto-fixable problems
ruff check . --fixFor more information, see the official Ruff VSCode extension documentation and the Ruff documentation.
You can enable specific rules over a catalog of over 800+ rules, depending on your needs or framework of choice. Check it out at the Ruff documentation.
This action uses pdoc to generate and serve documentation for your Python project.
The documentation configuration is managed in your pyproject.toml file:
[tool.pyscaf.documentation]
output_path = "docs"
[tool.pyscaf.documentation.pdoc]
# pdoc arguments are automatically converted to CLI arguments
# Boolean values: true -> --flag, false -> --no-flag
# Lists: ["value1", "value2"] -> --flag value1 --flag value2
# Strings: "value" -> --flag valueTwo scripts are available to manage documentation. Both scripts use the configuration defined in the [tool.pyscaf.documentation.pdoc]:
Generates static documentation files to the directory specified in tool.pyscaf.documentation.output_path.
uv run gen-docStarts a local documentation server for interactive browsing.
uv run serve-docAll arguments in the [tool.pyscaf.documentation.pdoc] section are automatically converted to pdoc CLI arguments:
- Boolean values:
truebecomes--flag,falsebecomes--no-flag - Lists:
["value1", "value2"]becomes--flag value1 --flag value2 - Strings:
"value"becomes--flag value
output argument is droped, as the behaviour to write instead of serve depends on the script use.
For example:
[tool.pyscaf.documentation.pdoc]
html = true
show_source = false
template_directory = "custom_templates"
external_links = ["https://example.com"]Becomes:
pdoc --html --no-show-source --template-directory custom_templates --external-links https://example.comThis project uses Git for version control, providing a robust system for tracking changes, collaborating, and managing code history.
- Version Control: Track changes and manage code history
- Branching: Create and manage feature branches
- Collaboration: Work with remote repositories
- Git Hooks: Automated scripts for repository events
# Initialize repository
git init
# Clone repository
git clone <repository-url>
# Create and switch to new branch
git checkout -b feature-name
# Stage changes
git add .
# Commit changes
git commit -m "commit message"
# Push changes
git push origin branch-name
# Pull latest changes
git pull origin branch-nameThe project includes:
.git/: Git repository data.gitignore: Specifies intentionally untracked files.gitattributes: Defines attributes for pathshooks/: Custom Git hooks (if present)
- Create a new branch for features/fixes
- Make changes and commit regularly
- Push changes to remote repository
- Create pull requests for code review
- Merge approved changes to main branch
- Write clear commit messages
- Keep commits focused and atomic
- Use meaningful branch names
- Regularly pull from main branch
- Review changes before committing
For more information, visit Git's official documentation.
This action provides a comprehensive set of tools for manipulating Jupyter notebooks in your project.
The Jupyter Tools action adds the following capabilities to your project:
-
py_to_notebook.py - Convert Python files to Jupyter notebooks
- Handles cell markers and tags
- Preserves markdown links
- Supports jupytext format
-
execute_notebook.py - Execute Jupyter notebooks
- Runs notebooks with proper error handling
- Updates execution metadata
- Supports parameterized execution
-
notebook_to_html.py - Convert notebooks to HTML
- Creates standalone HTML files
- Includes CSS styling
- Preserves code highlighting
-
notebook_to_pdf.py - Convert notebooks to PDF
- Uses nbconvert with LaTeX backend
- Supports custom templates
- Handles complex formatting
-
main.py - Main CLI interface
- Process entire directories
- Complete pipeline from Python to HTML
- Batch processing capabilities
The following dependencies are automatically added to your project's dev group:
jupytext- For Python to notebook conversionnbconvert- For notebook format conversionweasyprint- For PDF generationpandoc- For document conversion
After running this action, you'll have a tools/ directory in your project with all the scripts ready to use:
## Convert a Python file to notebook
python tools/py_to_notebook.py input.py output.ipynb
## Execute a notebook
python tools/execute_notebook.py notebook.ipynb
## Convert notebook to HTML
python tools/notebook_to_html.py notebook.ipynb output.html
## Convert notebook to PDF
python tools/notebook_to_pdf.py notebook.ipynb output.pdf
## Process all Python files in a directory
python tools/main.py notebooks/This action integrates seamlessly with the Jupyter action, providing additional tools for notebook manipulation beyond the basic Jupyter setup.
- Requires the
coreandjupyteractions to be run first - Poetry project structure
- Python 3.7+
This action configures python-semantic-release for automated versioning, changelog generation, and package publishing.
Semantic release automates the process of:
- Version management: Automatically bump version numbers based on commit messages
- Changelog generation: Create detailed changelogs from conventional commits
- Package publishing: Deploy to PyPI (TestPyPI automatically, Production PyPI manually)
- GitHub releases: Create GitHub releases with assets
- Git repository with versioning enabled
- GitHub repository (for workflows)
- Credential for the publisher repository
- PyPI credentials configured as GitHub secrets:
TEST_PYPI_PASSWORDfor TestPyPIPYPI_PASSWORDfor Production PyPI
-
TestPyPI (https://test.pypi.org):
- Go to Account Settings → API tokens
- Create a new token with "Entire account" scope
- Copy the token value
-
Production PyPI (https://pypi.org):
- Go to Account Settings → API tokens
- Create a new token with "Entire account" scope
- Copy the token value
-
Add to GitHub Secrets:
- Go to your repository → Settings → Secrets and variables → Actions
- Add
TEST_PYPI_PASSWORDwith your TestPyPI token - Add
PYPI_PASSWORDwith your production PyPI token
Configures pyproject.toml with some default semantic-release settings
- Release workflow: Automatically triggers on pushes to main branch
- Manual deploy workflow: Allows manual deployment to production PyPI
Uses Conventional Commits format:
feat:- New features (minor version bump)fix:- Bug fixes (patch version bump)BREAKING CHANGE:- Breaking changes (major version bump)docs:,style:,refactor:,test:,chore:- No version bump
The action automatically configures:
[tool.semantic_release]
version_variables = ["src/your_project/__init__.py:__version__"]
upload_to_pypi = true
upload_to_release = true
branch = "main"
[tool.semantic_release.remote]
type = "github" # or "gitlab"- Automatic releases: Push conventional commits to main branch
- Manual deployment: Use GitHub Actions "Manual Deploy to Production PyPI" workflow
- Commitizen - Interactive commit creation
- Semantic Release CLI - JavaScript version
- GitHub Actions for Python
- Keep a Changelog - Changelog format guidelines
- Semantic Versioning - Version numbering specification
- Git Flow - Git branching strategy
# Make changes
git add .
git commit -m "feat: add new feature"
git push origin main
# Automatic release happens on GitHub
# Package published to TestPyPI
# GitHub release created
# Manual deployment to Production PyPI via GitHub Actions