Skip to main content

A Python client for Slivka services

Project description

Slivka Python Client

PyPI version License

Slivka Python client is a convenience wrapper around the popular requests library. It provides an interface for communicating with the Slivka REST API using Python.

Features

  • Programmatic access to Slivka API with simple objects.
  • Command-line interface.
  • Interactive widgets for Jupyter notebooks.

Installation

The easiest way to install the Slivka client is via pip from PyPI:

pip install slivka-client

Alternatively, if you prefer to use the conda package manager, you can install it from the Slivka channel:

conda install -c slivka slivka-client

To install it from the source code, clone the Git repository to your machine and run:

python setup.py install

Getting Started

After installing the Slivka client, you can begin by importing it and connecting to a Slivka server:

import slivka_client

# Replace with your actual server URL
client = slivka_client.SlivkaClient("https://your-slivka-server-url/")

You can verify the connection by checking the server version:

print(client.version)

Usage

Accessing Services

To retrieve the list of available services from the Slivka server:

services = client.services

Each element in the list is a Service object containing details such as the service's id, name, and description.

To access a specific service by its ID, use:

service = client.get_service('example_service_id')
# Or
service = client['example_service_id']

Starting Jobs

Once you've selected the desired service, you can submit jobs using the submit_job() method. This requires providing parameters in the form of dictionaries.

Here’s an example of submitting a job:

data = {
    'param0': 13,
    'param1': 'foobar'
}

files = {
    'input0': open("input-file.txt", "rb"),
    'input1': b"data data data data\n"
}

job = service.submit_job(data=data, files=files)

This method returns a Job object that allows you to monitor the status and retrieve results.

Polling Jobs and Retrieving Results

You can check the status of a submitted job using:

print(job.status)

To retrieve the results:

for result in job.results:
    result.dump("output_file.txt")

File Handling

The File object provides a convenient way to download results:

result = job.results[0]
result.dump("output_file.txt")

The File object properties include:

  • url: Location of the resource.
  • content_url: Location of the file content.
  • id: Identifier of the file (can be used as input for other jobs).
  • job_id: ID of the job this file is a result of.
  • path: Real path and name of the file.
  • label: Name describing the file.
  • media_type: Media type of the file.

Command-Line Interface (CLI)

The slivka-cli command-line tool allows for interaction with the Slivka API without writing Python scripts.

To get started:

slivka-cli --help

This will provide you with usage instructions and available commands.


License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.


Support

If you have any questions or need assistance, please open an issue on our GitHub repository.

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

slivka_client-1.2.1b1.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

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

slivka_client-1.2.1b1-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file slivka_client-1.2.1b1.tar.gz.

File metadata

  • Download URL: slivka_client-1.2.1b1.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for slivka_client-1.2.1b1.tar.gz
Algorithm Hash digest
SHA256 4a4556f94ee6e97dc214a5cf10daa6d91ca8344d77acc3f2b0d19d8fee777ee0
MD5 1ea5f6c4b8dae5aeb5b69e405e54bac6
BLAKE2b-256 8b1cfd4737f2f57e8edd201e2ca80410744e262ebad43a158f4d599f7a511905

See more details on using hashes here.

File details

Details for the file slivka_client-1.2.1b1-py3-none-any.whl.

File metadata

File hashes

Hashes for slivka_client-1.2.1b1-py3-none-any.whl
Algorithm Hash digest
SHA256 6b56475206af75c299f251d6240a9346b22b0c80a6cccc5ed843b351662e3596
MD5 3cf22548dea3e7d1e4020da4e055e95b
BLAKE2b-256 ed8dda36a30ac163eec5298d738fa7e38692fab3e79b8bf2459320ebacfd27ff

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