Skip to content

Example

Prefect flow example for rs-client-libraries

hello_world(name='COPERNICUS', tasks_number=2)

Example flow that can be use in a COPERNICUS chain

This prefect flow may be used as start point in creating your own prefect flows. It runs in parallel tasks_number of print_hello

Parameters:

Name Type Description Default
name str

Username to be printed. Default COPERNICUS

'COPERNICUS'
tasks_number int

Number of tasks to be run. Default 2

2
Source code in docs/rs-client-libraries/rs_workflows/example.py
31
32
33
34
35
36
37
38
39
40
41
42
43
@flow(name="Hello RS-Server flow ")
def hello_world(name="COPERNICUS", tasks_number=2):
    """Example flow that can be use in a COPERNICUS chain

    This prefect flow may be used as start point in creating your own prefect flows. It runs in parallel
    tasks_number of print_hello

    Args:
        name (str): Username to be printed. Default COPERNICUS
        tasks_number (int): Number of tasks to be run. Default 2
    """
    for idx in range(0, tasks_number):
        print_hello(name + "_" + str(idx))

print_hello(name)

Example task to be used in a prefect flow

This prefect task may be used as start point in creating your own prefect tasks

Parameters:

Name Type Description Default
name str

Username to be printed

required
Source code in docs/rs-client-libraries/rs_workflows/example.py
19
20
21
22
23
24
25
26
27
28
@task
def print_hello(name: str):
    """Example task to be used in a prefect flow

    This prefect task may be used as start point in creating your own prefect tasks

    Args:
        name (str): Username to be printed
    """
    print(f"Hello {name}!")