Salohy
05/11/2021, 9:00 AMprefect.tasks.sql_server
requires Prefect to be installed with the "sql_server" extra`.
I am using, docker for storage using a docker file as explained here. My code looks like this
from prefect.tasks.sql_server import SqlServerExecute
STORAGE = Docker(registry_url="<http://xxx.azurecr.io|xxx.azurecr.io>",
image_name="prefect/test",
dockerfile="Dockerfile",
python_dependencies=["pyodbc"])
SQL = SqlServerExecute(db_name="myDb",
user="user",
host="<tcp:xxx.database.windows.net>",
port=1433,
driver="ODBC Driver 17 for SQL Server")
QUERY = """
CREATE TABLE [dbo].[myTable] (
[id] VARCHAR(22) COLLATE Latin1_General_100_BIN2 NOT NULL,
[FirstName] VARCHAR(222) NULL,
[LastName] VARCHAR(222) NULL
)
"""
@task
def create_table():
logger = prefect.context.get('logger')
<http://logger.info|logger.info>("Create table in DW for loading the results")
SQL.run(query=QUERY, password='myPass')
with Flow("candidates-flow", storage=STORAGE, run_config=RUN_CONFIG, executor=EXECUTOR) as flow:
create_table()
Can someone help? I do not understand the error. Many thanks already 🙏Salohy
05/11/2021, 10:28 AMModuleNotFoundError: No module named 'pyodbc'
, which I do not really understand since I am already adding pyodbc in python_dependencies and the dockerfile already customised to used this. Looks like pyodbc is not get intsalled 😕Kevin Kho
Salohy
05/11/2021, 1:40 PMSalohy
05/11/2021, 1:40 PMSalohy
05/11/2021, 1:41 PMKevin Kho
pyodbc
. Can you try passing it in?Kevin Kho
Salohy
05/11/2021, 1:53 PMKevin Kho
Salohy
05/11/2021, 1:57 PMKevin Kho
IfNotPresent
by default so it doesn’t update the image because it sees one locally with that name. You want to change this to Always
. This PR may help you: https://github.com/PrefectHQ/prefect/pull/4445/filesSalohy
05/11/2021, 2:46 PMModuleNotFoundError: No module named 'pyodbc'
Kevin Kho
Salohy
05/11/2021, 3:18 PM[2021-05-11 15:15:06,631] INFO - agent | Found 1 flow run(s) to submit for execution.
INFO:agent:Found 1 flow run(s) to submit for execution.
INFO:agent:Deploying flow run 79c0af83-ffd1-4b09-ae26-e34f8a0ebd88
[2021-05-11 15:15:06,819] INFO - agent | Deploying flow run 79c0af83-ffd1-4b09-ae26-e34f8a0ebd88
And When I describe the pod of the job I get
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 18s default-scheduler Successfully assigned default/prefect-job-15fad83d-54hg7 to aks-agentpool-47953602-vmss000000
Normal Pulling 17s kubelet Pulling image "<http://xxx.azurecr.io/prefect/kn-candidate:latest|xxx.azurecr.io/prefect/kn-candidate:latest>"
Normal Pulled 16s kubelet Successfully pulled image "<http://dexter.azurecr.io/prefect/kn-candidate:latest|dexter.azurecr.io/prefect/kn-candidate:latest>" in 1.002010051s
Normal Created 16s kubelet Created container flow
Normal Started 16s kubelet Started container flow
Kevin Kho
Salohy
05/11/2021, 3:24 PMTraceback (most recent call last):
File "/opt/conda/lib/python3.8/site-packages/distributed/worker.py", line 2632, in _maybe_deserialize_task
function, args, kwargs = _deserialize(*ts.runspec)
File "/opt/conda/lib/python3.8/site-packages/distributed/worker.py", line 3488, in _deserialize
kwargs = pickle.loads(kwargs)
File "/opt/conda/lib/python3.8/site-packages/distributed/protocol/pickle.py", line 75, in loads
return pickle.loads(x)
File "/opt/conda/lib/python3.8/site-packages/cloudpickle/cloudpickle.py", line 562, in subimport
__import__(name)
ModuleNotFoundError: No module named 'pyodbc'
The logs in prefect cloud has the same outputKevin Kho
Salohy
05/11/2021, 3:28 PMKevin Kho
Kevin Kho
Salohy
05/11/2021, 3:30 PMSalohy
05/11/2021, 4:12 PMKevin Kho