Skip to content
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

File extensions #684

Closed
mateusoliveira43 opened this issue Oct 8, 2022 · 6 comments · Fixed by #830
Closed

File extensions #684

mateusoliveira43 opened this issue Oct 8, 2022 · 6 comments · Fixed by #830
Assignees
Labels
ci tool-sharpening Related to the tools we use for the project

Comments

@mateusoliveira43
Copy link
Collaborator

Hi everyone 👋
Thanks for this awesome Project!

Pelorus have some files without extension. To get the list of files without extension, in the project root run

find . -type f ! -name "?*.*" | grep -v "venv/\|git/"

Some of them should not have extension (like .gitignore), but I believe the Python files should, for example. This leads to the project quality checks not checking files properly.

For example, running make black-check does not warn of any errors today. But if we change the name of the file scripts/bump-version to scripts/bump-version.py and run make black-check again, black indicates format errors.

@KevinMGranger
Copy link
Collaborator

I'm of the opinion that tools meant to be run directly (e.g. ./scripts/bump-version) should not have an extension. You don't run cat.elf, right?

But I did notice that our tools will skip files that don't have a .py, you're right. python3 -m this | sed -n 11p and whatnot :P

Side note: I think we might actually not use bump-version anymore, we should look into that.

@mateusoliveira43
Copy link
Collaborator Author

A suggestion would be to add the scripts to the path (this can be done with console scripts section in setup.cfg, setup.py or pyproject.toml and running pip install -e ./poetry install) then the extension does not appear (and neither the folder) when running the command.

An example https://github.com/mateusoliveira43/docky
if you git clone the repo and run docky (alias to scripts/docky.py), you will get a command not found error. But after running pip install -e ., docky would be available. The pip install -e . command could be added to $(PELORUS_VENV) command in makefile, to automatically adding the scripts to the path when configuring the development environment.

@KevinMGranger
Copy link
Collaborator

We can just add the extensions, I'm not a purist! I wouldn't mind setuptools integration eventually.

@mpryc
Copy link
Collaborator

mpryc commented Jan 24, 2023

Another approach to this is to have source files of the CLIs with extensions and link them to the CLIs executables without, so in our case, (example):

$ ls scripts/view-grafana-queries.py
scripts/view-grafana-queries.py

$ pushd scripts
$ mkdir src/
$ git mv scripts/view-grafana-queries.py scripts/src/
$ sed -i 's$../../charts/pelorus$../../../charts/pelorus$g' src/view-grafana-queries.py
$ ln -s ./src/view-grafana-queries.py ./view-grafana-queries

@KevinMGranger
Copy link
Collaborator

KevinMGranger commented Jan 24, 2023

Not a bad idea. setuptools gets us those in the virtualenv for free, though.

Essentially, in pyproject.toml, we would put:

[project.scripts]
view-grafana-queries = "pelorus_scripts.grafana:view_queries"

We'd have to slightly alter some of the scripts, and add a namespace manually to tools.setuptools.packages, but that shouldn't be too hard.

@KevinMGranger KevinMGranger self-assigned this Jan 24, 2023
@mpryc
Copy link
Collaborator

mpryc commented Jan 26, 2023

Related #479

@mateusoliveira43 mateusoliveira43 self-assigned this Jan 30, 2023
@mpryc mpryc added ci tool-sharpening Related to the tools we use for the project labels Feb 1, 2023
@mateusoliveira43 mateusoliveira43 moved this to 🏗 In progress in Boogie-Downs Apr 12, 2023
@mateusoliveira43 mateusoliveira43 moved this from 🏗 In progress to 👀 In review in Boogie-Downs Apr 14, 2023
@mateusoliveira43 mateusoliveira43 moved this from 👀 In review to ✅ Done in Boogie-Downs Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci tool-sharpening Related to the tools we use for the project
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants