Thread
#prefect-community
    Madison Schott

    Madison Schott

    1 year ago
    Hi, I am getting this error when trying to start my local agent. I've already authenticated using my token in the cli.
    RuntimeError: Error while contacting API at <https://api.prefect.io>
    m

    Mariia Kerimova

    1 year ago
    Hello Medison! What version of Prefect are you using? Can you set this environment variable
    export PREFECT__CLOUD__AGENT__LEVEL=DEBUG
    and run the agent again?
    Madison Schott

    Madison Schott

    1 year ago
    How do I check the version using cli?
    When I set that I get same error and it doesn't tell me version
    m

    Mariia Kerimova

    1 year ago
    Can you run
    prefect version
    ?
    Madison Schott

    Madison Schott

    1 year ago
    0.14.22
    m

    Mariia Kerimova

    1 year ago
    and
    prefect diagnostics
    please?
    Madison Schott

    Madison Schott

    1 year ago
    {
      "config_overrides": {},
      "env_vars": [
        "PREFECT__CLOUD__AGENT__LEVEL"
      ],
      "system_information": {
        "platform": "macOS-10.15.7-x86_64-i386-64bit",
        "prefect_backend": "cloud",
        "prefect_version": "0.14.22",
        "python_version": "3.9.6"
      }
    }
    m

    Mariia Kerimova

    1 year ago
    Can you upgrade prefect
    pip install --upgrade prefect
    and run your agent with service account key
    prefect agent local start -k <your service account key>
    Madison Schott

    Madison Schott

    1 year ago
    That works but I did update the flow I was running and added another and I am not seeing the changes reflected on UI
    How can I update the flow with the most recent code?
    I also changed file paths, not sure if that affects things
    m

    Mariia Kerimova

    1 year ago
    I'm glad that worked. As I understand, you updated the code for the flow, then you registered a new version of this flow with Prefect Cloud by
    python <file_with_flow>.py
    , right? Can you check in flow dashboard in UI that a new version of the flow showed up? It's in the top right corner
    Madison Schott

    Madison Schott

    1 year ago
    Ah no I didn’t
    That’s probably the issue, I just ran the agent right away
    I just use that command to register it?
    m

    Mariia Kerimova

    1 year ago
    I see, so register will reregister the flow if you change the flow metadata, but if you for example made a little change in the code of the task, you need to force reregistering by:
    prefect register --force ...
    Madison Schott

    Madison Schott

    1 year ago
    And then the name of the flow?
    what about deleting a flow?
    m

    Mariia Kerimova

    1 year ago
    yeah, you can run like this for example:
    prefect register --path flow.py --project my-project --force
    There are different ways to delete flow, you can do it in UI (flow dashboard), or interactive API (also UI, but using graphql query), or programmatically using graphql too
    Madison Schott

    Madison Schott

    1 year ago
    Got it- one last question. I ahve another flow that I've registered in my file using the below command but it doesn't show up on the UI. Do I need to also use the run command for it to show up on the UI?
    web_sessions_flow.register(project_name="Winc")
    m

    Mariia Kerimova

    1 year ago
    Yes, every time you write a flow, you need to register it with backend, in this case you can simply run that command, and it should show up in UI 👍
    Madison Schott

    Madison Schott

    1 year ago
    Hmm for some reason is it still not showing up on UI even after registering it
    m

    Mariia Kerimova

    1 year ago
    Hmm, interesting 🤔 do you see any flow URL/id after you run register command?
    did you use
    --force
    flag with that command?
    Madison Schott

    Madison Schott

    1 year ago
    Yeah I did
    I run the register command on the UI? It’s in the file
    m

    Mariia Kerimova

    1 year ago
    You have a flow with
    web_sessions_flow.register(project_name="Winc")
    line saved in the file <name_of_the_file>.py and you ran
    prefect register --project XXX --path <name_of_the_file>.py --force
    and it doesn't show up in the UI, right? Can you try to run
    python <name_of_the_file>.py
    and check if the flow is in UI now?
    Madison Schott

    Madison Schott

    1 year ago
    still nothing
    the version of the other flow I have just keeps changing
    do they have to be in seperate files?
    right now both flows are in the same file
    m

    Mariia Kerimova

    1 year ago
    Yes, can you add those flows in separate files, and try to register again, and let me know if it still doesn't show up in UI?
    Madison Schott

    Madison Schott

    1 year ago
    now it is working
    so is it best practices to create a file per flow?
    it just seems kinda redundant since I reuse the same code a lot
    m

    Mariia Kerimova

    1 year ago
    You actually can use imports, multiple flows, not sure why it didn't work for you. You can paste redacted flows here, and I can take a look
    Madison Schott

    Madison Schott

    1 year ago
    Also how do I make it so every time I run my flow it doesn't start a new local agent? Everytime I just try to update the code it starts a local agent
    m

    Mariia Kerimova

    1 year ago
    I guess you have a code block somewhere which starts a local agent, can you remove/comment it?
    Madison Schott

    Madison Schott

    1 year ago
    Ah ok, so the
    .run_agent
    with the token id creates a local agent every time it is ran?
    How do I register a flow with my ecs agent?
    m

    Mariia Kerimova

    1 year ago
    yeah, it starts a new process with the agent
    you can do it using different approaches. The easiest way is to spin up the ecs agent and create the flow with ECS run_config, and then use the command we discussed above (
    prefect register ...
    or
    python <file>.py
    )