Skip to main content

sparc.client

NIH SPARC Python Client

PyPI Latest Release pypi Package Status License Coverage

Architecture details

The sparc.client Python Client stores its configuration in the config.ini file.

The modules of sparc.client are to be defined in services/ directory and need to be derived from BaseService class (services/_default.py) This means that they need to implement the specific functions defined in the interface, such as init, connect(), info(), get_profile(), set_profile() and close(). Apart from that functions, each module in the services may define their own methods (e.g. refer to services/pennsieve.py list_datasets()).

config.ini

The configuration file has the following format:

[global]
default_profile=ci

[prod]
pennsieve_profile_name=prod

[dev]
pennsieve_profile_name=test

[ci]
pennsieve_profile_name=ci

[global] section defines the default profile that is to be used. This basically refers to any section in brackets that stores configuration variables. In this case it refers to 'ci' section.

Within each section, different configuration variables could be defined. In our case, the only variable that needs to be defined is pennsieve_profile_name, which is passed to the Pennsieve2 library.

Module automatic import

Each python file in services/ folder with defined class name that is derived from BaseService is imported as a module to SparcClient class.

For example, Pennsieve module could be used in the following way:

from sparc.client import SparcClient
client = SparcClient(connect=False, config_file='config/config.ini')

# Run module prerequisities, e.g. start Pennsieve agent in the background
!pennsieve agent

# connect to the Pennsieve module, get Pennsieve Agent object
client.pennsieve.connect()

# execute internal functions of the module
client.pennsieve.info()

# alternatively connect all the services available
client.connect()  #connect to all services

Test generation - PyTest

Some good resource for implementing tests could be found at Medium.

Documentation - Sphinx tutorial

A fresh start for creating documentation with Sphinx could be found at towardsdatascience. To reproduce steps:

  1. Create a docs folder
  2. Run sphinx-quickstart in docs folder, fill the required prompts.
  3. Edit conf.py and index.rst files to adjust them to your needs
  4. Run in docs folder sphinx-apidoc -o . ../src
  5. Disregard modules.rst and sphinx.rst, attach sphinx.client to toctree in index.rst
  6. Run make html in docs folder.

Contribution Guide

  1. Define configuration variables in config.ini file (e.g api_key, api_secret etc.)
  2. Create a file in services/
  3. Create a class within this file that extends BaseService
  4. The class needs to define all the functions required + may add its own.

Developer Setup

Run pip install -e '.[test]' to install the dependencies needed for a development environment.

Run pytest --cov=./src to run the tests and get a test coverage summary.

Run pytest --cov-report html --cov=./src to run the tests and get a full HTML coverage report output to htmlcov.

Run python -m build to check if your package builds successfully.

The process is currently automated using Github Action in CI.yml.

Software releasing guidelines

The process of releasing new version of the software is fully automated.

This means that CHANGELOG.md as well as release commands are automatically generated.

The versioning is fully dynamic using git tags.

Please also note that there is no package/software version pyproject.toml. We use dynamic versioning provided by setuptools_scm

Also file sparc.client/_version.py should not be committed to the repository.

How commits should look like?

We are using Semantic Commit Messages for commits.

Basically this means that important commits should start with one of the following prefixes: chore:, docs:, feat:, fix:, refactor:, style:, or test:.

Additionally, we ask to refer to the issue number on Github (by adding a reference, e.g. #24234) Refer to issues

Releasing a new version

  1. In order to release a new version, an action 'Create new release' needs to be launched from Github Actions menu. Please navigate to 'Actions' and click 'Create new release' on the left hand side. On the right hand side, you can click 'Run workflow'

  2. After launching a workflow, specify manually a version. The version needs to start with 'v', e.g. 'v0.0.34'.

  3. Launching a workflow checks for the user permission (needs to be admin to the repository) and runs CI in order to verify integrity of the software.

  4. If the CI/CD test passes, a temporary tag is created. The commits which follow the symantic versioning naming convention are then used to create and update CHANGELOG.md.

  5. Once CHANGELOG.md is pushed to the main branch, the new version is tagged again and the software is released to Github and to PyPI.

Metadata

Release files for sparc.client 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sparc.client 0.4.1
File Size Uploaded
sparc_client-0.4.1.tar.gz 791.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sparc.client 0.4.1
File Interpreter ABI Platform
sparc_client-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 820.6 kB

Release files / sparc_client-0.4.1.tar.gz

Download URL sparc_client-0.4.1.tar.gz
Size 791.2 kB
Tags Source
SHA-256 checksum
How to use checksums
24023cf2acd3880ebb15343a5c4a279974bd677bc9ab3b205bc0b3af6d2c5d20
BLAKE2b-256 checksum
How to use checksums
79aee9d46e85cda01459ace5e187b54e799aee40137d8b78dcdf2c96ffdb77db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2025.

Transparency log

Release files / sparc_client-0.4.1-py3-none-any.whl

Download URL sparc_client-0.4.1-py3-none-any.whl
Size 29.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
049d490bb15ba928de6e59bbefee6e3ca7445f19d83b4ccdef97aee2d0a11484
BLAKE2b-256 checksum
How to use checksums
94edeaa0fde6715f4f5fc754e76cfacfee98246fca8aae3bae3742bee9b1b35e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.99

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page