Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
still having python issues.
  • Loading branch information
mike dupont committed Oct 11, 2023
1 parent ba278e8 commit e93a685
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 33 deletions.
20 changes: 0 additions & 20 deletions .github/workflows/debug.yml

This file was deleted.

112 changes: 112 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Pipeline

on: push

jobs:
code-quality:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
# - name: Setup Python
# uses: actions/setup-python@v4
# with:
# python-version: 3.10.12
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.4.1
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
- name: pylint
run: |
source .venv/bin/activate
pylint build tests
- name: black
run: |
source .venv/bin/activate
black --check .
run-tests:
needs: code-quality
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# - name: Setup Python
# uses: actions/setup-python@v4
# with:
# python-version: 3.10.12
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.4.1
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
- name: Run all tests with pytest
run: |
source .venv/bin/activate
pytest --cov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

publish-all-images:
needs: run-tests
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Get Git Commit Tag Name
uses: olegtarasov/[email protected]
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# - name: Setup Python
# uses: actions/setup-python@v4
# with:
# python-version: 3.10.12
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.4.1
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
- name: Publish Image to Docker Hub
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
run: |
source .venv/bin/activate
python -m build.publish
15 changes: 8 additions & 7 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,19 @@ jobs:
GITHUB_REPO: "jmikedupont2/ai-ticket"
run: docker-compose build

- name: Docker Compose Action echo

- name: create openai
env:
GITHUB_PAT: ${{ secrets.PAT }}
GITHUB_REPO: "jmikedupont2/ai-ticket"
run: echo pat ${{ secrets.PAT }}
# run: echo docker-compose up -e GITHUB_PAT=${{ secrets.PAT }} -e GITHUB_REPO="jmikedupont2/ai-ticket"

- name: Docker Compose Action do it
#uses: meta-introspector/compose-action@main
run: |
GITHUB_PAT=${{ secrets.PAT }} GITHUB_REPO="jmikedupont2/ai-ticket" docker-compose up -d mockopenai
- name: run autogpt
env:
GITHUB_PAT: ${{ secrets.PAT }}
GITHUB_REPO: "jmikedupont2/ai-ticket"
run: |
GITHUB_PAT=${{ secrets.PAT }} GITHUB_REPO="jmikedupont2/ai-ticket" docker-compose up
GITHUB_PAT=${{ secrets.PAT }} GITHUB_REPO="jmikedupont2/ai-ticket" docker-compose run autogpt
43 changes: 41 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,51 @@
FROM python:3.10-slim
# The Poetry installation is provided through the base image. Please check the
# base image if you interested in the details.
# Base image: https://hub.docker.com/r/pfeiffermax/python-poetry
# Dockerfile: https://github.com/max-pfeiffer/python-poetry/blob/main/build/Dockerfile
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
ARG APPLICATION_SERVER_PORT

LABEL maintainer="Mike DuPont <[email protected]>"

ENV PYTHONUNBUFFERED=1 \
# https://docs.python.org/3/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=/application_root \
# https://python-poetry.org/docs/configuration/#virtualenvsin-project
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_CACHE_DIR="/application_root/.cache" \
VIRTUAL_ENVIRONMENT_PATH="/application_root/.venv" \
APPLICATION_SERVER_PORT=$APPLICATION_SERVER_PORT
# Adding the virtual environment to PATH in order to "activate" it.
# https://docs.python.org/3/library/venv.html#how-venvs-work
ENV PATH="$VIRTUAL_ENVIRONMENT_PATH/bin:$PATH"

# Principle of least privilege: create a new user for running the application
RUN groupadd -g 1001 python_application && \
useradd -r -u 1001 -g python_application python_application

# Set the WORKDIR to the application root.
# https://www.uvicorn.org/settings/#development
# https://docs.docker.com/engine/reference/builder/#workdir
WORKDIR ${PYTHONPATH}
RUN chown python_application:python_application ${PYTHONPATH}

# Create cache directory and set permissions because user 1001 has no home
# and poetry cache directory.
# https://python-poetry.org/docs/configuration/#cache-directory
RUN mkdir ${POETRY_CACHE_DIR} && chown python_application:python_application ${POETRY_CACHE_DIR}

# Use the unpriveledged user to run the application
USER 1001

WORKDIR /opt/ai-ticket
COPY pyproject.toml /opt/ai-ticket/
COPY setup.cfg /opt/ai-ticket/
COPY requirements.txt /opt/ai-ticket/
COPY ./src/ /opt/ai-ticket/src/
RUN pip install /opt/ai-ticket/


RUN apt update
RUN apt install -y git
RUN pip install --trusted-host pypi.python.org -r requirements.txt
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
#tty: true # docker run -t

autogpt:
entrypoint: bash -c "poetry run pip install /opt/ai-ticket && poetry run autogpt --install-plugin-deps --skip-news -y --ai-name 'meta-autogpt' --ai-role 'you will introspect autogpt and reveal its internals via reflection and comprehension' --ai-goal 'Observe your behaviour' --ai-goal 'Reflect over your outcomes' --ai-goal 'Orient yourself to your knowledge' --ai-goal 'Decide on your next step' --ai-goal 'Act on your chosen next experiment' "
entrypoint: bash -c "poetry run pip install /opt/ai-ticket && poetry run autogpt --install-plugin-deps --skip-news -y --ai-name 'meta-autogpt' --ai-role 'you will introspect autogpt and reveal its internals via reflection and comprehension' --ai-goal 'Observe your behaviour' --ai-goal 'Reflect over your outcomes' --ai-goal 'Orient yourself to your knowledge' --ai-goal 'Decide on your next step' --ai-goal 'Act on your chosen next experiment' "

# uncomment thse next 3 lines for debugging
#entrypoint: /bin/bash
Expand Down
7 changes: 7 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 37 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[build-system]
python = "^3.7"
requires = [
"setuptools>=42",
"wheel"
"wheel",
"poetry-core"
]
build-backend = "setuptools.build_meta"
#build-backend = "setuptools.build_meta"
build-backend = "poetry.core.masonry.api"


[tool.black]
line-length = 120
Expand All @@ -16,3 +20,34 @@ combine_as_imports = true
combine_star = true
known_local_folder = ["tests", "cli"]
known_first_party = ["test_utils"]

[tool.poetry]
name = "ai-ticket"
version = "0.0.1"
authors = [
"Mike Dupont <[email protected]>",
]
readme = "README.md"
description = "AI ticket"

classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
#packages = .

# [tool.poetry.scripts]
# [tool.poetry.dependencies]
[tool.poetry.group.dev.dependencies]
python = "^3.7"
pytest = "7.4.0"
pytest-cov = "4.1.0"
coverage = "7.3.1"
requests = "2.31.0"
black = "23.7.0"
pre-commit = "3.3.3"
semver = "3.0.1"
pylint = "2.17.5"
testcontainers = "3.7.1"

4 changes: 3 additions & 1 deletion runact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# use .secrets PAT And DOCKER
act -P ubuntu-latest=localhost/my_local_act \
--verbose \
--job python-package-build
--job code-quality

# --job python-package-build

# --pull=false \

0 comments on commit e93a685

Please sign in to comment.