Package: python-pfconclient
A Python3 client for pfcon’s web API.OverviewThis repository provides a Python3 client for pfcon service’s web API.
The client provides both a Python programmatic interface and a standalone CLI tool calledpfconclient.Installation$>pipinstall-Upython-pfconclientpfcon server preconditionsThese preconditions are only necessary to be able to test the client against an actual instance of the pfcon server.Install latest DockerCurrently tested platforms:Ubuntu 18.04+ and MAC OS X 11.1+Note: On a Linux machine make sure to add your computer user to thedockergroup.
Consult this pagehttps://docs.docker.com/engine/install/linux-postinstall/Fire up the full set of pfcon servicesOpen a terminal and run the following commands in any working directory:$>gitclonehttps://github.com/FNNDSC/pfcon.git$>cdpfcon$>./make.shYou can later remove all the backend containers with:$>cdpfcon$>./unmake.shUsagePython programmatic interfaceInstantiate the client:frompfconclientimportclienttoken=client.Client.get_auth_token('http://localhost:30006/api/v1/auth-token/','pfcon','pfcon1234')cl=client.Client('http://localhost:30006/api/v1/',token)Runfsplugin until finished using any local input directory and get the resulting files in a local output directory:job_descriptors={'args':['--saveinputmeta','--saveoutputmeta','--dir','cube/uploads'],'args_path_flags':['--dir'],# list of flags with arguments of type 'path' or 'unextpath''auid':'cube','number_of_workers':1,'cpu_limit':1000,'memory_limit':200,'gpu_limit':0,'image':'fnndsc/pl-simplefsapp','entrypoint':['python3','/usr/local/bin/simplefsapp'],'type':'fs'}job_id='chris-jid-1'inputdir='/tmp/sbin/in'outputdir='/tmp/sbin/out/chris-jid-1'cl.run_job(job_id,job_descriptors,inputdir,outputdir)Rundsplugin 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={'args':['--saveinputmeta','--saveoutputmeta','--prefix','lolo'],'auid':'cube','number_of_workers':1,'cpu_limit':1000,'memory_limit':200,'gpu_limit':0,'image':'fnndsc/pl-simpledsapp','entrypoint':['python3','/usr/local/bin/simpledsapp'],'type':'ds'}job_id='chris-jid-2'inputdir='/tmp/sbin/out/chris-jid-1'outputdir='/tmp/sbin/out/chris-jid-2'cl.run_job(job_id,job_descriptors,inputdir,outputdir)Visit thePython programmatic interfacewiki page to learn more about the client’s programmatic API.Standalone CLI client toolGet and print auth token with theauthsubcommand:$>pfconclienthttp://localhost:30006/api/v1/auth--pfcon_userpfcon--pfcon_passwordpfcon1234Runfsplugin until finished using any local input directory and get the resulting files in a local output directory:$>pfconclienthttp://localhost:30006/api/v1/-a<token>run--jidchris-jid-3--args'--saveinputmeta --saveoutputmeta --dir cube/uploads'--args_path_flags='--dir'--auidcube--number_of_workers1--cpu_limit1000--memory_limit200--gpu_limit0--imagefnndsc/pl-simplefsapp--selfexecsimplefsapp--selfpath/usr/local/bin--execshellpython3--typefs/tmp/sbin/in/tmp/sbin/out/chris-jid-3Rundsplugin 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:$>pfconclienthttp://localhost:30006/api/v1/-a<token>run--jidchris-jid-4--args'--saveinputmeta --saveoutputmeta --prefix lolo'--auidcube--number_of_workers1--cpu_limit1000--memory_limit200--gpu_limit0--imagefnndsc/pl-simpledsapp--selfexecsimpledsapp--selfpath/usr/local/bin--execshellpython3--typeds/tmp/sbin/out/chris-jid-3/tmp/sbin/out/chris-jid-4Visit thestandalone CLI clientwiki page to learn more about the CLI client.Arguments of typepathorunextpathIf a plugin’sargslist contains flags with arguments of typepathorunextpaththen those flags should be included
in the optionalargs_path_flagslist. This string represents a list of flags. This waypfconserver will
know that it has to substitute the local path specified by the flag by an actual path in the cloud.Development and testingOptionally setup a virtual environmentInstallvirtualenvandvirtualenvwrapper$>pip3install-UvirtualenvvirtualenvwrapperCreate a directory for your virtual environments e.g.:$>mkdir~/Python_EnvsYou might want to add the following two lines to your.bashrcfile:exportWORKON_HOME=~/Python_Envssource/usr/local/bin/virtualenvwrapper.shThen source your.bashrcand create a new Python3 virtual environment:$>mkvirtualenv--python=python3pfcon_client_envTo activate pfcon_client_env:$>workonpfcon_client_envTo deactivate pfcon_client_env:$>deactivateClone the repo$>gitclonehttps://github.com/FNNDSC/python-pfconclient.git$>cdpython-pfconclient$>workonpfcon_client_envRun automated tests$>cdpython-pfconclient$>workonpfcon_client_env$>pipinstall-Unose$>pythonsetup.pynosetests