This repository hosts the ProActive Python Client and its examples, enabling seamless interaction with the ProActive Scheduler and Resource Manager for automating workflow submission and management tasks directly from Python scripts.
proactive-python-client
: Contains the source code for the ProActive Python Client (SDK), facilitating the integration with the ProActive Scheduler. This SDK allows you to connect, submit jobs, manage tasks, and handle data spaces directly through Python.proactive-python-client-examples
: A collection of examples demonstrating various features and capabilities of the ProActive Python Client. These examples serve as a practical guide to get started with the SDK.
- Python version 3.5 or later.
- Java 8 or 11.
- Access to a ProActive Scheduler instance.
You can install the ProActive Python Client directly from PyPI using pip:
pip install --upgrade proactive
For the latest features and bug fixes, you can also install directly from this repository:
pip install --upgrade --pre proactive
The Proactive Python SDK provides a convenient way to create and submit jobs to the ProActive Scheduler. Here's a step-by-step guide:
from proactive import getProActiveGateway
gateway = getProActiveGateway()
This function automatically looks for a .env
file with your ProActive credentials. If it doesn't exist, it will prompt you to enter the server URL, username, and password.
job = gateway.createJob("MyJobName")
Replace "MyJobName" with the desired name for your job.
You can add various types of tasks to your job using the gateway.createTask or gateway.createPythonTask methods. Here's an example of adding a Python task:
task = gateway.createPythonTask("MyTaskName")
task.setTaskImplementation("print('Hello from ProActive!')")
job.addTask(task)
- Variables: You can add job-level or task-level variables using
job.addVariable
andtask.addVariable
. - Dependencies: Set dependencies between tasks using
task.addDependency
. - Fork Environment: Configure the execution environment using
task.setForkEnvironment
. - Selection Script: Control where the task runs using
task.setSelectionScript
. - Pre or Post scripts: Add scripts that will run before and after the task execution using
task.setPreScript
ortask.setPostScript
.
job_id = gateway.submitJob(job)
This submits the job to the ProActive Scheduler and returns the job ID for tracking.
You can monitor the job status using gateway.getJobStatus(job_id)
and retrieve the job output using gateway.getJobOutput(job_id)
.
gateway.close()
This disconnects from the ProActive server and cleans up resources.
Remember to replace the placeholders with your actual job and task names, and customize the task implementation with your desired Python code.
For more detailed examples and advanced features, refer to the Proactive Python Client documentation and the examples repository mentioned in the provided text.
Connecting to a ProActive Scheduler and submitting a simple job:
from proactive import ProActiveGateway
gateway = ProActiveGateway('https://try.activeeon.com:8443')
gateway.connect(username='admin', password='admin')
# Creating a ProActive job
job = gateway.createJob()
job.setJobName("SimpleJob")
# Creating a Python task
task = gateway.createPythonTask()
task.setTaskName("SimpleTask")
task.setTaskImplementation("""
print('Hello from ProActive!')
""")
# Adding the task to the job and submitting the job
job.addTask(task)
jobId = gateway.submitJob(job)
print(f"Job submitted with id {jobId}")
# Disconnecting
gateway.close()
For full documentation of the ProActive Python Client, visit our documentation site.
For detailed examples, check the proactive-python-client-examples
directory. Each example demonstrates different features and use cases of the ProActive Python Client.
Contributions to both the SDK and the examples are welcome. Please refer to the README files in the respective directories for more information on contributing.