Skip to main content

Smart Spectal Matching Python Client Library

Smart Spectral Matching Python Client

Installation

Using pip

coming soon...

Manually

Clone the repository either via:

  • HTTP:
git clone https://github.com/smart-spectral-matching/ssm-client-python.git
  • SSH:
git clone git@github.com:smart-spectral-matching/ssm-client-python.git

Create a virtual environment and activate to install the package in the isolated environment:

python -m venv <name of env>
source <env>/bin/activate

To install the package from the local source tree into the environment, run:

python -m pip install .

Or to do so in "Development Mode", you can run:

python -m pip install -e .

To deactivate the virtual environment

deactivate

When finished, remove the virtual environment by deleting the directory:

rm -rf <name of env>

Usage

After installation, you can use the two main components of this package for the following functions:

Also, there are Jupyter Notebooks in the tutorials/ directory to help get started and test files under tests/data in different directories.

IO Module

This module is used to translate to and from different spectroscopy file formats. The currently supported file formats are:

The module has two main functions, read and write.

The read function reads in spectroscopy files and translates them to SciData JSON-LD dictionaries.

The write function takes SciData JSON-LD dictionaries and writes them out in the specified spectroscopy file format.

Example:

from ssm_client.io import read, write

# Read in from RRUFF, write out to JCAMP-DX
scidata_dict = read("./tests/data/rruff/raman_studtite.rruff", ioformat="rruff")
write("./raman_studtite.jdx", scidata_dict, ioformat="jcamp")

# Modify SciData JSON-LD and write back out to RRUFF
uid = 'my:example:jsonld'
scidata_dict["@graph"]["uid"] = uid
write("./my_raman_studtite.rruff", scidata_dict, ioformat="rruff")

SSMRester

The SSMRester is a REST client for the SSM REST API for storing datasets.

The SSMRester is a class and you can create an object by providing the REST API server information (hostname + port) you want to interact with for uploading / downloading datasets.

A dataset is a collection of individual data you want to store and a model is the individual data you store as a graph.

You must have a dataset that a model is associated with.

With a SSMRester object, you can perform common Create-Read-Update-Delete (CRUD) tasks for datasets and models.

Example:

import json
from ssm_client import SSMRester

rester = SSMRester(hostname="http://ssm.ornl.gov")
dataset = rester.dataset.create()
rester.initialize_model_for_dataset(dataset)

model = rester.model.create(scidata_dict)
print(dataset.uuid)
print(model.uuid)
rester.dataset.delete_by_uuid(dataset.uuid)

Development

Install via pdm

Install via pdm with dev dependencies:

pdm install -G:all

Then, run commands via pdm:

pdm run python -c "import ssm_client"

Tests / Linting

Flake8 linting

Run linting over the package with flake8 via:

pdm run flake8 src/ssm_client/ tests/

Pytest testing

Run tests using pytest:

pdm run pytest tests/

Code coverage

Get code coverage reporting using the pytest-cov plugin:

pdm run pytest --cov=src/ssm_client --cov-report=term-missing tests/

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Links

Licensing

BSD 3-clause

Metadata

Release files for ssm-client 0.5.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 ssm-client 0.5.1
File Size Uploaded Provenance
ssm_client-0.5.1.tar.gz 423.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ssm-client 0.5.1
File Interpreter ABI Platform
ssm_client-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 437.8 kB

Release files / ssm_client-0.5.1.tar.gz

Download URL ssm_client-0.5.1.tar.gz
Size 423.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bcbdcee532e14e9b5727456f9998fc281b31d3d47ff2bb80645f2eb4d95584bf
BLAKE2b-256 checksum
How to use checksums
234277fb31bb801c69056cc97ec2cbcace73e1c116288c43a64177c94ca151b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.18.1 CPython/3.10.12 Linux/6.5.0-45-generic

Release files / ssm_client-0.5.1-py3-none-any.whl

Download URL ssm_client-0.5.1-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
745fc458ece35f11d9c22501114708f3d6441dab8c823d78ae1198660e6e9198
BLAKE2b-256 checksum
How to use checksums
9dd24fa56c2d92b055594ae2a7d246dfa47533d561f669cc6e650377ad18178c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.18.1 CPython/3.10.12 Linux/6.5.0-45-generic

Security for ssm-client 0.5.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files No provenance

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