diff --git a/.vscode/launch.json b/.vscode/launch.json index 0058d2f..fed21e6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,14 +4,17 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { "name": "Python: Current File", "type": "python", "request": "launch", "program": "${file}", + //"module": "unittest", "console": "integratedTerminal", - "justMyCode": true + "justMyCode": true, + "env": { "PYTHONPATH": "${workspaceRoot}:${PYTHONPATH}:~/Code/Athena/athena-db/owl-agent-backend/src"} } ] } \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 929fca5..dd54078 100644 --- a/docs/index.md +++ b/docs/index.md @@ -6,21 +6,21 @@ This repository regroup Python codes and notes from my own self-training and stu **Advantages:** -* Interpreted with shell to start quickly, more concise language -* May be now the 1st most used programming language -* A lot of libraries, used a lot by data scientists -* Combines functional and Object Oriented Programming. +* Since 2022 may be the 1st most used programming language +* A lot of libraries, used a lot by data scientists, data pipeline and web dev. +* Combines functional and Object Oriented Programming, with support to dynamic class creation and dynamic function call. +* Language of choices for Machine Learning development * Raspberry PI language of choice * Even new libraries are done to implement server side user interface, with project like Streamlit, [gradio.app](https://www.gradio.app/docs/), [Nice gui](https://nicegui.io/); [taipy](taipy.io) **Disadvantages:** -* Slow, not supporting well multi cpu / threading architecture +* Challenge in type enforcement and validation. Some tools are needed in IDE and adopting library like Pydantic. * Not great for mobile and 3D game programming ## Getting started -See this good [tutorial from Programiz](https://www.programiz.com/python-programming#tutorial) +See this good [tutorial from Programiz](https://www.programiz.com/python-programming#tutorial). Python is an interpreted Object Oriented & functional language. It organizes the code in modules. Use blank to indent code block. The coding style is known as PEP8. diff --git a/docs/python/faq.md b/docs/python/faq.md index 7997e2d..1b35878 100644 --- a/docs/python/faq.md +++ b/docs/python/faq.md @@ -56,6 +56,39 @@ The `__init__.py` file makes Python treat directories containing it as modules. pip freeze > requirements.txt ``` +## Develop a module to be installable with pip + +See [this article](https://betterscientificsoftware.github.io/python-for-hpc/tutorials/python-pypi-packaging/), and [Python Packaging User Guide](https://packaging.python.org/en/latest/) summarized as: + +1. Create a python package (folder) with the setup.py in it. + + ```python + from setuptools import setup, find_packages + + setup( + name="jb_module", + version="0.1.0", + description="The backend to support hybrid AI", + author="Jerome Boyer", + packages=find_packages(include=["acme"]), + install_requires=['uvicorn', 'fastapi', 'langchain-openai','langchain-anthropic','langchain_ibm','langchain_community', + 'pydantic','python-multipart','python-dotenv','markdown','chromadb','pypdf'], + ) + ``` + +1. `pip3 install setuptool` +1. install in current virtual env: `pip install .` or `pip install --upgrade .`. Install with `pip uninstall jb_module` +1. Add a `__init__.py` file under the jb_module folder specify version... + + ```python + __version__ = "0.1.0" + __author__ = 'Jerome Boyer' + __credits__ = '' + ``` +1. Create a source distribution with: `python setup.py sdist`, it contains a compressed archive of the package +1. Install twine to be able to upload to PyPi: `pip install twine` +1. Push the package to test.pypi.org + ## Access environment variable Define environment variables in a `.env` file, use os package: