Skip to content

Commit

Permalink
cicd: release action
Browse files Browse the repository at this point in the history
  • Loading branch information
numb3r3 committed Jul 10, 2023
1 parent 6deb96f commit 72771fb
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 138 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
echo "BUILD_TARGET=clip_executor" >> $GITHUB_ENV
VERSION=$(sed -n '/^version = /p' ./pyproject.toml | cut -d \" -f2)
VERSION=$(sed -n '/^version = /p' ./open_gpt/__init__.py | cut -d \' -f2)
V_VERSION=v${VERSION}
MINOR_VERSION=${VERSION%.*}
MAJOR_VERSION=${MINOR_VERSION%.*}
Expand Down
34 changes: 25 additions & 9 deletions .github/workflows/force-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,37 @@ jobs:
with:
python-version: "3.10"

- name: Install Poetry
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
pip install setuptools wheel twine
- name: Build project for distribution
run: poetry build
- name: Set envs and versions
run: |
VCS_REF=${{ github.ref }}
echo "VCS_REF=$VCS_REF" >> $GITHUB_ENV
echo "Will build $VCS_REF"
VERSION=$(sed -n '/^version = /p' ./open_gpt/__init__.py | cut -d \' -f2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Check Version
id: check-version
run: |
[[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT
[[ ${{ env.VERSION }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT
- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: poetry publish
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: steps.check-version.outputs.prerelease == 'true'
35 changes: 22 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,37 @@ jobs:
with:
python-version: "3.10"

- name: Install Poetry
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
pip install setuptools wheel twine
- name: Build project for distribution
run: poetry build
- name: Set envs and versions
run: |
VCS_REF=${{ github.ref }}
echo "VCS_REF=$VCS_REF" >> $GITHUB_ENV
echo "Will build $VCS_REF"
VERSION=$(sed -n '/^version = /p' ./open_gpt/__init__.py | cut -d \' -f2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Check Version
id: check-version
run: |
[[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT
[[ ${{ env.VERSION }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: steps.check-version.outputs.prerelease == 'true'

- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: poetry publish
prerelease: steps.check-version.outputs.prerelease == 'true'
14 changes: 3 additions & 11 deletions open_gpt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os as _os
import sys

__version__ = '0.0.8'

_logging.captureWarnings(True)


Expand All @@ -24,20 +26,10 @@
'`jina` dependency is not installed correctly, please reinstall with `pip install -U --force-reinstall jina`'
)


def get_version() -> str:
"""Return the module version number specified in pyproject.toml.
:return: The version number.
"""
return importlib_metadata.version(__package__ + '_torch')


__version__ = get_version()

__resources_path__ = _os.path.join(_os.path.dirname(__file__), 'resources')

_os.environ['NO_VERSION_CHECK'] = '1'

from inference_client import Client
from inference_client import Client # noqa

from .factory import create_model
109 changes: 5 additions & 104 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,106 +1,7 @@
[tool.poetry]
name = "open_gpt_torch"
version = "0.0.8"
description = "An open-source cloud-native of large multi-modal models (LMMs) serving framework."

license = "Apache-2.0"

authors = [
"Jina AI <hello@jina.ai>"
]

repository = "https://github.com/jina-ai/opengpt"
homepage = "https://github.com/jina-ai/opengpt"

classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
]
packages = [{ include = "open_gpt" }]
exclude = ["**/*.pyc", "**/*.pyi", "tests/**/*", "docs/**/*", "examples/**/*"]

# README file(s) are used as the package description
readme = ["README.md", "LICENSE"]

# Keywords (translated to tags on the package index)
keywords = ["Pytorch", "LMM", "GPT", "LLM", "multi-modality", "cloud-native", "model-serving", "model-inference", "llama", "vicuna", "stabellm"]

[build-system]
requires = ["poetry-core>=1.1.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.dependencies]
# Compatible Python versions
python = ">=3.8,<4.0"
jina = "^3.17.0"
docarray = "^0.21.0"
jcloud = "^0.2.11"
inference-client = "^0.0.4"
pydantic = "^1.10.0"
loguru = "^0.5"
cleo = "^2.0.0"
click = "^8.1.3"
Jinja2 = "^3.1.2"
numpy = "^1.21.2"
einops = "^0.6.0"
tensorboard = "<2.11.2"
transformers = "^4.30.1"
bitsandbytes = "^0.39.0"
accelerate = "^0.20.3"
tqdm = "^4.62.3"
peft = "^0.3.0"

# A list of all of the optional dependencies, some of which are included in the
# below `extras`. They can be opted into by apps.
psutil = { version = "^5.8.0", optional = true }
open-flamingo = { version = "^0.0.2", optional = true }
open_clip_torch = { version = "^2.20.0", optional = true }
gradio = { version = "^3.30.0", optional = true }
mdtex2html = { version = "^1.2.0", optional = true }
markdown2 = { version = "^2.4.0", optional = true }

[tool.poetry.extras]
flamingo = ["open-flamingo", "open_clip_torch"]
playground = ["gradio", "mdtex2html", "markdown2"]
profile = ["psutil"]


# Dependency groups are supported for organizing your dependencies
[tool.poetry.group.dev.dependencies]
ruff = "^0.0.262"
mypy = "^1.2.0"
pre-commit = ">=2.15.0"
pytest = "^7.1.2"
pytest-cov = "^3.0"
pytest-mock = ">=3.5"

[tool.pytest.ini_options]
# Ignore deprecation warnings
filterwarnings = [
"ignore:Deprecated call to `pkg_resources.declare_namespace:DeprecationWarning"
]


# ...and can be installed only when explicitly requested
[tool.poetry.group.docs]
optional = true
[tool.poetry.group.docs.dependencies]
Sphinx = "^5.1.1"
requires = ["setuptools>=40.8.0", "wheel"]

# Python-style entrypoints and scripts are easily expressed
[tool.poetry.scripts]
opengpt = "open_gpt.cli.application:main"
[tool.autopep8]
aggressive = 1
ignore = "E501,E701,E731,W690"
max_line_length = 88
99 changes: 99 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import sys
from os import path

from setuptools import find_packages, setup

if sys.version_info < (3, 8, 0):
raise OSError(f'OpenGPT requires Python >=3.8, but yours is {sys.version}')

try:
pkg_name = 'open-gpt-torch'
libinfo_py = path.join(path.dirname(__file__), 'open_gpt', '__init__.py')
libinfo_content = open(libinfo_py, 'r', encoding='utf8').readlines()
version_line = [l.strip() for l in libinfo_content if l.startswith('__version__')][
0
]
exec(version_line) # gives __version__
except FileNotFoundError:
__version__ = '0.0.0'


try:
with open('../README.md', encoding='utf8') as fp:
_long_description = fp.read()
except FileNotFoundError:
_long_description = ''

setup(
name=pkg_name,
packages=find_packages(),
version=__version__,
include_package_data=True,
description='An open-source cloud-native of large multi-modal models (LMMs) serving framework.',
author='Jina AI',
author_email='hello@jina.ai',
license='Apache 2.0',
url='https://https://github.com/jina-ai/opengpt',
download_url='https://https://github.com/jina-ai/opengpt/tags',
long_description=_long_description,
long_description_content_type='text/markdown',
zip_safe=False,
setup_requires=['setuptools>=18.0', 'wheel'],
install_requires=[
'pydantic<2.0.0',
'jina>=3.17.0',
'docarray<0.30.0',
'jcloud>0.2.0',
'inference-client>=0.0.4',
'cleo>=2.0.0',
'click>=8.0.0',
'Jinja2>=3.1.0',
'transformers>=4.30.1',
'bitsandbytes>=0.39.0',
'accelerate>=0.20.3',
'peft>=0.3.0',
'open_clip_torch>=2.20.0',
'loguru',
'tqdm',
],
extras_require={
'profile': ['psutil'],
'test': ['pytest', 'pytest-cov', 'pytest-xdist', 'pytest-mock'],
},
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
],
project_urls={
'Documentation': 'https://opengpt.jina.ai',
'Source': 'https://github.com/jina-ai/opengpt/',
'Tracker': 'https://github.com/jina-ai/opengpt/issues',
},
keywords=[
"Pytorch",
"LMM",
"GPT",
"LLM",
"multi-modality",
"cloud-native",
"model-serving",
"model-inference",
"llama",
"vicuna",
"stabellm",
],
)

0 comments on commit 72771fb

Please sign in to comment.