Execution#

Submit a Job#

After constructing the LogicalPlan, you can use the JobManager to create a Job in the cluster to execute it. However, in most cases, you only need to use the Driver as the entry point of the entire script and then submit the plan. The Driver is a simple wrapper around the JobManager. It reads the configuration from the command line arguments and passes it to the JobManager.

from smallpond.execution.driver import Driver

if __name__ == "__main__":
   driver = Driver()
   # add your own arguments
   driver.add_argument("-i", "--input_paths", nargs="+")
   driver.add_argument("-n", "--npartitions", type=int, default=10)
   # build and run logical plan
   plan = my_pipeline(**driver.get_arguments())
   driver.run(plan)

Driver()

A helper class that includes boilerplate code to execute a logical plan.

JobManager([data_root, python_venv, ...])

Scheduler and Executor#

Scheduler and Executor are lower-level APIs. They are directly responsible for scheduling and executing tasks, respectively. Generally, users do not need to use them directly.

Scheduler(exec_plan[, max_retry_count, ...])

The task scheduler.

Executor(ctx, id, wq, cq)

The task executor.

Customize Platform#

Smallpond supports user-defined task execution platforms. A Platform includes methods for submitting jobs and a series of default configurations. By default, smallpond automatically detects the current environment and selects the most suitable platform. If it cannot detect one, it uses the default platform.

You can specify a built-in platform via parameters:

# run with your platform
python script.py --platform mpi

Or implement your own Platform class:

# path/to/my/platform.py
from smallpond.platform import Platform

class MyPlatform(Platform):
   def start_job(self, ...) -> List[str]:
      ...
# run with your platform
# if using Driver
python script.py --platform path.to.my.platform

# if using smallpond.init
SP_PLATFORM=path.to.my.platform python script.py

Platform()

Base class for all platforms.

MPI()

MPI platform.