Thread
#prefect-community
    Alejandro Sanchez Losa

    Alejandro Sanchez Losa

    9 months ago
    I am trying to get the flow ID after register… is there any way ?
    Kevin Kho

    Kevin Kho

    9 months ago
    You can click the details tab
    Alejandro Sanchez Losa

    Alejandro Sanchez Losa

    9 months ago
    thanks !!! I mean trying do trough programming …
    Anna Geller

    Anna Geller

    9 months ago
    You can get it from the context:
    prefect.context.flow_id
    Alejandro Sanchez Losa

    Alejandro Sanchez Losa

    9 months ago
    thanks !!! let me check
    I looking for where I can call to context
    Anna Geller

    Anna Geller

    9 months ago
    in your task you can
    print(prefect.context.flow_id)
    Alejandro Sanchez Losa

    Alejandro Sanchez Losa

    9 months ago
    I though that … but does not work
    Anna Geller

    Anna Geller

    9 months ago
    you need to register the flow and run with a backend
    Kevin Kho

    Kevin Kho

    9 months ago
    Oh
    flow.register()
    will return the id.
    Alejandro Sanchez Losa

    Alejandro Sanchez Losa

    9 months ago
    yes but in a string human ready not to get that value
    Kevin Kho

    Kevin Kho

    9 months ago
    Could you give more details to what you are trying to do?
    Alejandro Sanchez Losa

    Alejandro Sanchez Losa

    9 months ago
    I need get the ID to use after in other process
    as I can see the register only returns string
    the idea is use the ID in other python process
    I found a solution
    its not elegant but it will be work for me …
    Kevin Kho

    Kevin Kho

    9 months ago
    I think what you’re saying is that you register a flow, and then you can get the flow id and plug it here, but the problem is that when you re-register, the version will change and you get a new flow id so this doesn’t work right? It might be easier for you to trigger the Flow by using project name and flow name. You can do this using the create_flow_run task, which will find the flow_id for you under the hood and start the flow run. To use
    create_flow_run
    in a script, just import it and call the
    .run()
    method.
    from prefect.tasks.prefect import create_flow_run
    create_flow_run.run(flow_name="flow", project_name="project")
    Alejandro Sanchez Losa

    Alejandro Sanchez Losa

    9 months ago
    I am trying to automate from github actions
    Kevin Kho

    Kevin Kho

    9 months ago
    If you want to stick to the Client, you can use the
    version_group_id
    instead which doesn’t change from registration to registration
    Alejandro Sanchez Losa

    Alejandro Sanchez Losa

    9 months ago
    umm I have to read that document
    @Kevin Kho your solution working better, is more elegant !!! and easy
    I apreciate
    Kevin Kho

    Kevin Kho

    9 months ago
    Of course!
    Alejandro Sanchez Losa

    Alejandro Sanchez Losa

    9 months ago
    thanks so much !!!
    now i get a nice error xD
    do you know why I get “No module named in /home/runner/” error ?
    Kevin Kho

    Kevin Kho

    9 months ago
    I think so. When you register a Flow, Prefect puts it in “Storage”. When a Flow Run is triggered, the Flow is retrieved from Storage and executed. The default is Local Storage which is on your machine so this error is when you register with Local Storage on machine A and try to run it on machine B, which doesn’t have the file
    Anna Geller

    Anna Geller

    9 months ago
    @Alejandro Sanchez Losa I think you don’t need to do any of this if the goal is to register your flow in CI. You only need to use “prefect register” CLI. Here is how I used it in CircleCI:
    version: 2
    jobs:
      build:
        docker:
          - image: prefecthq/prefect:latest-python3.9
        steps:
          - checkout  # checkout source code to working directory
          - run: pip install .
          - run: prefect auth login --key $PREFECT_API_KEY
          - run: export PREFECT__CLOUD__USE_LOCAL_SECRETS=false && prefect register --project yourprojectname -p flows/ # -p sets the directory to your flows that should be registered
    Alejandro Sanchez Losa

    Alejandro Sanchez Losa

    9 months ago
    thanks so much you all guys let me read and learn
    Anna Geller

    Anna Geller

    9 months ago
    with this: you don’t need any of this I meant using Client and calling create_flow_run from script 😄 you still need to specify storage, as Kevin explained it
    since you do CI already, a GitHub storage seems to be a good choice. If you need some examples, here is one for local agent
    Alejandro Sanchez Losa

    Alejandro Sanchez Losa

    9 months ago
    maybe I need a cloud store point …
    I have to read slowly that to understand
    thanks so much