Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcodeforce committed Jun 5, 2024
2 parents 7eea271 + a3b3c5e commit f9786b7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
}
]
}
12 changes: 6 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
33 changes: 33 additions & 0 deletions docs/python/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f9786b7

Please sign in to comment.