0

I have the following python structure

package
    ├── __init__.py
    ├── data
    │   ├── __init__.py
    │   ├── module_data1.py
    │   ├── module_data2.py
    │   ├── module_data3.py
    │   └── file.json
    └──  model
        ├── __init__.py
        ├── module_model1.py
        └── module_model2.py

and what I want is to make content of file.json available inside all data modules (module_data1, module_data2, module_data3). I have tried to read it inside data/__init__.py, but does not seem to be working or I do not know how to do it properly. Here is what I put into my data/__init__.py

## data/__init__.py

import json
with open("<path/to/file.json>", "r") as f:
    f = json.load(f)

But f is not available inside modules. Also I had to put <path/to/file.json> all the way from home/... and it would not work when I submit this package.zip to a dataproc job.

Ala Tarighati
  • 3,507
  • 5
  • 17
  • 34

0 Answers0