diff --git a/.github/actions/setup-poetry/action.yml b/.github/actions/setup-poetry/action.yml index 77a1324e..eff8c3c0 100644 --- a/.github/actions/setup-poetry/action.yml +++ b/.github/actions/setup-poetry/action.yml @@ -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: @@ -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 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 48ee9d86..efe55a6c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -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 diff --git a/poetry.lock b/poetry.lock index fb1a1dbf..6c876855 100644 --- a/poetry.lock +++ b/poetry.lock @@ -15,7 +15,7 @@ files = [ name = "annotated-types" version = "0.7.0" description = "Reusable constraint types to use with typing.Annotated" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53"}, @@ -676,7 +676,7 @@ files = [ name = "docling-core" version = "2.6.1" description = "A python library to define and validate data types in Docling." -optional = false +optional = true python-versions = "<4.0,>=3.9" files = [ {file = "docling_core-2.6.1-py3-none-any.whl", hash = "sha256:8e7a5bc0ce13289567738481949fed3ab580f2d8cea7525b246159233d81b26b"}, @@ -1036,7 +1036,7 @@ trio = ["async_generator", "trio"] name = "jsonref" version = "1.1.0" description = "jsonref is a library for automatic dereferencing of JSON Reference objects for Python." -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "jsonref-1.1.0-py3-none-any.whl", hash = "sha256:590dc7773df6c21cbf948b5dac07a72a251db28b0238ceecce0a2abfa8ec30a9"}, @@ -1047,7 +1047,7 @@ files = [ name = "jsonschema" version = "4.23.0" description = "An implementation of JSON Schema validation for Python" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "jsonschema-4.23.0-py3-none-any.whl", hash = "sha256:fbadb6f8b144a8f8cf9f0b89ba94501d143e50411a1278633f56a7acf7fd5566"}, @@ -1068,7 +1068,7 @@ format-nongpl = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339- name = "jsonschema-specifications" version = "2024.10.1" description = "The JSON Schema meta-schemas and vocabularies, exposed as a Registry" -optional = false +optional = true python-versions = ">=3.9" files = [ {file = "jsonschema_specifications-2024.10.1-py3-none-any.whl", hash = "sha256:a09a0680616357d9a0ecf05c12ad234479f549239d0f5b55f3deea67475da9bf"}, @@ -1262,7 +1262,7 @@ attrs = "*" name = "markdown-it-py" version = "3.0.0" description = "Python port of markdown-it. Markdown parsing, done right!" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"}, @@ -1362,7 +1362,7 @@ files = [ name = "mdurl" version = "0.1.2" description = "Markdown URL utilities" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"}, @@ -1728,7 +1728,7 @@ files = [ name = "pillow" version = "10.4.0" description = "Python Imaging Library (Fork)" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "pillow-10.4.0-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:4d9667937cfa347525b319ae34375c37b9ee6b525440f3ef48542fcf66f2731e"}, @@ -1900,7 +1900,7 @@ files = [ name = "pydantic" version = "2.9.2" description = "Data validation using Python type hints" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "pydantic-2.9.2-py3-none-any.whl", hash = "sha256:f048cec7b26778210e28a0459867920654d48e5e62db0958433636cde4254f12"}, @@ -1923,7 +1923,7 @@ timezone = ["tzdata"] name = "pydantic-core" version = "2.23.4" description = "Core functionality for Pydantic validation and serialization" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "pydantic_core-2.23.4-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:b10bd51f823d891193d4717448fab065733958bdb6a6b351967bd349d48d5c9b"}, @@ -2332,7 +2332,7 @@ md = ["cmarkgfm (>=0.8.0)"] name = "referencing" version = "0.35.1" description = "JSON Referencing + Python" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "referencing-0.35.1-py3-none-any.whl", hash = "sha256:eda6d3234d62814d1c64e305c1331c9a3a6132da475ab6382eaa997b21ee75de"}, @@ -2396,7 +2396,7 @@ idna2008 = ["idna"] name = "rich" version = "13.9.4" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" -optional = false +optional = true python-versions = ">=3.8.0" files = [ {file = "rich-13.9.4-py3-none-any.whl", hash = "sha256:6049d5e6ec054bf2779ab3358186963bac2ea89175919d699e378b99738c2a90"}, @@ -2415,7 +2415,7 @@ jupyter = ["ipywidgets (>=7.5.1,<9)"] name = "rpds-py" version = "0.22.1" description = "Python bindings to Rust's persistent data structures (rpds)" -optional = false +optional = true python-versions = ">=3.9" files = [ {file = "rpds_py-0.22.1-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:ab27dd4edd84b13309f268ffcdfc07aef8339135ffab7b6d43f16884307a2a48"}, @@ -2586,7 +2586,7 @@ files = [ name = "tabulate" version = "0.9.0" description = "Pretty-print tabular data" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "tabulate-0.9.0-py3-none-any.whl", hash = "sha256:024ca478df22e9340661486f85298cff5f6dcdba14f3813e8830015b9ed1948f"}, @@ -2812,10 +2812,12 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", type = ["pytest-mypy"] [extras] +docling = ["docling-core", "pandas"] pyplot = ["matplotlib"] toolkit = ["deepsearch-toolkit", "python-dotenv"] +utils = ["pandas", "python-dotenv", "requests", "rich", "tabulate", "tqdm"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "1eae18c2d50d224cf84899d60efb0a888157f81a226c4b360f87888e01cd3d23" +content-hash = "3d8cd2c9768df607d967c0ff3b824042da573567271de3f0b6d72f5ca7e399a6" diff --git a/pyproject.toml b/pyproject.toml index 005d4850..031e8846 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -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 diff --git a/tests/test_simple_interface.py b/tests/test_simple_interface.py new file mode 100644 index 00000000..1ff5b0d7 --- /dev/null +++ b/tests/test_simple_interface.py @@ -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)