Child pages
  • python api & client code (to discuss @ 3/9 dev meeting)

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepy
themeRDark
linenumberstrue
#!/usr/bin/env python3
 
from pathlib import Path
from tempfile import NamedTemporaryFile
 
from Pegasus.api import *
 
# --- Pegasus Properties -------------------------------------------------------
props = Properties()
props["pegasus.data.configuration"] = "condorio"
pegasus_conf_file = NamedTemporaryFile(mode="w+", buffering=1)
props.write()
 
# --- Sites --------------------------------------------------------------------
LOCAL = "local"
CONDORPOOL = "condorpool"
sc = SiteCatalog()\
        .add_sites(
            Site(CONDORPOOL, arch=Arch.X86_64, os_type=OS.LINUX)
                .add_pegasus(style="condor")
                .add_condor(universe="vanilla")
        )
 
# --- Replicas -----------------------------------------------------------------
input_file = File("input")
rc = ReplicaCatalog()\
        .add_replica(LOCAL, input_file, "file://" + str(TOP_DIR / "input"))
 
# --- Transformations ----------------------------------------------------------
tar = Transformation("tar", site=CONDOR_POOL, pfn="/usr/bin/tar", is_stageable=False)
 
tc = TransformationCatalog()\
        .add_transformations(tar)
 
# --- Workflow -----------------------------------------------------------------
output_file = File("output")
 
Workflow("compress", infer_dependencies=True)\
    .add_jobs(
        Job(tar)
            .add_args("-czvf", "arch.tar.gz", input_file)
            .add_inputs(input_file)
            .add_outputs(output_file)
    ).add_site_catalog(sc)\
    .add_replica_catalog(rc)\
    .add_transformation_catalog(tc)\
    .plan(               # call to plan will auto write wf to file with auto generated uuid() name
        conf=pegasus_conf_file.name,
        sites=CONDORPOOL,
        output_site=LOCAL,
        submit=True
    )
 
pegasus_conf_file.close()output_site=LOCAL, submit=True)\
	.wait()


'''[########------------------------------------------] 16.7% ..Running (Completed: 1, Queued: 0, Running: 2, Failed: 0)'''