Skip to main content

Slycat python interface.

Project description

SlyPI

Python Interface for Slycat.

Description

Slycat is a web application for interactive visualization of ensemble data (see https://github.com/sandialabs/slycat and https://slycat.readthedocs.io/en/latest). The SlyPI project contains code that enables you to interact with the Slycat web server through a Python interface. You can query the Slycat server, create Slycat models, and use the code to integrate your own algorithms into the Slycat pipeline.

Documentation

Full documentation can be found in the docs folder and can be compiled using Sphinx with

make html

The resulting documention can be accessed under build from the file index.html. You can also read the compiled version at https://slypi.readthedocs.io/en/latest/index.html.

Installation

This code is available at https://pypi.org/project/slypi/ and can be installed using

pip install slypi

If you are working behind a proxy, you might also need, e.g.

pip install slypi --proxy your-proxy:your-port

If you are getting SSL certificate errors, you can use:

pip install slypi --trusted-host pypi.org --trusted-host files.pythonhosted.org

Be aware that the last option is insecure. The better approach is to fix your SSL certificate and/or point Python to a copy of the certificate. This can be done using:

pip config set global.cert path-to-your-certificate

You can also install locally from this repository using:

pip install -e slypi .

Note: that for SlyPI to work, you must have a Slycat server running.
See https://slycat.readthedocs.io/en/latest/ for details on setting up a server.

Optional Dependencies

SlyPI uses PyMKS (https://github.com/materialsinnovation/pymks, https://pypi.org/project/pymks/) to compute auto-correlation. This package doesn't install with versions of Python past 3.11.8, so it is included as an optional dependency. If you want to use auto-correlation, use

pip install slypi[auto]

Basic Use

SlyPI can be imported from within a Python file using

import slypi

Some examples using SlyPI can be found in the SlyPI source directory. These can be run using, e.g.

python -m slypi.util.list_markings

In addition, there are two main entry points defined, one for the Slycat Dial-A-Cluster model

dac_upload_gen

and one for the parameter space model

ps_upload_csv

Kerberos

The --kerberos option relies on a working Kerberos installation on your system. Sometimes this will fail. If you get an error related to Kerberos credentials (e.g. "Couldn't find Kerberos ticket," or "User not Kerberos authenticated"), try:

kinit

Then re-run the original command.

Proxies/Certificates

If you are separated from the Slycat server by a proxy, or have not set up a security certificate, you will have to use the SlyPI proxy settings. The proxy settings are available using the flags:

  • --http-proxy
  • --https-proxy
  • --verify
  • --no-verify

The proxy flags are by default set to "no proxy". If you have proxies set in the environment variables, they will be ignored. The proxy flags are used as follows (for example):

python -m slypi.list_markings --http-proxy http://your.http.proxy --https-proxy https://your.https.proxy

The verify flag can be used to pass a security certificate as a command line argument and the --no-verify flag can be used to ignore the security certificates altogether.

General Utilities

The simplest examples of interacting with the Slycat server issue requests for markings and projects, e.g.

python -m slypi.util.list_markings
python -m slypi.util.list_projects

To examine a particular model or project, use

python -m slypi.util.get_model mid
python -m slypi.util.get_project pid

where mid and pid are the hash identifiers for a Slycat model or project residing on the Slycat server. These IDs can be extracted from the URL in the Slycat web browser client, or by using Info -> Model Details from the browser.

Creating Models

The SlyPI module provides a command line option for creating Slycat models. For example, to create a sample CCA model using random data, use:

python -m slypi.cca.upload_random

To create a sample CCA model from a CSV file, use:

python -m slypi.cca.upload_csv slycat-data/cars.csv --input Cylinders Displacement Weight Year --output MPG Horsepower Acceleration --project-name "CCA Models"

where "slycat-data/cars.csv" is from the slycat-data git repository at https://github.com/sandialabs/slycat-data.

Note that when a model is created, the URL is given in the console and can be copied into a web browser to display the model. The model ID can also be extracted from this URL (it is the hash at the end of the URL).

Parameter Space Models

SlyPI also provides a programmatic interface for creating models. To create a Parameter Space model from a python script, use the SlyPI module as follows:

import slypi.ps.upload_csv as ps_upload_csv

# parameter space file
CARS_FILE = ['../slycat-data/cars.csv']

# input/output columns for cars data file
CARS_INPUT = ['--input-columns', 'Model', 'Cylinders', 'Displacement', 'Weight', 'Year']
CARS_OUTPUT = ['--output-columns', 'MPG', 'Horsepower', 'Acceleration']

# create PS model from cars file
ps_parser = ps_upload_csv.parser()
arguments = ps_parser.parse_args(CARS_FILE + CARS_INPUT + CARS_OUTPUT)
ps_upload_csv.create_model(arguments, ps_upload_csv.log)     

A Parameter Space model can also be created from .csv file using the ps_csv script. From the command line, use:

python -m slypi.ps.upload_csv slycat-data/cars.csv --input-columns Cylinders Displacement Weight Year --output-columns MPG Horsepower Acceleration --project-name "PS Models"

Dial-A-Cluster (DAC) Models

Dial-A-Cluster models can be loaded using different formats. The first format is the generic dial-a-cluster format, described more fully in the Slycat user manual.

To upload a DAC generic .zip file, use

dac_upload_gen slycat-data/dial-a-clsuter/weather-dac-gen.zip --project-name "DAC Models"

This will create a model from a single .zip file containing the appropriate folders with the pre-computed distance or PCA matrices.

Other Models

Currently, SlyPI supports Slycat CCA, DAC, PS, and Videoswarm models. The only Slycat model type still unsupported is Time Series. For examples using CCA, DAC, PS, and Videoswarm, see the full documentation.

Contact

Shawn Martin -- smartin@sandia.gov

License

Distributed under the Sandia license. See LICENSE file for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slypi-1.1.6.tar.gz (102.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

slypi-1.1.6-py3-none-any.whl (121.5 kB view details)

Uploaded Python 3

File details

Details for the file slypi-1.1.6.tar.gz.

File metadata

  • Download URL: slypi-1.1.6.tar.gz
  • Upload date:
  • Size: 102.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for slypi-1.1.6.tar.gz
Algorithm Hash digest
SHA256 0f2dea1367c45d3daae173e33af235d154e94ba14a577ea039278ad7ebd453d3
MD5 983da62e5eb073ba8f06fd2b09577291
BLAKE2b-256 ea3a9fb052f34f557c08d2a55de8e7d62578acebd3fc7b1501bd50f53069b609

See more details on using hashes here.

File details

Details for the file slypi-1.1.6-py3-none-any.whl.

File metadata

  • Download URL: slypi-1.1.6-py3-none-any.whl
  • Upload date:
  • Size: 121.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for slypi-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 dc6eceb9877c498ec80605f63de14eca63a4c4e87c9a4ac61d2aaabc6b0d3b53
MD5 2e8484233950c077fa7acb2021ce96eb
BLAKE2b-256 9ff41da1458a7d5e77767f19ec1f0b3b3ed1311c63a5c68b6b4c1cb7f0998d9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page