Um direkt in dem Visual Studio Editor auch Vektorgrafiken mit DrawIO zu bearbeiten, kann folgendes Addon installiert werden. Die dateien sind dann mit der Endung *.drawio.svg zu speichern.
An example python AI project, testing out some best practices for python development
- using rye as a build tool,
- using pyright for static type checking and linting,
- and pre-commit for pre-commit checks.
To be used as a template.
the repo contains a sample package called example_project_with_rye.
Replace it with our own one:
- Rename the package at
src/ - Update the test at
tests/ - Update the
pyproject.toml:-
[project] name = "example-project-with-rye" version = "0.1.0" description = "Add your description here" authors = [ { name = "Max", email = "Max@example-project-with-rye.com" } ] -
[project.scripts] "example-project-with-rye" = "example_project_with_rye:main" -
[tool.hatch.build.targets.wheel] packages = ["src/example_project_with_rye"]
-
- uses rye as a build tool.
- pyproject.toml is used to configure rye.
- .python-version is used to specify the python version.
- requirements.lock and requirements-dev.lock are automatically generated.
- uses pytest for testing.
- test files are located in the
testsdirectory. - test files are named
test_*.py.
- test files are located in the
- uses pyright for static type checking and linting.
- uses ruff /rye as linter.
- settings are configure in the
[tool.ruff]section of thepyproject.tomlfile.
- settings are configure in the
- uses pre-commit for pre-commit checks.
- pre-commit checks are configured in the
.pre-commit-config.yamlfile. - pre-commit checks are run automatically before each commit.
- includes: lint, type-check (pyright), and detect-secrets.
- pre-commit checks are configured in the
Follow these steps to install the required tools to run this program:
-
Install rye.
-
Run following command to install the required dependencies in a virtual environment:
rye sync
-
ALTERNATIVE: Install the dependencies manually:
pip install -r requirements.lock pip install -r requirements-dev.lock
-
Configure the Python Interpreter of your IDE to use the
.venvenvironment. -
Duplicate the
.env.examplefile and rename it to.env. Fill in the required fields.
- In Pycharm, mark the
srcdirectory as source root:- Right-click on the
srcdirectory -> Mark Directory as -> Sources Root
- Right-click on the
- In Pycharm, mark the
testsdirectory as test root:- Right-click on the
testsdirectory -> Mark Directory as -> Test Sources Root
- Right-click on the
- When running tests, make sure that pytest is configured as test runner in your IDE.
- For PyCharm: Settings -> Tools -> Python Integrated Tools -> Testing -> Default test runner -> pytest
- You will need to delete any existing run configurations for tests and re-create them!
- Plugins:
- Install the 'pyright Language Server' plugin for PyCharm. Under Settings -> Tools -> Pyright LS (Local), set the path to the pyright-langserver executable, e.g.:.venv\Scripts\pyright-langserver.exe
...
Additional developer commands (Click to expand)
-
Add langchain as regular dependency
rye add langchain
-
Add pytest as dev dependency
rye add pytest --dev
-
Update specific package:
rye sync --update langchain
-
Update all packages:
rye sync --update-all
-
Update rye itself:
rye self update
-
Find all lint errors, auto fix some:
rye lint --fix
-
Static type and syntax checking:
pyright
-
Auto-format all files:
rye fmt
-
Install pre-commit checks, that will be run automatically before each commit:
# (only for staged files) pre-commit install --hook-type pre-commit -
Manually run configured pre-commit checks on the currently staged files:
pre-commit run
-
Manually run configured pre-commit checks, on all files, including unstaged:
pre-commit run --all-files
-
Update all configured pre-commit hook scripts to their newest versions:
pre-commit autoupdate