Skip to main content

A Python3 client for pfcon’s web API.

MIT License https://badge.fury.io/py/python-pfconclient.svg

Overview

This repository provides a Python3 client for pfcon service’s web API. The client provides both a Python programmatic interface and a standalone CLI tool called pfconclient.

Installation

$> pip install -U python-pfconclient

pfcon server preconditions

These preconditions are only necessary to be able to test the client against an actual instance of the pfcon server and run the automated tests.

Install latest Docker

Currently tested platforms:

  • Ubuntu 20.04+ and MAC OS X 12+

Note: On a Linux machine make sure to add your computer user to the docker group. Consult this page https://docs.docker.com/engine/install/linux-postinstall/

Fire up the full set of pfcon services

Open a terminal and run the following commands in any working directory:

$> git clone https://github.com/FNNDSC/pfcon.git
$> cd pfcon
$> ./make.sh -N -F fslink

You can later remove all the backend containers with:

$> cd pfcon
$> ./unmake.sh -N -F fslink

Usage

Python programmatic interface

Instantiate the client:

from pfconclient.client import Client, JobType

token = Client.get_auth_token('http://localhost:30006/api/v1/auth-token/', 'pfcon', 'pfcon1234')
cl = Client('http://localhost:30006/api/v1/', token)

Standalone CLI client tool

Get and print auth token with the auth subcommand:

$> pfconclient http://localhost:30006/api/v1/ auth --pfcon_user pfcon --pfcon_password pfcon1234

Submit a copy job:

$> pfconclient http://localhost:30006/api/v1/ -a <token> submit --job_type copy --jid chris-jid-2 --input_dirs home/user/cube --output_dir home/user/cube_out

Poll copy job status:

$> pfconclient http://localhost:30006/api/v1/ -a <token> poll --job_type copy --jid chris-jid-2

Submit a ds plugin job:

$> pfconclient http://localhost:30006/api/v1/ -a <token> submit --job_type plugin --jid chris-jid-2 --entrypoint python3 /usr/local/bin/simpledsapp --args '--prefix le' --auid cube --number_of_workers 1 --cpu_limit 1000 --memory_limit 200 --gpu_limit 0 --image fnndsc/pl-simpledsapp --type ds --input_dirs home/user/cube --output_dir home/user/cube_out

Poll plugin job status:

$> pfconclient http://localhost:30006/api/v1/ -a <token> poll --job_type plugin --jid chris-jid-2

Get plugin job status:

$> pfconclient http://localhost:30006/api/v1/ -a <token> status --job_type plugin --jid chris-jid-2

Delete a copy job’s container:

$> pfconclient http://localhost:30006/api/v1/ -a <token> delete --job_type copy --jid chris-jid-2

Delete a plugin job’s container:

$> pfconclient http://localhost:30006/api/v1/ -a <token> delete --job_type plugin --jid chris-jid-2

Submit a delete job:

$> pfconclient http://localhost:30006/api/v1/ -a <token> submit --job_type delete --jid chris-jid-2

Poll delete job status:

$> pfconclient http://localhost:30006/api/v1/ -a <token> poll --job_type delete --jid chris-jid-2

Delete a delete job’s container:

$> pfconclient http://localhost:30006/api/v1/ -a <token> delete --job_type delete --jid chris-jid-2

Visit the standalone CLI client wiki page to learn more about the CLI client.

Development and testing

Optionally setup a virtual environment

Install virtualenv and virtualenvwrapper using your OS package manager.

Create a directory for your virtual environments e.g.:

$> mkdir ~/Python_Envs

You might want to add the following lines to your .bashrc or .zshrc file:

VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
export WORKON_HOME=~/Python_Envs
source /usr/local/bin/virtualenvwrapper.sh

Then source the file and create a new Python3 virtual environment:

$> mkvirtualenv pfcon_client_env

To activate pfcon_client_env:

$> workon pfcon_client_env

To deactivate pfcon_client_env:

$> deactivate

Clone the repo

$> git clone https://github.com/FNNDSC/python-pfconclient.git

Run automated tests

$> cd python-pfconclient
$> workon pfcon_client_env
$> pip install -e ".[dev]"
$> pytest

Metadata

Release files for python-pfconclient 4.0.0

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

Source distribution (sdist)

Source distribution for python-pfconclient 4.0.0
File Size Uploaded
python_pfconclient-4.0.0.tar.gz 13.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-pfconclient 4.0.0
File Interpreter ABI Platform
python_pfconclient-4.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.8 kB

Release files / python_pfconclient-4.0.0.tar.gz

Download URL python_pfconclient-4.0.0.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
53bd125a47d1dfc00c29de57d3e1bd08bcf5efad78d7b9df0296458370cee4b1
BLAKE2b-256 checksum
How to use checksums
c3167a0b532f7eaceb29f65b88303a88c29eaa46f0bba475576d9acebf926838
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / python_pfconclient-4.0.0-py3-none-any.whl

Download URL python_pfconclient-4.0.0-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68651bfe30925754e6417e5d414ff767b059835cce5e622cea45afca40ad46ae
BLAKE2b-256 checksum
How to use checksums
552e846ddbcc6b8ffbe5c4cd79ffca560773ec9150508ac69a89b51c11e7643b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

4.0.0 This release

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.1.0

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