Skip to content

Commit

Permalink
Merge branch 'master' into flavor
Browse files Browse the repository at this point in the history
  • Loading branch information
lfoppiano authored Jan 15, 2025
2 parents 4a5f45a + dcf1b50 commit d518359
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 22 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build unstable

on: [push]

concurrency:
group: unstable


jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ]
fail-fast: true

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Cleanup more disk space
run: sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade flake8 pytest pycodestyle pytest-cov
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# - name: Test with pytest
# run: |
# pytest
43 changes: 43 additions & 0 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build release

on:
workflow_dispatch:
push:
tags:
- 'v*'

concurrency:
group: docker
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: 'pip'
- name: Cleanup more disk space
run: sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade flake8 pytest pycodestyle
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# - name: Test with pytest
# run: |
# pytest

- name: Build and Publish to PyPI
uses: conchylicultor/pypi-build-publish@v1
with:
pypi-token: ${{ secrets.PYPI_API_TOKEN }}
37 changes: 34 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,31 @@ You can change the server address by editing the file `config.json`, see below.

## Requirements

This client has been developed and was tested with Python `3.5`-`3.9` and should work with any higher `3.*` versions. It uses `requests` as dependency beyond the Standard Python Library.
This client has been developed and was tested with Python `3.8`-`3.13` and should work with any higher `3.*` versions.
It uses `requests` as dependency beyond the Standard Python Library.

## Install

Get the github repo:
The client can be installed with any of the following ways:

* Install *latest stable release* from PyPI:

```console
python3 -m pip install grobid-client-python
```

* Install *current master development version* from GitHub:

```console
pip install git+https://github.com/kermitt2/grobid_client_python.git
python3 -m pip install git+https://github.com/kermitt2/grobid_client_python.git
```

* Install and build from a clone of the repo (*current master development version*):

```
git clone https://github.com/kermitt2/grobid_client_python
cd grobid_client_python
pip install -e .
```

There is nothing more needed to start using the python command lines, see the next section.
Expand Down Expand Up @@ -177,6 +194,20 @@ In similar conditions, extraction and structuring of bibliographical references
Processing of 3500 raw bibliographical take 4.3 s with `n=10` (814 references parsed per second).


## Developer notes

### New release

New releases can be published by using `bump-my-version`:

```shell
pip install bump-my-version
bump-my-version bump patch
```

Use of `major`, `minor`, or `patch` or will increment the first, second or the third digit of the version, respectively.
The release will be published automatically on pypy.

## License and contact

Distributed under [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0).
Expand Down
10 changes: 9 additions & 1 deletion grobid_client/grobid_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ def process_pdf(
include_raw_affiliations,
tei_coordinates,
segment_sentences,
start=-1,
end=-1,
flavor=None
):
pdf_handle = open(pdf_file, "rb")
Expand Down Expand Up @@ -293,6 +295,10 @@ def process_pdf(
the_data["segmentSentences"] = "1"
if flavor:
the_data["flavor"] = flavor
if start > 0:
the_data["start"] = str(start)
if end > 0:
the_data["end"] = str(end)

try:
res, status = self.post(
Expand All @@ -310,7 +316,9 @@ def process_pdf(
include_raw_citations,
include_raw_affiliations,
tei_coordinates,
segment_sentences
segment_sentences,
start,
end
)
except requests.exceptions.ReadTimeout:
pdf_handle.close()
Expand Down
40 changes: 40 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[tool.bumpversion]
current_version = "0.0.9"
commit = "true"
tag = "true"
tag_name = "v{new_version}"

[project]
name = "grobid-client-python"
license = { file = "LICENSE" }
authors = [
{ name = "Patrice Lopez", email = "[email protected]" },
]
maintainers = [
{ name = "Patrice Lopez", email = "[email protected]" },
{ name = "Luca Foppiano", email = "[email protected]" }
]
description = "Simple python client for GROBID REST services"
readme = "Readme.md"

dynamic = ['version', "dependencies"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[tool.setuptools_scm]

[tool.setuptools]
packages=['grobid_client']

[project.urls]
Homepage = "https://github.com/kermitt2/grobid_client_python"
Repository = "https://github.com/kermitt2/grobid_client_python"
Changelog = "https://github.com/kermitt2/grobid_client_python"

[project.scripts]
grobid_client = "grobid_client.grobid_client:main"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests
18 changes: 0 additions & 18 deletions setup.py

This file was deleted.

0 comments on commit d518359

Please sign in to comment.