Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.

Commit 3c79e58

Browse files
committed
feat: publishing infernet-ml v0.1.0
0 parents  commit 3c79e58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4332
-0
lines changed

.github/workflows/python_ci.yaml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# pre-commit workflow
2+
#
3+
# Ensures the codebase passes the pre-commit stack.
4+
5+
name: Python CI
6+
7+
on: [push]
8+
9+
jobs:
10+
python_ci:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [ "3.10", "3.11" ]
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install UV
26+
run: python -m pip install uv
27+
28+
- name: Create virtual environment
29+
run: uv venv
30+
31+
- name: Activate virtual environment
32+
run: |
33+
. .venv/bin/activate
34+
echo PATH=$PATH >> $GITHUB_ENV
35+
36+
- name: Install dependencies
37+
run: uv pip install -r requirements.lock
38+
39+
- name: Run pre-commit hooks
40+
run: pre-commit run --all-files --show-diff-on-failure
41+
42+
- name: Run tests (infernet_ml)
43+
working-directory: .
44+
env:
45+
HUGGING_FACE_HUB_TOKEN: ${{ secrets.HF_TOKEN }}
46+
MODEL_OWNER: ${{ secrets.MODEL_OWNER }}
47+
PYTHONPATH: src
48+
run: pytest -vvv

.gitignore

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Python
2+
__pycache__/
3+
.pytest_cache
4+
5+
# ezkl artifacts
6+
input.json
7+
*.srs
8+
*.compiled
9+
*.onnx
10+
settings.json
11+
*.pf
12+
*.pk
13+
*.vk
14+
witness.json
15+
16+
# mlflow / mlruns
17+
mlfow
18+
mlruns
19+
20+
21+
# notebooks
22+
notebooks
23+
**/known_nodes.json
24+
*/.vscode/*
25+
*/.idea/*
26+
*/.DS_Store
27+
*/.env
28+
*/.env.local
29+
*/.env.*.local
30+
31+
# Linters
32+
**/.mypy_cache/
33+
**/.ruff_cache/
34+
35+
# Unit test / coverage reports
36+
htmlcov/
37+
.coverage
38+
.coverage.*
39+
40+
# Environments
41+
.env
42+
.venv
43+
env/
44+
venv/
45+
46+
#dotenv files
47+
.env
48+
*.env
49+
50+
# onnx environment
51+
onnx
52+
53+
# Mac finder cache
54+
.DS_Store
55+
56+
# Local logs
57+
*.log
58+
59+
# Config file
60+
config.json
61+
62+
# ignore build artifacts
63+
infernet_ml.egg-info
64+
dist
65+
build
66+
67+
#ide specific
68+
launch.json
69+
70+
# ide
71+
.idea
72+
73+
# wallet files
74+
**/keyfile-arweave.json
75+
76+
# shared volume files
77+
shared
78+
79+
# model files
80+
**/*.torch
81+
82+
# pypi-server packages (testing installation of lib locally)
83+
packages

.pre-commit-config.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.0.289
4+
hooks:
5+
- id: ruff
6+
args: [--fix, --exit-non-zero-on-fix]
7+
8+
- repo: https://github.com/psf/black
9+
rev: 23.9.1
10+
hooks:
11+
- id: black
12+
13+
- repo: local
14+
hooks:
15+
- id: mypy
16+
name: mypy
17+
entry: mypy --strict
18+
language: system
19+
types: [python]
20+
21+
- repo: https://github.com/pycqa/isort
22+
rev: 5.13.2
23+
hooks:
24+
- id: isort
25+
name: isort (python)
26+
27+
# Default pre-commit hooks
28+
- repo: https://github.com/pre-commit/pre-commit-hooks
29+
rev: v3.2.0
30+
hooks:
31+
# Ensure EOF exists
32+
- id: end-of-file-fixer
33+
# Prevent adding large files
34+
- id: check-added-large-files
35+
args: ["--maxkb=5000"]
36+
# Newline at end of file
37+
- id: trailing-whitespace

LICENSE

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
The Clear BSD License
2+
3+
Copyright (c) 2023 Origin Research Ltd
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification,
7+
are permitted (subject to the limitations in the disclaimer below) provided that
8+
the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
13+
* Redistributions in binary form must reproduce the above copyright
14+
notice, this list of conditions and the following disclaimer in the
15+
documentation and/or other materials provided with the distribution.
16+
17+
* Neither the name of the copyright holder nor the names of its
18+
contributors may be used to endorse or promote products derived from this
19+
software without specific prior written permission.
20+
21+
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
22+
THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23+
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
26+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
30+
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
POSSIBILITY OF SUCH DAMAGE.

Makefile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.phony: clean build-library publish-to-local-pypi start-local-pypi
2+
3+
clean:
4+
rm -rf dist
5+
rm -rf src/infernet_ml.egg-info
6+
7+
build-library: clean
8+
# build library from pyproject.toml
9+
python -m build
10+
11+
publish-to-local-pypi: build-library
12+
twine upload --repository-url http://localhost:4040 dist/* --username user --password user
13+
14+
start-local-pypi:
15+
mkdir -p packages
16+
pypi-server run -a . -P . -p 4040 packages --overwrite

README.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# infernet-ml
2+
3+
`infernet-ml` is a lightweight library meant to simplify the implementation
4+
of machine learning workflows for models intended for Web3.
5+
6+
# Installation
7+
8+
### Via `pip`
9+
10+
To install this library via pip:
11+
12+
```bash
13+
python -m venv .venv
14+
source .venv/bin/activate
15+
pip install "infernet-ml"
16+
```
17+
18+
### Via `uv`
19+
20+
Alternatively, via [uv](https://github.com/astral-sh/uv):
21+
22+
```bash
23+
uv venv
24+
source .venv/bin/activate
25+
uv pip install infernet-ml
26+
```
27+
28+
## Optional Dependencies
29+
30+
Depending on the workflow you're using, you may want to install optional dependencies. For example, if you're using the
31+
`torch` workflow, you'll need to install its dependencies by running:
32+
33+
```bash
34+
pip install "infernet-ml[torch_inference]"
35+
```
36+
37+
Alternatively, via [uv](https://github.com/astral-sh/uv):
38+
39+
```bash
40+
uv pip install "infernet-ml[torch_inference]"
41+
```
42+
43+
> [!NOTE] The optional dependencies for this workflow require that `cmake` is installed on your system. You can install
44+
`cmake` on MacOS by running `brew install cmake`. On Ubuntu & Windows,
45+
> consult [the documentation](https://onnxruntime.ai/docs/build/inferencing.html#prerequisites)
46+
> for more information.
47+
48+
## Docs
49+
50+
For more information on this library, consult
51+
the [documentation website](https://docs.ritual.net/ml-workflows/overview).

pyproject.toml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0", "setuptools-scm>=8.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "infernet_ml"
7+
version = "0.1.0"
8+
description = "Lightweight library to build web3 machine learning workflows"
9+
readme = "README.md"
10+
requires-python = ">=3.10, <3.12"
11+
classifiers = [
12+
"Programming Language :: Python :: 3",
13+
"Operating System :: OS Independent",
14+
]
15+
16+
dependencies = [
17+
"python-dotenv>=1.0.0,<2.0.0",
18+
"pydantic>=2.5.3,<3.0.0",
19+
"huggingface-hub>=0.17.3,<1.0.0",
20+
"click>=8.1.7,<9.0.0",
21+
]
22+
23+
[project.optional-dependencies]
24+
25+
# torch inference dependencies
26+
torch_inference = [
27+
"torch>=2.1.2,<3.0.0",
28+
"sk2torch>=1.2.0,<2.0.0"
29+
]
30+
31+
# bark inference service
32+
bark_inference = [
33+
"torch>=2.1.2,<3.0.0",
34+
"transformers>=4.37.2,<5.0.0",
35+
"scipy>=1.11.4,<2.0.0",
36+
]
37+
38+
# onnx inference dependencies
39+
onnx_inference = [
40+
"torch>=2.1.2,<3.0.0",
41+
"onnx>=1.15.0,<2.0.0",
42+
"onnxruntime>=1.16.3,<2.0.0",
43+
]
44+
45+
# llm inference dependencies
46+
tgi_inference = [
47+
"text-generation>=0.6.1,<1.0.0",
48+
"retry2>=0.9.5,<1.0.0",
49+
]
50+
51+
css_inference = [
52+
"text-generation>=0.6.1,<1.0.0",
53+
"retry2>=0.9.5,<1.0.0",
54+
]
55+
56+
[project.scripts]
57+
arweave = "infernet_ml.utils.arweave:cli"
58+
59+
[tool.pytest.ini_options]
60+
log_cli = true
61+
log_cli_level = "INFO"
62+
log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
63+
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
64+
65+
[tool.setuptools_scm]
66+
fallback_version = "0.0.0"
67+
68+
[tool.mypy]
69+
exclude = ['venv', '.venv']
70+
71+
[tool.isort]
72+
profile = "black"

requirements-test.txt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
black~=23.9.1
2+
pre-commit~=2.15.0
3+
mypy~=1.7.0
4+
pytest~=7.1.3
5+
pytest-mock~=3.12.0
6+
pytest-cov~=3.0.0
7+
pytest-metadata~=1.7.0
8+
pytest-asyncio~=0.21.1
9+
pandas-stubs~=2.1.4.231227
10+
types-Pillow~=10.2.0.20240111
11+
types-aiofiles~=23.2.0.20240106
12+
types-requests~=2.31.0.20240106
13+
types-setuptools~=69.0.0.20240115
14+
types-tabulate~=0.9.0.20240106
15+
types-tqdm~=4.66.0.20240106
16+
types-pytz~=2023.3.1.1
17+
types-retry~=0.9.9.4
18+
py-solc-x~=1.1.1

0 commit comments

Comments
 (0)