Skip to content

Commit

Permalink
Merge pull request #17 from argilla-io/feat/code_rewriting
Browse files Browse the repository at this point in the history
[RELEASE] ArgillaLlamaIndex 1.0: Update to Llama Index >= 0.10.0
  • Loading branch information
ignacioct authored Apr 26, 2024
2 parents 3e92dee + 1d470af commit da176e2
Show file tree
Hide file tree
Showing 11 changed files with 1,231 additions and 287 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/integration-tests.yml
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
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ __pycache__/
*.py[cod]
*$py.class

.DS_Store

# C extensions
*.so

Expand Down
353 changes: 353 additions & 0 deletions data/paul_graham_essay.txt

Large diffs are not rendered by default.

Binary file modified docs/assets/argilla-ui-dataset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
342 changes: 342 additions & 0 deletions docs/examples/usage_example.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ classifiers = [
"Programming Language :: Python :: 3.11",
]
dependencies = [
"argilla >= 1.18.0",
"llama-index >= 0.9.32",
"argilla >= 1.22.0",
"llama-index >= 0.10.0",
"packaging >= 23.2",
"typing-extensions >= 4.3.0"
]
Expand Down
2 changes: 1 addition & 1 deletion src/argilla_llama_index/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.0.1-alpha"
__version__ = "1.0.0"

from argilla_llama_index.llama_index_handler import ArgillaCallbackHandler

Expand Down
43 changes: 43 additions & 0 deletions src/argilla_llama_index/helpers.py
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)
Loading

0 comments on commit da176e2

Please sign in to comment.