Python implementation of the SiLA 2 standard for lab automation
Project description
SiLA 2 Python Implementation
| SiLA Homepage | https://sila-standard.com |
| Chat group | Join the group on Slack |
| Maintainer | UniteLabs GmbH and Niklas Mertsch of wega Informatik AG |
| Vulnerability Policy | https://sila-standard.com/vulnerability_policy |
Project Status: Maintenance-only
Please don't expect major changes. For an actively maintained and more extensive Python implementation of SiLA 2, please see https://gitlab.com/unitelabs/sila2/sila-python.
Getting started
Installation
Use pip install sila2 to install the latest release of the library.
There are optional dependencies:
pip install sila2[codegen]is required for code generation but not for running SiLA Servers or Clientspip install sila2[cryptography]is required for auto-generating self-signed SSL certificates on server startup, and for additional certificate validation steps by the client
On Raspberry Pi systems, run the following to fix some ImportErrors:
pip uninstall -y lxml grpcio grpcio-toolssudo apt install -y python3-lxml python3-grpcio python3-grpc-tools
Dependencies
This project only has a few direct dependencies:
- grpc for gRPC-based communication
- lxml for XML interactions (parsing, XSD validation, XSL transformation)
- zeroconf for SiLA2 Server Discovery
- typing-extensions for type hinting
- typer for server command line interfaces (server only, can be disabled during code generation)
A list of all dependencies (including transitive dependencies) for the latest version of the example server can be found here
Documentation
A documentation on SiLA Server generation, feature implementation, and usage of SiLA Clients can be found here.
Example
The directory example_server contains an example SiLA Server application. example_client_scripts contains multiple SiLA Client programs that interact with the example server.
Implementation status
Missing parts from SiLA 2 specification
- Lifetime handling for binary transfer
- currently, large binaries are only deleted on request
- Server-initiated connection (SiLA 2 v1.1)
- currently, only client-initiated connections are supported
Deviations from SiLA 2 specification
- Duration is rounded to microseconds, because
datetime.timedeltadoes not support sub-microsecond precision - Microseconds of
datetime.timeanddatetime.datetimeare ignored since Time and Timestamp don't support sub-second precision
Contributing
Contributions in the form of issues, feature requests and merge requests are welcome. To reduce duplicate work, please create an issue and state that you are working on it before you spend significant time on writing code for a merge request.
Development
Multi-stage build process
Because the sila2.features submodule is auto-generated using the code generator included in this library, the build process has multiple steps:
- Install the library without
sila2.feature - Use the script
generate-feature-submodule.pyto generatesila2.feature - Install again
Development tools
This project uses the following tools to improve code quality:
- ruff for code formatting and linting
- pytest for testing
- pytest-cov for measuring code coverage
The following Python scripts are provided to guide the development process:
run-formatting.pyappliesruff formatandruff check --select I --fix .run-checks.pychecks for formatting and code style problems, runs SAST scan and runs the testsinstall-pre-commit-hook.pyinstalls apre-commitgit hook to automatically execute a fast-running subset of all checks on each commit
To install all these tools, use pip install .[dev].
Documentation build process
To build the documentation, first install this library with pip install .[docs], the run docs/make-docs.py.
The HTML documentation can then be found at docs/_build/html
Application Security
To ensure secure development practices, this project integrates automated security scans into the development workflow. Both static application security testing (SAST) and software composition analysis (SCA) are used to detect vulnerabilities in custom code and third-party dependencies. A pre-commit hook is also provided to catch issues early by scanning changed code before it is committed.
This project uses the following tools to improve application security:
- OSS Review Toolkit (ORT) for software composition analysis (SCA) of third-party dependencies.
- Semgrep Community Edition for static application security testing (SAST), using both general (e.g. OWASP Top 10, CWE Top 25) and Python-specific security rules.
- ruff with bandit rules enabled for lightweight static checks focused on Python code security.
The following Python script is provided to support security checks:
install-pre-commit-hook.pyinstalls apre-commitgit hook to automatically run fast SAST checks (via Semgrep CE) on changed code before each commit.
Setup code
The full development setup using the setuptools development mode looks like this:
# clone repository
git clone --recurse-submodules https://gitlab.com/sila2/sila_python
cd sila2
# install sila2 in development mode
pip install -e .[full] # install without sila2.feature submodule and all optional dependencies
python generate-feature-submodule.py # generate sila2.feature code (generates src/sila2/feature/...)
# build documentation (generates docs/_build/html)
python docs/make-docs.py
# install example server in development mode (required for tests)
pip install -e example_server
# run test suite
python run-checks.py
# run code formatting
python run-formatting.py
# install git pre-commit hook (generates .git/hooks/pre-commit)
python install-pre-commit-hook.py
# build wheel and source distribution (generates build/ and dist/)
pip install build
python -m build -ws
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sila2-0.14.0-py3-none-any.whl.
File metadata
- Download URL: sila2-0.14.0-py3-none-any.whl
- Upload date:
- Size: 197.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f85447cf9a92889170f666410d5f45b736f2b4025132d73f54609027118a839
|
|
| MD5 |
2301d984c1d033287da9528988c5d823
|
|
| BLAKE2b-256 |
124c5a4dcf0843990433871fd1ab6de50b230d4e6f3de3f727e75aa4b596142e
|