https://prefect.io logo
#prefect-community
Title
# prefect-community
g

Guilherme Petris

05/13/2022, 11:35 AM
Hey peeps! I’m currently trying it out some tests here to be ran with prefect cloud. When i’m using the flow.run() in my machine just using a LocalRun and Local storage, everything seems to run fine, but when i try to register the flow and run through the UI i get back the ModuleNotFoundError(“No module name ‘/Users/username’“). I’ve already searched for it’s solution back in the discourse page,(https://discourse.prefect.io/t/when-i-run-my-flow-i-see-an-error-failed-to-load-and-exe[…]derror-no-module-named-users-username-what-is-happening/33) but none of the solutions seems to work, even when i specify the module within the agent. The module that i’m using is in the same folder structure and everything seems to work when running directly from my IDE. Can’t figure it out what’s happening 🤔
a

Anna Geller

05/13/2022, 11:44 AM
what have you tried so far? can you share your code and how you register your flow?
can you share your
prefect diagnostics
?
g

Guilherme Petris

05/13/2022, 11:46 AM
Copy code
❯ prefect diagnostics
{
  "config_overrides": {
    "context": {
      "secrets": false
    }
  },
  "env_vars": [],
  "system_information": {
    "platform": "macOS-12.3.1-x86_64-i386-64bit",
    "prefect_backend": "cloud",
    "prefect_version": "1.2.1",
    "python_version": "3.9.10"
  }
}
was just testing easy stuff just to make sure that i could isolate and error if happens
Copy code
import pandas as pd
from zdesk import Zendesk
from prefect.client.secrets import Secret
import prefect
from prefect import task, Flow
import pyarrow as pa
import datetime 

from modules.snowflake_utils import SnowflakeBaseTask
from prefect.executors import LocalDaskExecutor
from prefect.run_configs import LocalRun
from prefect.storage import Local



sn = SnowflakeBaseTask()

# Credentials and connections
zpass = Secret('ZDESK_PASSWORD').get()

zendesk = Zendesk(
    zdesk_email = X
    zdesk_url = Y,
    zdesk_password = zpass,
    zdesk_token= True)


#INCREMENTAL CALL TICKETS

@task
def latest_date():
    latest_date = sn._find_latest_date(
        schema='ZENDESK',
        table='TICKETS',
        date_column='updated_at')
    return print(latest_date)


with Flow("Zendesk_incremental_test",
    run_config = LocalRun(working_dir="/Users/guilherme.petris/Scrive/python_scripts"),
    storage=Local(),
    executor=LocalDaskExecutor()
    ) as flow:

    latest_date()

flow.register("zendesk_project_test")
a

Anna Geller

05/13/2022, 11:51 AM
try removing the storage and run configuration entirely, then start your agent using:
Copy code
prefect agent local start -p /Users/guilherme.petris/Scrive/python_scripts
and then register this flow using CLI:
Copy code
prefect register --project xxx -p your_flow.py
this will use local storage as default, will attach your hostname as a label, and this way match with your local agent
g

Guilherme Petris

05/13/2022, 12:07 PM
This
-p your_flow.py
shouldn’t be the path?
a

Anna Geller

05/13/2022, 12:14 PM
this is the path
g

Guilherme Petris

05/13/2022, 12:39 PM
Ok, i’m getting a different error message now: State Message: Failed to load and execute flow run: ModuleNotFoundError(“No module named ‘modules’“) I already directed the path of this in the agent, but still doesn’t work
a

Anna Geller

05/13/2022, 12:45 PM
Maybe try building a package as suggested in the Discourse thread? Or add the module to your Python Path?
1
6 Views