Python programmatic interface
The pfconclient
package provides a client
module with eight main methods among others:
-
run_job
: Run plugin until finished and get the resulting files in a local directory -
submit_job
: Submit plugin for execution and return without waiting for the plugin to finish -
poll_job_status
: Keep polling for the execution status of a previously submitted plugin until it finishes -
get_job_status
: Perform a single check on the execution status of a previously submitted plugin -
get_job_zip_data
: Download the output files of a previously submitted plugin that has already finished as a single zip file and return the content of the zip file -
get_job_zip_file
: Download the output files of a previously submitted plugin that has already finished as a single zip file and save the file into a local directory -
get_job_files
: Download the output files of a previously submitted plugin that has already finished as a single zip file and unpack the zip file's content files within a local directory -
delete_job
: Delete a previously submitted plugin
from pfconclient import client
token = client.Client.get_auth_token('http://localhost:30006/api/v1/auth-token/', 'pfcon', 'pfcon1234')
cl = client.Client('http://localhost:30006/api/v1/', token)
Run fs
plugin until finished using any local input directory and get the resulting files in a local output directory:
job_descriptors = {
'cmd_args': '--saveinputmeta --saveoutputmeta --dir cube/uploads',
'cmd_path_flags': '--dir', # flags with arguments of type 'path' or 'unextpath' should be specified here separated by comma
'auid': 'cube',
'number_of_workers': 1,
'cpu_limit': 1000,
'memory_limit': 200,
'gpu_limit': 0,
'image': 'fnndsc/pl-simplefsapp',
'selfexec': 'simplefsapp',
'selfpath': '/usr/local/bin',
'execshell': 'python3',
'type': 'fs'
}
job_id = 'chris-jid-20'
inputdir = '/tmp/sbin/in'
outputdir = '/tmp/sbin/out/chris-jid-20'
cl.run_job(job_id, job_descriptors, inputdir, outputdir)
Run ds
plugin until finished using the local output directory of a previous plugin as its input directory and get the resulting files in a local output directory:
job_descriptors = {
'cmd_args': '--saveinputmeta --saveoutputmeta --prefix lolo',
'auid': 'cube',
'number_of_workers': 1,
'cpu_limit': 1000,
'memory_limit': 200,
'gpu_limit': 0,
'image': 'fnndsc/pl-simpledsapp',
'selfexec': 'simpledsapp',
'selfpath': '/usr/local/bin',
'execshell': 'python3',
'type': 'ds'
}
job_id = 'chris-jid-21'
inputdir = '/tmp/sbin/out/chris-jid-20'
outputdir = '/tmp/sbin/out/chris-jid-21'
cl.run_job(job_id, job_descriptors, inputdir, outputdir)
Submit fs
plugin for execution using any local input directory and return without waiting for the plugin to finish:
job_descriptors = {
'cmd_args': '--saveinputmeta --saveoutputmeta --dir cube/uploads',
'cmd_path_flags': '--dir', # flags with arguments of type 'path' or 'unextpath' should be specified here separated by comma
'auid': 'cube',
'number_of_workers': 1,
'cpu_limit': 1000,
'memory_limit': 200,
'gpu_limit': 0,
'image': 'fnndsc/pl-simplefsapp',
'selfexec': 'simplefsapp',
'selfpath': '/usr/local/bin',
'execshell': 'python3',
'type': 'fs'
}
job_id = 'chris-jid-22'
inputdir = '/tmp/sbin/in'
cl.submit_job(job_id, job_descriptors, inputdir)
Submit ds
plugin for execution using the local output directory of a previously finished plugin as its input directory and return without waiting for the plugin to finish:
job_descriptors = {
'cmd_args': '--saveinputmeta --saveoutputmeta --prefix lolo',
'auid': 'cube',
'number_of_workers': 1,
'cpu_limit': 1000,
'memory_limit': 200,
'gpu_limit': 0,
'image': 'fnndsc/pl-simpledsapp',
'selfexec': 'simpledsapp',
'selfpath': '/usr/local/bin',
'execshell': 'python3',
'type': 'ds'
}
job_id = 'chris-jid-23'
inputdir = '/tmp/sbin/out/chris-jid-20'
cl.submit_job(job_id, job_descriptors, inputdir)
Keep polling for the execution status of a previously submitted plugin until it finishes:
job_id = 'chris-jid-22'
l_status = cl.poll_job_status(job_id)
Perform a single check on the execution status of a previously submitted plugin:
job_id = 'chris-jid-23'
l_status = cl.get_job_status(job_id)
Get a job's zip file byte content:
job_id = 'chris-jid-22'
zip_content = cl.get_job_zip_data(job_id)
Get and save a job's zip file into a local directory:
job_id = 'chris-jid-23'
local_dir = '/tmp/sbin/out/chris-jid-23'
cl.get_job_zip_file(job_id)
Get a job's output files unpacked within a local directory:
job_id = 'chris-jid-23'
local_dir = '/tmp/sbin/out/chris-jid-23'
cl.get_job_files(job_id)
Delete a previously submitted plugin:
job_id = 'chris-jid-23'
cl.delete_job(job_id)