pfcon http API call examples - FNNDSC/pfcon GitHub Wiki
pfcon http API call examples
Create a zip file in your local filesystem
mkdir -p /tmp/in
cd /tmp/in
echo "Test file" > test.txt
zip test.zip test.txt
Submit plugin for execution
Note: Usage here has been updated to support the change introduced in https://github.com/FNNDSC/pfcon/commit/49f545f179098982b547235194971e3be56390ef
Using HTTPie REST API client:
Get a JWT token from the server:
http POST http://localhost:30006/api/v1/auth-token/ pfcon_user=pfcon pfcon_password=pfcon1234
Submit fs
plugin for execution using the previous token and any local zip file:
http -f POST http://localhost:30006/api/v1/jobs/ args=--saveinputmeta args=--saveoutputmeta args=--dir args=cube/uploads args_path_flags=--dir auid=cube number_of_workers=1 cpu_limit=1000 memory_limit=200 gpu_limit=0 image=fnndsc/pl-simplefsapp entrypoint=python3 entrypoint=/usr/local/bin/simplefsapp type=fs jid=chris-jid-1 data_file@/tmp/in/test.zip "Authorization: Bearer <token>"
Submit ds
plugin for execution using any local zip file:
http -f POST http://localhost:30006/api/v1/jobs/ args=--saveinputmeta args=--saveoutputmeta args=--prefix args=lolo auid=cube number_of_workers=1 cpu_limit=1000 memory_limit=200 gpu_limit=0 image=fnndsc/pl-simpledsapp entrypoint=python3 entrypoint=/usr/local/bin/simpledsapp type=ds data_file@/tmp/in/test.zip jid=chris-jid-2
Using curl:
Get a JWT token from the server:
curl -H 'Content-Type: application/json' -X POST -d '{"pfcon_user": "pfcon", "pfcon_password": "pfcon1234"}' http://localhost:30006/api/v1/auth-token/
Submit fs
plugin for execution using any local zip file:
curl -H "Authorization: Bearer <token>" -F args=--saveinputmeta -F args=--saveoutputmeta -F args=--dir -F args=cube/uploads -F args_path_flags=--dir -F auid=cube -F number_of_workers=1 -F cpu_limit=1000 -F memory_limit=200 -F gpu_limit=0 -F image=fnndsc/pl-simplefsapp -F entrypoint=python3 -F entrypoint=/usr/local/bin/simplefsapp -F type=fs -F jid=chris-jid-1 -F data_file=@/tmp/in/test.zip http://localhost:30006/api/v1/jobs/
Submit ds
plugin for execution using any local zip file:
curl -H "Authorization: Bearer <token>" -F args=--saveinputmeta -F args=--saveoutputmeta -F args=--prefix -F args=lolo -F auid=cube -F number_of_workers=1 -F cpu_limit=1000 -F memory_limit=200 -F gpu_limit=0 -F image=fnndsc/pl-simpledsapp -F entrypoint=python3 -F entrypoint=/usr/local/bin/simpledsapp -F type=ds -F data_file=@/tmp/in/test.zip -F jid=chris-jid-2 http://localhost:30006/api/v1/jobs/
Arguments of type path
or unextpath
If a plugin's args
list contains flags with arguments of type path
or unextpath
then those flags should be included in the optional args_path_flags
list (as in the fs
plugin example above). This way pfcon
server will know that it has to substitute the local path specified by the flag by an actual path in the cloud.
Check on a plugin execution status
Using HTTPie REST API client:
http http://localhost:30006/api/v1/jobs/chris-jid-2/ "Authorization: Bearer <token>"
Using curl:
curl -H "Authorization: Bearer <token>" http://localhost:30006/api/v1/jobs/chris-jid-2/
Download the output files of a previously submitted plugin that has already finished
Using HTTPie REST API client:
http --download http://localhost:30006/api/v1/jobs/chris-jid-2/file/ "Authorization: Bearer <token>"
Using curl:
curl -H "Authorization: Bearer <token>" http://localhost:30006/api/v1/jobs/chris-jid-2/file/ --output file.zip
Delete a previously submitted plugin from the remote environment
Using HTTPie REST API client:
http delete http://localhost:30006/api/v1/jobs/chris-jid-2/ "Authorization: Bearer <token>"
Using curl:
curl -H "Authorization: Bearer <token>" -x "DELETE" http://localhost:30006/api/v1/jobs/chris-jid-2/