Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT BRANCH] Add argilla-sdk project #4891

Merged
merged 19 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/argilla-sdk.docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Publish documentation

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
paths:
- "argilla-sdk/docs/**"
- "argilla-sdk/src/**"
branches:
# - "main"
# - "develop"
- "feat/v2.0.0" # Fixing this branch until we merge everything into develop
- "docs/**" # When we create a new branch only for docs
tags:
- "**"

defaults:
run:
working-directory: argilla-sdk

jobs:
publish:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.10" ]
steps:

- name: checkout docs-site
uses: actions/checkout@v4
with:
ref: gh-pages

- uses: actions/checkout@v4

- name: Setup Python
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
cache: true
cache-dependency-path: |
argilla-sdk/pyproject.toml

- name: Install dependencies
run: |
pdm install

- name: Set git credentials
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"

- run: pdm run mike deploy dev --push
if: github.ref == 'refs/heads/feat/v2.0.0'
# if: github.ref == 'refs/heads/develop'

- run: pdm run mike deploy ${{ github.ref_name }} latest --update-aliases --push
if: startsWith(github.ref, 'refs/tags/')

- name: Extract branch name
shell: bash
run: echo "branch_name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | sed 's/\//_/g' >> $GITHUB_OUTPUT
id: extract_branch_name

- run: pdm run mike deploy ${{ steps.extract_branch_name.outputs.branch_name }} --push
if: startsWith(github.head_ref, 'docs/')
151 changes: 151 additions & 0 deletions .github/workflows/argilla-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Build and publish the `argilla-sdk` python package

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
workflow_dispatch:
inputs:
release:
description: "If true, the workflow will publish the package to PyPI. Default is false."
default: false

push:
paths:
- "argilla-sdk/**"
- "!argilla-sdk/docs/**"
branches:
- "develop"
- "main"

pull_request:
paths:
- "argilla-sdk/**"
- "!argilla-sdk/docs/**"
branches:
- "develop"
- "main"
- "feat/**"

release:
types:
- "published"

defaults:
run:
working-directory: argilla-sdk

jobs:
build:
services:
argilla-quickstart:
image: argilla/argilla-quickstart:main
ports:
- 6900:6900
env:
ANNOTATOR_USERNAME: annotator
OWNER_USERNAME: argilla
OWNER_API_KEY: argilla.apikey
ADMIN_USERNAME: admin
ADMIN_API_KEY: admin.apikey
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
steps:
- uses: actions/checkout@v4
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
cache: true
cache-dependency-path: |
argilla-sdk/pyproject.toml
- name: Install dependencies
run: |
pdm install
- name: Wait for argilla-quickstart to start
run: |
while ! curl -XGET http://localhost:6900/api/_status; do sleep 5; done
- name: Run unit tests
run: |
pdm run test tests/unit
- name: Run integration tests
run: |
pdm run test tests/integration
- name: Build package
run: |
pdm build
- name: Upload artifact
uses: actions/upload-artifact@v4
# Upload the package to be used in the next jobs only once
if: ${{ matrix.python-version == '3.8' }}
with:
name: argilla-sdk
path: argilla-sdk/dist

# This job will publish argilla-sdk package into PyPI repository
publish_release:
name: Publish Release
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
needs:
- build

permissions:
# This permission is needed for private repositories.
# contents: read
# IMPORTANT: this permission is mandatory for trusted publishing on PyPI
id-token: write
# This permission is needed for creating tags
contents: write

defaults:
run:
shell: bash -l {0}

steps:
- name: Checkout Code 🛎
uses: actions/checkout@v4

- name: Download python package
uses: actions/download-artifact@v4
with:
name: argilla-sdk
path: argilla-sdk/dist

- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
cache: true

- name: Read package info
run: |
PACKAGE_VERSION=$(pdm show --version)
PACKAGE_NAME=$(pdm show --name)
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
echo "$PACKAGE_NAME==$PACKAGE_VERSION"

- name: Create tag
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git tag -f -a v${{ env.PACKAGE_VERSION }} -m "Release v${{ env.PACKAGE_VERSION }}"
git push -f origin v${{ env.PACKAGE_VERSION }}

- name: Publish Package to PyPI test environment 🥪
run: pdm publish --no-build --repository testpypi
continue-on-error: true

- name: Test Installing 🍿
run: |
pip install --index-url https://test.pypi.org/simple --no-deps $PACKAGE_NAME==$PACKAGE_VERSION

- name: Publish Package to PyPI 🥩
if: ${{ inputs.release == 'true' }}
run: pdm publish --no-build
52 changes: 47 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,83 @@
repos:
##############################################################################
# argilla specific hooks
##############################################################################
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
files: '^argilla/.*\.py$'
- id: end-of-file-fixer
files: '^argilla/.*\.py$'
exclude_types: [ text, jupyter ]
- id: trailing-whitespace

files: '^argilla/.*\.py$'
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
- id: insert-license
name: "Insert license header in Python source files"
files: \.py$
files: '^argilla/.*\.py$'
args:
- --license-filepath
- license_header.txt
- --fuzzy-match-generates-todo
# - --remove-header

- repo: https://github.com/psf/black
rev: 23.10.1
hooks:
- id: black
additional_dependencies: [ "typer==0.7.0" ]
# only run for argilla/ files
files: '^argilla/.*\.py'
files: '^argilla/.*\.py$'
args: [ --line-length=120 ]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
# Simulate isort via (the much faster) ruff
- id: ruff
files: '^argilla/.*\.py$'
args:
- --select=I
- --fix
##############################################################################
# argilla-sdk specific hooks
##############################################################################
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
- id: insert-license
name: "Insert license header in Python source files"
files: '^argilla-sdk/.*\.py$'
exclude: ^argilla-sdk/docs/snippets/
args:
- --license-filepath
- argilla-sdk/LICENSE_HEADER
- --fuzzy-match-generates-todo
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.4
hooks:
- id: ruff
files: '^argilla-sdk/.*\.py$'
args:
- --fix
- id: ruff-format
files: '^argilla-sdk/.*\.py$'
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout
files: '^argilla-sdk/.*\.ipynb$'
args:
- --keep-count
- --keep-output
# - --keep-prompt-number
# - --keep-cell-ids
# - --keep-markdown
# - --keep-output-timestamp
# - --keep-execution-count
# - --keep-metadata
# - --keep-version

ci:
autofix_commit_msg: |
Expand Down
Loading
Loading