Reputation: 593
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
Upvotes: 3
Views: 7927
Reputation: 87279
There are several aspects here.
%run ./config
to include notebook from the current directory (doc)__init__.py
, etc. In this case, you can use Python imports. Your repository directory will be automatically added into a sys.path
and you don't need to modify it.P.S. I have an example of repository with both notebooks & Python files approaches.
Upvotes: 5