chaiNNer-org / spandrel

Spandrel gives your project support for various PyTorch architectures meant for AI Super-Resolution, restoration, and inpainting. Based on the model support implemented in chaiNNer.
MIT License
139 stars 12 forks source link

scripts: avoid `sys.path` hacks; simplify #105

Closed akx closed 9 months ago

akx commented 9 months ago

This PR removes the sys.path hacks from the scripts/. It should work as-is, but as usual when working on a library, you can also pip install -e . to make sure src/spandrel is editable and in your env's paths.

You will need to run these scripts with python -m henceforth, though, but that's really good hygiene anyway, as you're forced to use proper imports (see from scripts.dump_state_dict import instead of from dump_state_dict import) that don't depend on the cwd or PYTHONPATH.

It also simplifies and idiomaticizes (what a word!) dump_state_dict a bit – I checked that the output is the same aside from less trailing whitespaces in certain lines.

RunDevelopment commented 9 months ago

python -m scripts.dump_dummy

I don't like that because now I have to type out script names. Right now, I can just use the terminal to fill the script file name for me with tab completion. I'm lazy and I want to keep doing that.