https://github.com/data-miner00/python-workspace
https://github.com/data-miner00/python-workspace
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/data-miner00/python-workspace
- Owner: data-miner00
- License: wtfpl
- Created: 2024-04-09T10:51:05.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-04-14T07:50:40.000Z (over 1 year ago)
- Last Synced: 2024-04-17T04:55:51.349Z (over 1 year ago)
- Language: Python
- Size: 73.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Python Workspace
A personal workspace to deal with data quickly, inspired by my colleague.
## Installation
For Nix users, initiate the Nix shell by running the `develop` command. This step is optional.
```
nix develop
```
Poetry is required to manage the virtual environment and packages. If Poetry is not installed globally on your system, run the following Pip install command. Nix users can skip this step as the dependency is already installed.
```
pip install poetry
```
After that, install and create a virtual environment for the project workspace.
```
poetry install
```
## Features
To execute these command line features, we'll need to activate the environment to our current command line.
```
poetry shell
```
### Execute Codes
The code within the `src/work` can be execute easily with the Python command.
```
python src/work
```
This is possible because of the `__main__.py` file, which serves as the entry point for the executable scripts.
### Jupyter Notebook
Run interactive session for Python with Jupyter Notebook.
```
jupyter notebook --notebook-dir="notebooks"
```
This will automatically open the Jupyter Notebook UI in the browser with the url `localhost:8888`.
### Pytest
Unit tests are located at the `tests` folder. Pytest will be able to execute the tests correctly.
```
pytest
```
### Codespell
Typos for spellings can be checked with codespell.
```
codespell
```
The `.codespellrc` file provides a way to customize the behaviour.
### Linting
Ruff is used for linting Python codes.
```
ruff check .
```
### Formatting
Automated formatting of the codes to improve readability can be done by using Black.
```
black .
```
## Enforce Rules (Optional)
To ensure that the codebase is clean and free of trivial issues such as extra space or overlooked typos, the rules can be enforced before every commit to examine the codebase. `pre-commit` can be installed from Pip and it's included in Nix.
```
pip install pre-commit
```
After that, install the hooks by running
```
pre-commit install
```
It should now run the checks listed in `.pre-commit-config.yaml` file upon each attempted commit.
## Useful Links
- [Poetry Docs](https://python-poetry.org/docs/cli/)
- [Jupyter Docs](https://docs.jupyter.org/en/latest/)
- [Ruff Configuration](https://docs.astral.sh/ruff/configuration/)
- [Codespell GitHub](https://github.com/codespell-project/codespell)