Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
LabKey Python Client API News
+++++++++++

What's New in the LabKey 4.1.0 package
==============================

*Release date: 02/24/2026*
- Add array filter types
- Use importlib to determine client version
- Update build to use Hatch

What's New in the LabKey 4.0.1 package
==============================

Expand Down
24 changes: 0 additions & 24 deletions Makefile

This file was deleted.

28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,13 @@ This package is maintained by [LabKey](http://www.labkey.com/). If you have any
[LabKey Server developer support forum](https://www.labkey.org/home/developer/forum/project-start.view).

### Setup
We use the Just command runner to simplify setup and development with this package. You'll want to install just to work
on this package. Installation instructions can be found here: https://just.systems/man/en/packages.html

To install the necessary dependencies for local development you can run the following command:

```bash
pip install -e '.[dev]'
just install
```


Expand All @@ -135,20 +138,27 @@ When contributing changes please use `Black` to format your code. To run Black y
black .
```

After black has run it may have formatted some files, commit the changed files before opening a PR.
After black has run, it may have formatted some files, commit the changed files before opening a PR.

### Testing
If you are looking to contribute please run the tests before issuing a PR. The tests can be run with:
If you are looking to contribute please run the tests before issuing a PR.

To run only the unit tests, run the following command:

```bash
just test-unit
```

To run the integration tests, make sure you have a live server running, a netrc file, and run the following command:

```bash
$ pytest .
just test-integration
```

The integration tests do not run by default. If you want to run the integration tests make sure you have a live server
running, a netrc file, and run the following command:
To run all tests, run the following command:

```bash
$ pytest . -m "integration"
just test
```

### Maintainers
Expand All @@ -158,13 +168,13 @@ releases.
To build the package before releasing you will need to install the build dependencies. This can be done by running:

```bash
pip install -e '.[build]'
just install-build
```

To build the package you can run:

```bash
python -m build
just build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Please update the Python: LabKey Package Maintenance documentation, specfically, the "Publishing next version" section once this is merged.

```

You should now have a `dist/` folder with two files:
Expand Down
33 changes: 33 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
build:
python -m build

release-test:
hatch publish --repo test

release:
hatch publish

install:
pip install -e '.[dev,test]'

install-build:
pip install -e '.[build]'

uninstall:
pip uninstall -y labkey

clean:
rm -rf ./dist/
rm -rf ./labkey.egg-info

test-unit:
pytest .

test-integration:
pytest . -m "integration"

test: test-unit test-integration

brt: clean build release-test

br: clean build release
4 changes: 0 additions & 4 deletions labkey/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__title__ = "labkey"
__version__ = "4.0.1"
__author__ = "LabKey"
__license__ = "Apache License 2.0"
11 changes: 10 additions & 1 deletion labkey/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class Pagination:
ALL = "all"
NONE = "none"


# TODO: Provide filter generators.
#
# There are some inconsistencies between the different filter types with multiple values,
Expand Down Expand Up @@ -114,6 +113,12 @@ class Types:
CONTAINS_ONE_OF = "containsoneof"
CONTAINS_NONE_OF = "containsnoneof"

ARRAY_CONTAINS_ALL = "arraycontainsall"
ARRAY_CONTAINS_ANY = "arraycontainsany"
ARRAY_CONTAINS_NONE = "arraycontainsnone"
ARRAY_CONTAINS_EXACT = "arraymatches"
ARRAY_CONTAINS_NOT_EXACT = "arraynotmatches"

IN = "in"

EQUALS_ONE_OF = "in"
Expand All @@ -135,6 +140,10 @@ class Types:
HAS_MISSING_VALUE = "hasmvvalue"
DOES_NOT_HAVE_MISSING_VALUE = "nomvvalue"

ARRAY_ISEMPTY = "arrayisempty"
ARRAY_ISNOTEMPTY = "arrayisnotempty"


# Table/Query-wise operators
Q = "q"

Expand Down
7 changes: 5 additions & 2 deletions labkey/server_context.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Dict, TextIO
from labkey.utils import json_dumps
from . import __version__
import requests
import importlib.metadata
from requests.exceptions import RequestException
from labkey.exceptions import (
RequestError,
Expand All @@ -14,6 +14,7 @@

API_KEY_TOKEN = "apikey"
CSRF_TOKEN = "X-LABKEY-CSRF"
client_version = importlib.metadata.version("labkey")


def handle_response(response, non_json_response=False):
Expand Down Expand Up @@ -76,7 +77,9 @@ def __init__(
self._disable_csrf = disable_csrf
self.allow_redirects = allow_redirects
self._session = requests.Session()
self._session.headers.update({"User-Agent": f"LabKey Python API/{__version__}"})
self._session.headers.update({"User-Agent": f"LabKey Python API/{client_version}"})

print(f"User Agent header: LabKey Python API/{client_version}")

if self._use_ssl:
self._scheme = "https://"
Expand Down
40 changes: 40 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name="labkey"
version = "4.1.0"
description = "Python client API for LabKey Server"
dependencies = ["requests>=2.32.5"]
readme = "README.md"
requires-python = ">=3.11"
license = "Apache-2.0"
license-files = ["LICENSE.txt"]
keywords = ["labkey"]
maintainers = [{ name = "Alan Vezina", email="alanv@labkey.com" }]
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Science/Research",
"Intended Audience :: System Administrators",
"Operating System :: MacOS",
"Operating System :: Microsoft",
"Operating System :: POSIX",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Scientific/Engineering",
]

[tool.hatch.build.targets.sdist]
only-include = ["labkey"]

[project.optional-dependencies]
test = ["pytest>=9.0.2", "mock>=5.2.0", "pytest-cov>=7.0.0"]
dev = ["black>=26.1.0", "pytest>=9.0.2", "mock>=5.2.0", "pytest-cov>=7.0.0", "hatch>=1.16.4"]

[project.urls]
Homepage = "https://github.com/LabKey/labkey-api-python"

[tool.black]
line-length = 100
68 changes: 0 additions & 68 deletions setup.py

This file was deleted.

Loading