-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ee90cd
commit ed47359
Showing
10 changed files
with
42 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,139 +3,24 @@ | |
A [simple] [general-purpose] Python template 🐍🚀🎉🦕 | ||
|
||
|
||
I used this template for [fesenjoon](https://pypi.org/project/fesenjoon/) and [medviz](https://pypi.org/project/medviz/). | ||
|
||
## How to use | ||
|
||
- Linux and Mac | ||
Use GCC Makefile | ||
|
||
- Install Makefile | ||
|
||
https://community.chocolatey.org/packages/make | ||
|
||
http://www.cygwin.com/ | ||
|
||
### Bootstrap | ||
|
||
To use env in another directory: | ||
|
||
``` bash | ||
make env | ||
``` | ||
|
||
There is no need to active virtual environment when the `PY` command is used from Makefile. | ||
|
||
To use env here (local directory) | ||
|
||
``` bash | ||
make env-local | ||
``` | ||
|
||
``` bash | ||
source env_platform_ver/bin/activate | ||
``` | ||
|
||
Set a name for the package: | ||
|
||
```bash | ||
make init newName | ||
``` | ||
|
||
Check Python and pip version | ||
|
||
``` bash | ||
make | ||
``` | ||
|
||
Update pip and build tools | ||
|
||
``` bash | ||
make check | ||
``` | ||
|
||
Install the requirements | ||
|
||
``` bash | ||
make pireq | ||
``` | ||
|
||
### Install a package | ||
|
||
``` bash | ||
make piu numpy matplotlib scipy | ||
``` | ||
|
||
## Features | ||
|
||
- Linter: Pylint | ||
- Formatter: Black | ||
- CI: GitHub Actions | ||
|
||
### ToDo | ||
|
||
- [x] Formatter: Black + isort | ||
- [x] Type checker: MyPy | ||
- [x] Linter: Ruff | ||
- [x] Linter: Pylint | ||
- [x] GitHub Actions | ||
- [x] Git Hooks | ||
- [x] PyPI Publish | ||
- [x] Flit | ||
- [x] Poetry | ||
- [x] Ruff | ||
|
||
### Git | ||
|
||
Git hooks are available in ./scripts/.githooks | ||
|
||
``` bash | ||
chmod +x ./scripts/.githooks/script | ||
|
||
git config core.hooksPath ./scripts/.githooks | ||
|
||
``` | ||
|
||
|
||
## Publish to PyPI | ||
|
||
|
||
1. To build a package, run: | ||
``` bash | ||
make pkg-build | ||
``` | ||
|
||
2. To check the build, run: | ||
``` bash | ||
make pkg-check | ||
``` | ||
|
||
3. To install the package locally, run: | ||
``` bash | ||
make pkg-install | ||
``` | ||
|
||
4. Create `.pypirc` file in the root directory of the project. It should look like this: | ||
|
||
``` bash | ||
[distutils] | ||
index-servers = | ||
pypi | ||
testpypi | ||
|
||
[pypi] | ||
repository: https://upload.pypi.org/legacy/ | ||
username: <your username> | ||
password: <your password> | ||
|
||
[testpypi] | ||
repository: https://test.pypi.org/legacy/ | ||
username: <your username> | ||
password: <your password> | ||
``` | ||
|
||
4. To publish to PyPI, run: | ||
|
||
``` bash | ||
make pkg-publish | ||
``` | ||
## Run on HPC | ||
|
||
1. Clone the repository | ||
```bash | ||
git clone [email protected]:mohsenhariri/template-python.git | ||
chmod -R u=rwx,go= template-python | ||
cd template-python | ||
``` | ||
|
||
2. Run the initialization script | ||
```bash | ||
chmod +x hpc.init | ||
source hpc.init | ||
``` | ||
|
||
3. Modify or add commands to `hpc.make` file | ||
|
||
4. Run the `hpc.make` file | ||
```bash | ||
make newCommand | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
run: | ||
$(PY) $(SRC)/app.py | ||
$(PY) $(SRC)/app.py | ||
|
||
gpu-test: | ||
$(PY) $(SRC)/gpu.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
""" | ||
DocString | ||
""" | ||
print("main") | ||
print("Running on HPC") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import torch | ||
|
||
device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | ||
|
||
print(f"Using {device} device") | ||
print(f"Using {torch.cuda.device_count()} GPUs!") |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.