Hey everyone! I am trying to integrate prefect wit...
# ask-community
a
Hey everyone! I am trying to integrate prefect with modal but my deployment does not seem to work I keep getting the following error.
Copy code
Failed due to a(n) NameError caused by accessing a local variable 'sb' without a value associated with it. Further investigation should focus on where 'sb' is defined and how it is being used in the context of the Prefect flow.
I think it's something to do with sandboxes. The invocations are popping up in the modal dashboard but without any logs: Has anyone experiences something similar before? Does anyone have any tips to assist?
1
n
hi @Antreas Pogiatzis - do you have logs in the prefect UI for the failed flow run? i assume this
Failed due to a(n) NameError caused by accessing a local variable 'sb' without a value associated with it. Further investigation should focus on where 'sb' is defined and how it is being used in the context of the Prefect flow.
is the flow run error summary, which suggests there's unbound variable issue in your code
does your flow run locally if you just run the python file?
a
Hello. Thank you for the response! Yes locally it runs. I am trying to do a minimal deployment with the following code:
Copy code
@flow
def hello_world():
    print("Hello World")

if __name__ == "__main__":
    deployment = hello_world.deploy(
        name="subdomain-discovery",
        work_pool_name="bb-modal-pool",
        image="<http://ghcr.io/apogiatzis/hello-image:latest|ghcr.io/apogiatzis/hello-image:latest>",
    )
is the flow run error summary, which suggests there's unbound variable issue in your code
This is the indeed the flow run error summary, but I don't see how that could have been triggered by the flow code. I am suspecting that something going on between prefect <-> modal integration
j
hey! can you share your workspace id? I think you're right something may be off in the integration
thank you 1
a
The docker image is pushed to a GitHub private registry if that makes any difference but I've set the credentials in modal
> hey! can you share your workspace id? I think you're right something may be off in the integration Hey there, here's my workspace id
bb92bb27-08a7-4055-b700-0166d86dfa7a
The only hint that makes me think that it's something to do with sandboxes is because I only found a reference of "sb" variable to the starter example in the Sandboxes tab
j
There does seem to be a bug in how the error is being surfaced, I can get a fix out for that. The error I'm seeing is that it looks like it's trying to resolve a secret that is named
""
Modal is a bit special where when you pass image as a job variable it needs to look like:
Copy code
image={"tag": "<http://ghcr.io/apogiatzis/hello-image:latest|ghcr.io/apogiatzis/hello-image:latest>", "secret": "<name of private registry creds in modal>"}}
your secret in modal needs to have the keys:
Copy code
REGISTRY_USERNAME: ...
REGISTRY_PASSWORD: ...
a
Thanks for looking into this! Although my deployment code looks like this:
Copy code
@flow
def hello_world():
    print("Hello World")

if __name__ == "__main__":
    deployment = hello_world.deploy(
        name="subdomain-discovery",
        work_pool_name="bb-modal-pool",
        image="<http://ghcr.io/apogiatzis/hello-image:latest|ghcr.io/apogiatzis/hello-image:latest>",
    )
I've manually updated my job variables from UI to look like the screenshot attached based on this. If I use the set the image as a dictionary in the python code deployment it raises an exception when building the image.
your secret in modal needs to have the keys:
```REGISTRY_USERNAME: ...
REGISTRY_PASSWORD: ...```
Yes I have this set. So If I understood correctly then my secret name is not being picked from the job variables?
j
oh I see, sorry yes I meant as
{job_variables={"image": ...}}
but it does look like you have that set
can you set the tag to the full url though, not just
latest
?
a
> The error I'm seeing is that it looks like it's trying to resolve a secret that is named
""
Could it possibly be referring to the secret in modal (My private registry credentials)?
can you set the tag to the full url though, not just
latest
?
I've tried already but I can try again, was just experimenting with different values
👍 1
j
you're not passing any other secrets to include in your image right? just the one to access the registry?
ah I see now:
Copy code
modal.exception.NotFoundError: Could not find secret: 'bb-modal-pool-modal-credentials'
a
can you set the tag to the full url though, not just
latest
?
Just tried again with the full image url as the
tag
value but I'm still get same result.
you're not passing any other secrets to include in your image right? just the one to access the registry?
I'm not passing any secrets explicitly to be honest. I was under the impression that modal will automatically pick up REGISTRY_USERNAME and REGISTRY_PASSWORD
Copy code
modal.exception.NotFoundError: Could not find secret: 'bb-modal-pool-modal-credentials'
Ohhh I think I get it now... I was passing in the name of my modal credentials block in prefect but I guess I need to pass the secret name in model for the registry credentials (
<http://ghcr.io|ghcr.io>
)
j
ahhh!!! yes I think that is exactly it
a
Still the same error 😅 Do you by any chance see a different error message now?
j
theres a space after
<http://ghcr.io|ghcr.io>
😅
apologies, this is the error that you should be seeing directly once I get this fix out
modal.exception.NotFoundError: Could not find secret: '<http://ghcr.io|ghcr.io> '.
a
Omg sorry 😅
apologies, this is the error that you should be seeing directly once I get this fix out
No worries thanks for looking into it!
Strangely, I am erasing the space, saving the job variables and the space it's still there !! 😄 😄
Okay it's been updated now 👍
Nope. Still getting the same problem 😅
But I can see the logs in modal now which suggest that it's a the first issue has been solved now. Thanks! thank you
🙌 2