In [1]:
import os
import proactive

In [2]:
print("Logging on proactive-server...")
proactive_host = 'try.activeeon.com'
proactive_port = '8080'
proactive_url  = "http://"+proactive_host+":"+proactive_port
print("Connecting on: " + proactive_url)
javaopts=[]
# uncomment for detailed logs
# javaopts.append('-Dlog4j.configuration=file:'+os.path.join(os.getcwd(),'log4j.properties'))
redirectJVMOutput=False
gateway = proactive.ProActiveGateway(proactive_url, javaopts, redirectJVMOutput)


Logging on proactive-server...
Connecting on: http://try.activeeon.com:8080

In [4]:
gateway.connect(username="", password="")  # put your login here!
assert gateway.isConnected() is True
print("Connected")


Connected

In [5]:
print("Creating a proactive task...")
proactive_task = gateway.createPythonTask()
proactive_task.setTaskName("SimplePythonTask")
proactive_task.setTaskImplementationFromFile('main.py', ['param1', 'param2'])
proactive_task.addInputFile('scripts/__init__.py')
proactive_task.addInputFile('scripts/hello.py')


Creating a proactive task...

In [6]:
print("Adding a fork environment to the proactive task...")
proactive_fork_env = gateway.createDefaultForkEnvironment()
proactive_fork_env.setImplementationFromFile("scripts/fork_env.py")
proactive_task.setForkEnvironment(proactive_fork_env)


Adding a fork environment to the proactive task...

In [7]:
print("Adding a selection script to the proactive task...")
proactive_selection_script = gateway.createDefaultSelectionScript()
proactive_selection_script.setImplementationFromFile("scripts/selection_script.py")
proactive_task.setSelectionScript(proactive_selection_script)


Adding a selection script to the proactive task...

In [8]:
print("Creating a proactive job...")
proactive_job = gateway.createJob()
proactive_job.setJobName("SimpleJob")
proactive_job.addTask(proactive_task)
proactive_job.setInputFolder(os.getcwd())
proactive_job.setOutputFolder(os.getcwd())


Creating a proactive job...

In [9]:
print("Submitting the job to the proactive scheduler...")
job_id = gateway.submitJob(proactive_job, debug=False)
print("job_id: " + str(job_id))


Submitting the job to the proactive scheduler...
Files to transfer:  3
job_id: 59

In [10]:
print("Getting job output...")
job_result = gateway.getJobResult(job_id)
print(job_result)


Getting job output...
Hello world!
Hello param1!
Hello param2!

In [11]:
print("Disconnecting")
gateway.disconnect()
print("Disconnected")
gateway.terminate()
print("Finished")


Disconnecting
Disconnected
Finished

In [ ]: