-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python modifications #111
base: main
Are you sure you want to change the base?
Python modifications #111
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome work @gorimaaa ! and you even went ahead and published the package 🚀
i added couple of comments, feel free to merge this PR now and address them in a separate follow-up PR if you want
thanks again for the PR i'm learning Python along with you now 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to commit this file (and also kulya_python-1.6-py3-none-any.whl
) ?
ideally we want to generate them and publish them in a Github CI Action
if they are not mandatory to be committed, then let's remove them for now, and worry about publishing the package in a follow-up PR.
Issues = "https://github.com/dzcode-io/kuliya/issues" | ||
|
||
[tool.hatch.build.targets.wheel] | ||
only-include = ["src/kulya_python", "data"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "data"
folder here is only used during build time right? and not actually published as part of the package code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also not commit this file? and generate it on the fly in CI? and also locally when you build the package
self.nameAr = nameAr | ||
self.nameEn = nameEn | ||
self.nameFr = nameFr | ||
self.univ = univ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we have .univ
field?
def getNameFr(self): | ||
return self.nameFr | ||
|
||
def getUniv(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we have getUniv
method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we not commit the __pycache__
folder?
Essientially, it converts the JSON data into a Node object. | ||
""" | ||
def getNodeByPath(path: str) -> Node: | ||
if DEVELOPMENT_MODE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is clever, but generally we want to avoid bloating our package with files it does not need. for instance, a consumer of this package will never use directoryToOneJsonFile
but they will still download this piece of code regardless, which is not ideal.
an alternative solution is, move the directoryToOneJsonFile
to a seperate non-published directory (eg: src/build/utils.py
) and then:
- in development, you would need to run this in watch mode (it watches
../data
for changes and re-run, maybe usingnodemon
) - in CI, we run this once before publishing the package (to prepare the json once)
think of it more or less like the JS implementation where we have a script that prepares the data.json
targetFile.write(file.read()) | ||
targetFile.write(",") | ||
file.close() | ||
targetFile.write('"":{}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
writing the json format by hand is error prune, maybe we can use a more rebust solution by using the existing json module, where:
- we would have a local jsonData variable as an empty array, that we then add nodes into
- then we json.dump it to targetFile
this way we guarantee we have a valid and escaped json file, and as a bonus we have a nice formatted file ;)
Description
Following #109 #109
I added the modifications as asked :
If there is any error left, or misunderstanding from my side please let me know.
Type of change
Please delete options that are not relevant.