Matt Robinson d7608014c0
improve: add Python 3.12 support (#3033) (#3047)
### Summary

Closes #2959. Updates the dependency and CI to add support for Python
3.12.

The MongoDB ingest tests were disabled due to jobs like [this
one](https://github.com/Unstructured-IO/unstructured/actions/runs/9133383127/job/25116767333)
failing due to issues with the `bson` package. `bson` is a dependency
for the AstraDB connector, but `pymongo` does not work when `bson` is
installed from `pip`. This issue is documented by MongoDB
[here](https://pymongo.readthedocs.io/en/stable/installation.html). Spun
off #3049 to resolve this. Issue seems unrelated to Python 3.12, though
unsure why this didn't surface previously.

Disables the `argilla` tests because `argilla` does not yet support
Python 3.12. We can add the `argilla` tests back in once the PR
references below is merged. You can still use the `stage_for_argilla`
function if you're on `python<3.12` and you install `argilla` yourself.
- https://github.com/argilla-io/argilla/pull/4837

---------

Co-authored-by: Nicolò Boschi <boschi1997@gmail.com>
2024-05-19 23:03:15 +00:00

51 lines
1.8 KiB
YAML

name: 'Base Cache Build'
description: 'Restore the base python cache for CI to use, recreate if not found'
inputs:
python-version:
description: 'python version associated with the cache'
required: true
check-only:
description: 'if set, will not restore the cache if it exists'
default: "false"
runs:
using: "composite"
steps:
- name: Check for/restore base cache
uses: actions/cache/restore@v3
id: virtualenv-cache-restore
with:
path: |
.venv
nltk_data
key: unstructured-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('requirements/*.txt') }}
lookup-only: ${{ inputs.check-only }}
- name: Set up Python ${{ inputs.python-version }}
if: steps.virtualenv-cache-restore.outputs.cache-hit != 'true'
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
- name: Setup virtual environment (no cache hit)
if: steps.virtualenv-cache-restore.outputs.cache-hit != 'true'
shell: bash
run: |
python${{ inputs.python-version }} -m pip install --upgrade virtualenv
python${{ inputs.python-version }} -m venv .venv
source .venv/bin/activate
[ ! -d "$NLTK_DATA" ] && mkdir "$NLTK_DATA"
if [ "${{ inputs.python-version == '3.12' }}" == "true" ]; then
python -m ensurepip --upgrade
python -m pip install --upgrade setuptools
fi
make install-ci
- name: Save Cache
if: steps.virtualenv-cache-restore.outputs.cache-hit != 'true'
id: virtualenv-cache-save
uses: actions/cache/save@v3
with:
path: |
.venv
nltk_data
key: unstructured-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('requirements/*.txt') }}