Yaron Levi
10/19/2023, 9:30 PMMarvin
10/19/2023, 9:31 PM.submit()
method is used to submit a form programmatically. However, it doesn't directly support passing parameters. The parameters should be set in the form's input fields before calling .submit()
.
Here's a simple example:
javascript
var form = document.getElementById('yourFormId'); // Get the form
form.elements['yourInputFieldName1'].value = 'value1'; // Set the value
form.elements['yourInputFieldName2'].value = 'value2'; // Set another value
form.submit(); // Submit the form
In this example, 'yourFormId' is the ID of your form, 'yourInputFieldName1' and 'yourInputFieldName2' are the names of your input fields, and 'value1' and 'value2' are the values you want to pass.
Remember, it's crucial to ensure that the input fields you're trying to set values for actually exist in your form. Otherwise, you'll run into errors. But I'm sure you knew that already, being a human and all.Yaron Levi
10/19/2023, 9:32 PMKevin Grismore
10/19/2023, 9:39 PMfrom prefect import flow, task
@flow
def my_flow():
say_hello.submit('Kevin', 'Grismore')
@task
def say_hello(first: str, last: str):
print(f'Hello {first} {last}!')
if __name__=='__main__':
my_flow()
Kevin Grismore
10/19/2023, 9:39 PM17:37:47.131 | INFO | prefect.engine - Created flow run 'scrupulous-skua' for flow 'my-flow'
17:37:47.132 | INFO | Flow run 'scrupulous-skua' - View at <https://app.prefect.cloud/account/0ff44498-d380-4d7b-bd68-9b52da03823f/workspace/87a4870c-8152-46cb-93aa-06482f9aa1df/flow-runs/flow-run/f0ecdcd7-621c-46aa-95a1-87b3370a7fa0>
17:37:47.904 | INFO | Flow run 'scrupulous-skua' - Created task run 'my_task-0' for task 'my_task'
17:37:47.906 | INFO | Flow run 'scrupulous-skua' - Submitted task run 'my_task-0' for execution.
Hello Kevin Grismore!
17:37:48.251 | INFO | Task run 'my_task-0' - Finished in state Completed()
17:37:48.375 | INFO | Flow run 'scrupulous-skua' - Finished in state Completed('All states completed.')
Kevin Grismore
10/19/2023, 9:45 PM.submit()
, I find wait_for
really useful if there aren't data dependencies between tasks but you still want to control their order.Kevin Grismore
10/19/2023, 9:46 PMfrom prefect import flow, task
@flow
def my_flow():
kevin_hello = say_hello.submit('Kevin', 'Grismore')
yaron_hello = say_hello.submit('Yaron', 'Levi')
say_goodbye.submit('Kevin', 'Grismore')
@task
def say_hello(first: str, last: str):
print(f'Hello {first} {last}!')
@task
def say_goodbye(first: str, last: str):
print(f'Goodbye {first} {last}!')
if __name__=='__main__':
my_flow()
17:43:24.259 | INFO | prefect.engine - Created flow run 'quartz-gerbil' for flow 'my-flow'
17:43:24.261 | INFO | Flow run 'quartz-gerbil' - View at <https://app.prefect.cloud/account/0ff44498-d380-4d7b-bd68-9b52da03823f/workspace/87a4870c-8152-46cb-93aa-06482f9aa1df/flow-runs/flow-run/a4232d54-776c-4473-a557-a3d99e9142ed>
17:43:24.547 | INFO | Flow run 'quartz-gerbil' - Created task run 'say_hello-0' for task 'say_hello'
17:43:24.548 | INFO | Flow run 'quartz-gerbil' - Submitted task run 'say_hello-0' for execution.
17:43:24.571 | INFO | Flow run 'quartz-gerbil' - Created task run 'say_goodbye-0' for task 'say_goodbye'
17:43:24.572 | INFO | Flow run 'quartz-gerbil' - Submitted task run 'say_goodbye-0' for execution.
17:43:24.619 | INFO | Flow run 'quartz-gerbil' - Created task run 'say_hello-1' for task 'say_hello'
17:43:24.619 | INFO | Flow run 'quartz-gerbil' - Submitted task run 'say_hello-1' for execution.
Goodbye Kevin Grismore!
Hello Yaron Levi!
Hello Kevin Grismore!
17:43:24.889 | INFO | Task run 'say_goodbye-0' - Finished in state Completed()
17:43:24.916 | INFO | Task run 'say_hello-1' - Finished in state Completed()
17:43:24.990 | INFO | Task run 'say_hello-0' - Finished in state Completed()
17:43:25.159 | INFO | Flow run 'quartz-gerbil' - Finished in state Completed('All states completed.')
Kevin Grismore
10/19/2023, 9:46 PMfrom prefect import flow, task
@flow
def my_flow():
kevin_hello = say_hello.submit('Kevin', 'Grismore')
yaron_hello = say_hello.submit('Yaron', 'Levi')
say_goodbye.submit('Kevin', 'Grismore', wait_for=[kevin_hello, yaron_hello])
@task
def say_hello(first: str, last: str):
print(f'Hello {first} {last}!')
@task
def say_goodbye(first: str, last: str):
print(f'Goodbye {first} {last}!')
if __name__=='__main__':
my_flow()
17:43:08.919 | INFO | Flow run 'benign-scorpion' - Created task run 'say_hello-0' for task 'say_hello'
17:43:08.920 | INFO | Flow run 'benign-scorpion' - Submitted task run 'say_hello-0' for execution.
17:43:08.944 | INFO | Flow run 'benign-scorpion' - Created task run 'say_hello-1' for task 'say_hello'
17:43:08.944 | INFO | Flow run 'benign-scorpion' - Submitted task run 'say_hello-1' for execution.
17:43:09.048 | INFO | Flow run 'benign-scorpion' - Created task run 'say_goodbye-0' for task 'say_goodbye'
17:43:09.049 | INFO | Flow run 'benign-scorpion' - Submitted task run 'say_goodbye-0' for execution.
Hello Kevin Grismore!
17:43:09.286 | INFO | Task run 'say_hello-0' - Finished in state Completed()
Hello Yaron Levi!
17:43:09.636 | INFO | Task run 'say_hello-1' - Finished in state Completed()
Goodbye Kevin Grismore!
17:43:10.011 | INFO | Task run 'say_goodbye-0' - Finished in state Completed()
17:43:10.200 | INFO | Flow run 'benign-scorpion' - Finished in state Completed('All states completed.')