Pipeline file access within code #563
Answered
by
saul-data
crooktec-tannercrook
asked this question in
Q&A
|
When editing code in the pipeline there is a place where you can create files. Is there anyway to reference these files in the python script? I have a package that requires a json keyfile and it is the one thing that is blocking me from building that pipeline. |
Answered by
saul-data
Feb 8, 2023
Replies: 1 comment 2 replies
|
Hi @crooktec-tannercrook, if the json file is small, you could save the json file in code editor by simply creating a file. If it is a large json file, I'd recommend storing that file in a database like Postgresql or S3 and then pulling it from that storage. You should then reference that file using a relative path in your python code. import json
# Get scripts directory
import pathlib
jsonpath = pathlib.Path(__file__).parent.resolve()
print(jsonpath)
# Opening JSON file
f = open(str(jsonpath)+'/myjsonfile.json')
# returns JSON object as
# a dictionary
data = json.load(f)
print(data) |
2 replies
Answer selected by
saul-data
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment



Hi @crooktec-tannercrook, if the json file is small, you could save the json file in code editor by simply creating a file. If it is a large json file, I'd recommend storing that file in a database like Postgresql or S3 and then pulling it from that storage.
Here is an example:
You should then reference that file using a relative path in your python code.