Issue
This is my config.py in Databricks
DATA_S3_LOCATION='s3://server-data/data1'
DATA_S3_FILE_TYPE='orc'
DATA2_S3_LOCATION='s3://server-data/data2'
DATA2_S3_FILE_TYPE='orc'
I have init . py in this folder as well
I am trying to access these variables in another file
import sys
sys.path.insert(1,'/Users/file')
from file import config
I am facing error , no module named file
Solution
There are several aspects here.
- If these files are notebooks, then you need to use
%run ./config
to include notebook from the current directory (doc) - if you're using Databricks Repos and arbitrary files support is enabled, then your code needs to be a Python file, not notebook, and have correct directory layout with
__init__.py
, etc. In this case, you can use Python imports. Your repository directory will be automatically added into asys.path
and you don't need to modify it.
P.S. I have an example of repository with both notebooks & Python files approaches.
Answered By - Alex Ott Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.