How can I simplify reading JSON files? #1321
Unanswered
mikhail-putilov
asked this question in
Q&A
Replies: 1 comment 2 replies
-
|
It seems that Might look a bit strange, but since you also import utils from one level up, maybe it's okay... 🤔 🤷♂️ |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I've been trying to externalize commonly repeated code into a utils file:
./utils.pkl:
./main.pkl:
./sample.json:
{ "text": "Hello, world!" }It works as long as all files are in the same directory. When I move
main.pklandsample.jsoninto a subfolder dedicated to an environment./prod/, then it breaks. I suspect this is because of lazy evaluation ofread.As a solution, I found that I can pass
Resourceintorequirelike this:./utils.pkl:
./prod/main.pkl:
./prod/sample.json:
{ "text": "Hello, world!" }Is there anything I am missing? I wanted to have utility functions to simplify reading external sources, but I always need to remember that I must call
readbefore :-)Beta Was this translation helpful? Give feedback.
All reactions