0

I have a python script that reads the sql file from the same location. When I run it from kernal, the process works fine. However when I schedule and run it from Notebook jobs, it keeps failing with the error "FileNotFoundError Traceback (most recent call last) <ip, exit code: 1"

!pip install snowflake-connector-python
#!pip install snowflake-sqlalchemy
!pip install "snowflake-connector-python[pandas]"
!pip install keyring==23.11.0
!pip install snowflake-sqlalchemy==1.2.5
!pip install xgboost
!pip install shap
!pip install pgeocode
!pip install scikit-plot
pip install snowflake-sqlalchemy --upgrade


import snowflake.connector
import pandas as pd
from snowflake.sqlalchemy import URL
from sqlalchemy import create_engine

url = URL(
                 user=='************',
                 password='***************',
                 account='************',
                 database='************',
                 schema='************',
                 warehouse= '***********',
                 role = '***********')

engine = create_engine(url)
connection = engine.connect()

# Reading SQL Files
test_File = open('test.sql','r')
test_query = test_File.read()

df_test = pd.read_sql(test_query, connection)

df_test

When I run this, I get the error:

AlgorithmError: Error with executing notebook ++ sed 's|.|-|g; s|:|-|g; s|-*ipynb$|.ipynb|g;' ++ echo /opt/ml/output/data/TestSchedu-TestSchedu-2023-07-26T22:54:39.520Z-.ipynb Use Kernel python3 to execute Try_Sch.ipynb with output to /opt/ml/output/data/TestSchedu-TestSchedu-2023-07-26T22-54-39-520Z.ipynb. Params: {} Executing: 0%| | 0/8 [00:00<?, ?cell/s] Executing: 12%|█▎ | 1/8 [00:38<04:31, 38.84s/cell] Executing: 25%|██▌ | 2/8 [00:43<02:51, 28.59s/cell] Executing: 38%|███▊ | 3/8 [00:44<01:42, 20.42s/cell] Executing: 75%|███████▌ | 6/8 [00:45<00:28, 14.31s/cell] Executing: 75%|███████▌ | 6/8 [00:45<00:15, 7.61s/cell] Exception during processing notebook: --------------------------------------------------------------------------- Exception encountered at "In [6]": --------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) <ip, exit code: 1

VSN
  • 25
  • 5

0 Answers0