Skip to content

Commit

Permalink
make all deps optional and test simple interface
Browse files Browse the repository at this point in the history
Signed-off-by: Michele Dolfi <[email protected]>
  • Loading branch information
dolfim-ibm committed Dec 4, 2024
1 parent 1490677 commit e1abdec
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 25 deletions.
13 changes: 12 additions & 1 deletion .github/actions/setup-poetry/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ inputs:
python-version:
description: "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax."
default: '3.11'
run_install:
description: "Install the dependencies."
default: 'true'
install_extras:
description: "When installing depdencies, the extra dependencies are included."
default: 'true'
runs:
using: 'composite'
steps:
Expand All @@ -21,6 +27,11 @@ runs:
poetry env use ${{ steps.py.outputs.python-path }}
poetry run python --version
shell: bash
- name: Install only dependencies and not the package itself
- name: Install the dependencies and the extas (but not the package itself)
if: ${{ inputs.run_install == 'true' && inputs.install_extras == 'true' }}
run: poetry install --all-extras --no-root
shell: bash
- name: Install only dependencies and not the package itself
if: ${{ inputs.run_install == 'true' && inputs.install_extras != 'true' }}
run: poetry install --no-root
shell: bash
13 changes: 12 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@ jobs:
- uses: ./.github/actions/setup-poetry
with:
python-version: ${{ matrix.python-version }}
- name: Install with poetry
run_install: 'false'

- name: Install extras
run: |
poetry install
ls -l
ls -l deepsearch_glm
- name: Test interface without extras
run: |
poetry run pytest ./tests/test_simple_interface.py -vs
- name: Install extras
run: |
poetry install --all-extras
ls -l
Expand Down
32 changes: 17 additions & 15 deletions poetry.lock

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

17 changes: 9 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ build = "build.py"

[tool.poetry.dependencies]
python = "^3.9"
docling-core = "^2.0"
pywin32 = { version = "^307", markers = "sys_platform == 'win32'" }
docling-core = { version = "^2.0", optional = true }
deepsearch-toolkit = { version = "^1.1.0", optional = true }
tabulate = ">=0.8.9"
pandas = ">=1.5.1,<3.0.0"
tabulate = { version = ">=0.8.9", optional = true }
pandas = { version = ">=1.5.1,<3.0.0", optional = true }
matplotlib = { version = "^3.7.1", optional = true }
python-dotenv = { version = "^1.0.0", optional = true }
tqdm = "^4.64.0"
rich = "^13.7.0"
pywin32 = { version = "^307", markers = "sys_platform == 'win32'" }
requests = "^2.32.3"
tqdm = { version = "^4.64.0", optional = true }
rich = { version = "^13.7.0", optional = true }
requests = { version = "^2.32.3", optional = true }

[tool.poetry.group.test.dependencies]
pytest = "^7.4.2"
Expand Down Expand Up @@ -73,7 +73,8 @@ pandas = [

pyplot = ["matplotlib"]
toolkit = ["deepsearch-toolkit", "python-dotenv"]

docling = ["docling-core", "pandas"]
utils = ["tabulate", "python-dotenv", "pandas", "tqdm", "rich", "requests"]

[tool.black]
line-length = 88
Expand Down
17 changes: 17 additions & 0 deletions tests/test_simple_interface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import json

from deepsearch_glm.andromeda_nlp import nlp_model


def test_simple_interface():
model = nlp_model()
model.set_loglevel("WARNING")

config = model.get_apply_configs()[0]
config["models"] = ""
config["subject-filters"] = []

model.initialise(config)

doc = json.load(open("tests/data/docs/1806.02284.json"))
output = model.apply_on_doc(doc)

0 comments on commit e1abdec

Please sign in to comment.