-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from argilla-io/feat/code_rewriting
[RELEASE] ArgillaLlamaIndex 1.0: Update to Llama Index >= 0.10.0
- Loading branch information
Showing
11 changed files
with
1,231 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: 🧪 Integration Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
integration_tests: | ||
name: Running integration tests, which require an Argilla instance running | ||
runs-on: ubuntu-latest | ||
services: | ||
search-engine: | ||
image: | ||
searchEngineDockerImage: | ||
description: "The name of the Docker image of the search engine to use." | ||
default: docker.elastic.co/elasticsearch/elasticsearch:8.8.2 | ||
required: false | ||
type: string | ||
ports: | ||
- 6900:6900 | ||
env: | ||
searchEngineDockerEnv: | ||
description: "The name of the Docker image of the search engine to use." | ||
default: '{"discovery.type": "single-node", "xpack.security.enabled": "false"}' | ||
required: false | ||
type: string | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
steps: | ||
- name: Checkout Code 🛎 | ||
uses: actions/checkout@v3 | ||
- name: Setup Conda Env 🐍 | ||
uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
miniforge-variant: Mambaforge | ||
miniforge-version: latest | ||
use-mamba: true | ||
activate-environment: argilla | ||
- name: Get date for conda cache | ||
id: get-date | ||
run: echo "::set-output name=today::$(/bin/date -u '+%Y%m%d')" | ||
shell: bash | ||
- name: Cache Conda env | ||
uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: ${{ env.CONDA }}/envs | ||
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('environment_dev.yml') }}-${{ env.CACHE_NUMBER }} | ||
- name: Update environment | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: mamba env update -n argilla -f environment_dev.yml | ||
- name: Cache pip 👜 | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ env.CACHE_NUMBER }}-${{ hashFiles('pyproject.toml') }} | ||
- name: Set Argilla search engine env variable | ||
if: startsWith(inputs.searchEngineDockerImage, 'docker.elastic.co') | ||
run: | | ||
echo "ARGILLA_SEARCH_ENGINE=elasticsearch" >> "$GITHUB_ENV" | ||
echo "Configure elasticsearch engine" | ||
- name: Set Argilla search engine env variable | ||
if: startsWith(inputs.searchEngineDockerImage, 'opensearchproject') | ||
run: | | ||
echo "ARGILLA_SEARCH_ENGINE=opensearch" >> "$GITHUB_ENV" | ||
echo "Configure opensearch engine" | ||
- name: Launch Argilla Server | ||
env: | ||
ARGILLA_ENABLE_TELEMETRY: 0 | ||
run: | | ||
pip install -e ".[server]" | ||
python -m argilla server database migrate | ||
python -m argilla server database users create_default | ||
python -m argilla server start & | ||
- name: Run end2end examples 📈 | ||
env: | ||
ARGILLA_ENABLE_TELEMETRY: 0 | ||
run: | | ||
pip install pytest | ||
pytest tests | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: 🎉 Release | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
# Looks like it's not working very well for other people: | ||
# https://github.com/actions/setup-python/issues/436 | ||
# cache: "pip" | ||
# cache-dependency-path: pyproject.toml | ||
|
||
- uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-release-v00 | ||
|
||
- name: Install dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: pip install build | ||
|
||
- name: Build distribution | ||
run: python -m build | ||
|
||
- name: Publish | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ __pycache__/ | |
*.py[cod] | ||
*$py.class | ||
|
||
.DS_Store | ||
|
||
# C extensions | ||
*.so | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Auxiliary methods for the Argilla Llama Index integration. | ||
""" | ||
|
||
from datetime import datetime | ||
from typing import Dict, List | ||
|
||
from llama_index.core.callbacks.schema import CBEvent | ||
|
||
def _get_time_diff(event_1_time_str: str, event_2_time_str: str) -> float: | ||
""" | ||
Get the time difference between two events Follows the American format (month, day, year). | ||
Args: | ||
event_1_time_str (str): The first event time. | ||
event_2_time_str (str): The second event time. | ||
Returns: | ||
float: The time difference between the two events. | ||
""" | ||
time_format = "%m/%d/%Y, %H:%M:%S.%f" | ||
|
||
event_1_time = datetime.strptime(event_1_time_str, time_format) | ||
event_2_time = datetime.strptime(event_2_time_str, time_format) | ||
|
||
return round((event_2_time - event_1_time).total_seconds(), 4) | ||
|
||
|
||
def _calc_time(events_data: Dict[str, List[CBEvent]], id: str) -> float: | ||
""" | ||
Calculate the time difference between the start and end of an event using the events_data. | ||
Args: | ||
events_data (Dict[str, List[CBEvent]]): The events data, stored in a dictionary. | ||
id (str): The event id to calculate the time difference between start and finish timestamps. | ||
Returns: | ||
float: The time difference between the start and end of the event. | ||
""" | ||
|
||
start_time = events_data[id][0].time | ||
end_time = events_data[id][1].time | ||
return _get_time_diff(start_time, end_time) |
Oops, something went wrong.