Message-ID: <404189549.9129.1711718815302.JavaMail.confluence@host3.pipelinefx.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_9128_2000696325.1711718815302" ------=_Part_9128_2000696325.1711718815302 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
To begin we will go through a simple job submission. In th= is example, we will submit a job that runs a single command (in this case, = the command "hostname") on one worker. This is the simplest= form of job submission.
#!/usr/bin/env python3 # Below are required imports for the script to run import os, sys # The next few lines attempt to import the Qube API. If the path to the qb = module # is not in $PATH or $PYTHONPATH, we will attempt to find it by looking in = known # locations try: import qb except ImportError: if os.environ.get("QBDIR"): qbdir_api =3D os.path.join(os.environ.get("QBDIR"),"= api","python") for api_path in (qbdir_api, "/Applications/pfx/qube/api/python/", "/usr/local/pfx/qube/api/python/", "C:\\Program Files\\pfx\\qube\\api\\python", "C:\\Program Files (x86)\\pfx\\qube\\api\\python&= quot;): if api_path not in sys.path and os.path.exists(api_path): sys.path.insert(0,api_path) try: import qb except: continue break # this should throw an exception if we've exhuasted all other possibili= ties import qb # Below is the main function to run in this script=20 def main(): =20 # Below creates an empty dictionary to be filled by the following lines= of code=20 job =3D {} =20 # Below defines the name of the Qube! job. This is the name that will = be=20 # displayed in the GUI and through the command line tools=20 job['name'] =3D 'python test job' =20 # Below defines how many Instances/subjobs the job is to spawn. Becaus= e we=20 # will be running only a single command, there is no need to request mo= re than 1. =20 job['cpus'] =3D 1 =20 # Below defines the internal Qube! jobtype to be used to execute the jo= b. # 'cmdline' tells Qube that on the backend, we will execute a single co= mmand line=20 # command. This will be the same as opening a terminal/command prompt = and typing # out a command. job['prototype'] =3D 'cmdline' =20 # The below parameters are explained further in the "Job submissio= n with job=20 # package explained" page package =3D {} package['cmdline'] =3D 'hostname' job['package'] =3D package =20 # Below creates an empty list filled by the following lines of code. listOfJobsToSubmit =3D [] =20 # Below evaluates the jobs to be submitted and adds the to the above li= st=20 listOfJobsToSubmit.append(job) =20 # Below calls the list of jobs to be submitted and then prints the job = IDs for each # While it is not strictly necessary that one submits a list of jobs, i= t is a good # habit to start, so we will only submit lists of jobs. It is, however= , perfectly # acceptable to qb.submit(job) listOfSubmittedJobs =3D qb.submit(listOfJobsToSubmit) for job in listOfSubmittedJobs: print(job['id']) # Below runs the "main" function=20 if __name__ =3D=3D "__main__": main() sys.exit(0)=20
This example and others like it can be found in:
C:\Program Files\pfx\qube\examples
=
span>/Application/pfx/qube=
/examples
/usr/local/pfx/qube/e=
xamples
Continue to Basic python job submission II. Frames