<@ULVA73B9P> when triggering an action in an Autom...
# marvin-in-the-wild
j
@Marvin when triggering an action in an Automation, where can I get information about the available context for passing parameters? I need to pass the parameter of a Crashed flow into the parameters of the triggered action.
m
You can find information about context and passing parameters in Automations in the Prefect documentation. Here are some relevant details and links: 1. Automations Overview: - Triggers: Specify conditions under which actions are performed, e.g., flow run state changes, work pool status, metric thresholds, etc. - Actions: Define what your automation will do (e.g., canceling a flow, sending notifications). - Documentation Link: Automations - Prefect Docs 2. Flow Run Parameters: - Parameters are validated before a flow is run, and invalid parameters cause the flow to fail. - Documentation on parameters: Flows - Prefect Docs 3. Example GitHub Issue: - Issue discussing passing parameters in automations and custom webhook block usage. - GitHub Issue Link: CustomWebhook block type not found on Automation action For specific automation configurations: - You might want to register custom blocks or customization actions. Example commands and code can be found in the linked issue. It's a dull task, yes, but remember, even a brain the size of a planet can be helpful as long as it’s precise. If further specifics are needed, let me know!
j
@Marvin the document suggests that the context will contain "deployment.parameters". If the flow that triggered the automation has a parameter called "url", will I be able to access the url like "deployment.parameters.url", when running a new flow in the automation's action?
m
Yes, you should be able to access the parameters of the flow that triggered the automation using
deployment.parameters
. For example, if the flow has a parameter called
url
, you can access it as
deployment.parameters.url
when running a new flow in the automation's action. Relevant documentation and an example can be found here: - Automations - Prefect Docs In summary, within your automation's action, utilize
deployment.parameters.url
to retrieve the
url
parameter from the triggering flow. If you have further questions or need a more detailed example, I'm here to help!
j
@Marvin I tested this with a notificatino and the url in the notificatino is an empty string, instead of the original value from the flow that triggered the automation.
m
If the value is not being passed correctly, there may be some nuances or restrictions in the context propagation that need addressing. Let's verify with more documentation specifics, or consult with recent issues or examples related to this topic. I'll perform a thorough search to ensure we have covered all edge cases. Let's start. It appears there’s no definitive explanation or related issue from our searches. The relevant documents about Automations and parameter context were searched but didn't yield the exact answer. Here’s what you can try to ensure your
url
parameter is properly accessed in the automation’s action: 1. Verify Parameter Passing: - Ensure that your flow's
url
parameter is correctly set and can be accessed within the flow itself. - Double-check the parameter's name in the triggering flow and ensure it matches exactly when accessed in the automation. 2. Debugging the Context: - Add a logging step or intermediate action to output the context being passed to the automation. This would help in verifying if
deployment.parameters.url
holds the expected value. 3. Simplified Example: - Test with a minimal, simplified flow and automation setup to isolate the issue:
Copy code
python
      # Flow with a parameter called `url`
      from prefect import flow, task

      @task
      def print_url(url):
          print(f"The URL is: {url}")

      @flow
      def example_flow(url: str):
          print_url(url)
Copy code
python
      # Automation action script to trigger a notification with the URL parameter
      from prefect import flow

      @flow
      def notification_flow_dependent_on_parameter():
          context = prefect.context.get_run_context().parameters
          url = context.get("url", "default_url")
          print(f"Triggering notification with URL: {url}")

      # Register automation action
4. Ensure Correct Syntax and Context:
Copy code
yaml
    # Example snippet for deployment.yaml
    parameters:
      url: "<https://example.com>"

    # Ensuring parameters are accessible
If these steps don't resolve the issue, the fault may lie deeper within the automation's context handling. For further precision, you may consider: - Reaching out on Prefect’s official forums or Slack community. - Reviewing the latest updates in Prefect's documentation or release notes. But above all, stay positive—eventually, you'll get it working. If you need more precise examples or have further questions, let me know!