Skip to content

Commit 40a8030

Browse files
authored
Add array filter types, modernize build (#89)
* Add Array filter types to QueryFilter.Types * Use importlib to determine client version * Remove setup.py * package metadata moved to pyproject.toml * Update build to use hatchling * Add justfile * Remove Makefile * Update dependencies * Update README
1 parent 1028cdd commit 40a8030

File tree

9 files changed

+115
-108
lines changed

9 files changed

+115
-108
lines changed

CHANGE.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
LabKey Python Client API News
33
+++++++++++
44

5+
What's New in the LabKey 4.1.0 package
6+
==============================
7+
8+
*Release date: 02/24/2026*
9+
- Add array filter types
10+
- Use importlib to determine client version
11+
- Update build to use Hatch
12+
513
What's New in the LabKey 4.0.1 package
614
==============================
715

Makefile

Lines changed: 0 additions & 24 deletions
This file was deleted.

README.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,13 @@ This package is maintained by [LabKey](http://www.labkey.com/). If you have any
121121
[LabKey Server developer support forum](https://www.labkey.org/home/developer/forum/project-start.view).
122122

123123
### Setup
124+
We use the Just command runner to simplify setup and development with this package. You'll want to install just to work
125+
on this package. Installation instructions can be found here: https://just.systems/man/en/packages.html
126+
124127
To install the necessary dependencies for local development you can run the following command:
125128

126129
```bash
127-
pip install -e '.[dev]'
130+
just install
128131
```
129132

130133

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

138-
After black has run it may have formatted some files, commit the changed files before opening a PR.
141+
After black has run, it may have formatted some files, commit the changed files before opening a PR.
139142

140143
### Testing
141-
If you are looking to contribute please run the tests before issuing a PR. The tests can be run with:
144+
If you are looking to contribute please run the tests before issuing a PR.
145+
146+
To run only the unit tests, run the following command:
147+
148+
```bash
149+
just test-unit
150+
```
151+
152+
To run the integration tests, make sure you have a live server running, a netrc file, and run the following command:
142153

143154
```bash
144-
$ pytest .
155+
just test-integration
145156
```
146157

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

150160
```bash
151-
$ pytest . -m "integration"
161+
just test
152162
```
153163

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

160170
```bash
161-
pip install -e '.[build]'
171+
just install-build
162172
```
163173

164174
To build the package you can run:
165175

166176
```bash
167-
python -m build
177+
just build
168178
```
169179

170180
You should now have a `dist/` folder with two files:

justfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
build:
2+
python -m build
3+
4+
release-test:
5+
hatch publish --repo test
6+
7+
release:
8+
hatch publish
9+
10+
install:
11+
pip install -e '.[dev,test]'
12+
13+
install-build:
14+
pip install -e '.[build]'
15+
16+
uninstall:
17+
pip uninstall -y labkey
18+
19+
clean:
20+
rm -rf ./dist/
21+
rm -rf ./labkey.egg-info
22+
23+
test-unit:
24+
pytest .
25+
26+
test-integration:
27+
pytest . -m "integration"
28+
29+
test: test-unit test-integration
30+
31+
brt: clean build release-test
32+
33+
br: clean build release

labkey/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,3 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__title__ = "labkey"
17-
__version__ = "4.0.1"
18-
__author__ = "LabKey"
19-
__license__ = "Apache License 2.0"

labkey/query.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class Pagination:
6060
ALL = "all"
6161
NONE = "none"
6262

63-
6463
# TODO: Provide filter generators.
6564
#
6665
# There are some inconsistencies between the different filter types with multiple values,
@@ -114,6 +113,12 @@ class Types:
114113
CONTAINS_ONE_OF = "containsoneof"
115114
CONTAINS_NONE_OF = "containsnoneof"
116115

116+
ARRAY_CONTAINS_ALL = "arraycontainsall"
117+
ARRAY_CONTAINS_ANY = "arraycontainsany"
118+
ARRAY_CONTAINS_NONE = "arraycontainsnone"
119+
ARRAY_CONTAINS_EXACT = "arraymatches"
120+
ARRAY_CONTAINS_NOT_EXACT = "arraynotmatches"
121+
117122
IN = "in"
118123

119124
EQUALS_ONE_OF = "in"
@@ -135,6 +140,10 @@ class Types:
135140
HAS_MISSING_VALUE = "hasmvvalue"
136141
DOES_NOT_HAVE_MISSING_VALUE = "nomvvalue"
137142

143+
ARRAY_ISEMPTY = "arrayisempty"
144+
ARRAY_ISNOTEMPTY = "arrayisnotempty"
145+
146+
138147
# Table/Query-wise operators
139148
Q = "q"
140149

labkey/server_context.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Dict, TextIO
22
from labkey.utils import json_dumps
3-
from . import __version__
43
import requests
4+
import importlib.metadata
55
from requests.exceptions import RequestException
66
from labkey.exceptions import (
77
RequestError,
@@ -14,6 +14,7 @@
1414

1515
API_KEY_TOKEN = "apikey"
1616
CSRF_TOKEN = "X-LABKEY-CSRF"
17+
client_version = importlib.metadata.version("labkey")
1718

1819

1920
def handle_response(response, non_json_response=False):
@@ -76,7 +77,9 @@ def __init__(
7677
self._disable_csrf = disable_csrf
7778
self.allow_redirects = allow_redirects
7879
self._session = requests.Session()
79-
self._session.headers.update({"User-Agent": f"LabKey Python API/{__version__}"})
80+
self._session.headers.update({"User-Agent": f"LabKey Python API/{client_version}"})
81+
82+
print(f"User Agent header: LabKey Python API/{client_version}")
8083

8184
if self._use_ssl:
8285
self._scheme = "https://"

pyproject.toml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name="labkey"
7+
version = "4.1.0"
8+
description = "Python client API for LabKey Server"
9+
dependencies = ["requests>=2.32.5"]
10+
readme = "README.md"
11+
requires-python = ">=3.11"
12+
license = "Apache-2.0"
13+
license-files = ["LICENSE.txt"]
14+
keywords = ["labkey"]
15+
maintainers = [{ name = "Alan Vezina", email="alanv@labkey.com" }]
16+
classifiers = [
17+
"Development Status :: 4 - Beta",
18+
"Environment :: Console",
19+
"Intended Audience :: Science/Research",
20+
"Intended Audience :: System Administrators",
21+
"Operating System :: MacOS",
22+
"Operating System :: Microsoft",
23+
"Operating System :: POSIX",
24+
"Programming Language :: Python :: 3.11",
25+
"Programming Language :: Python :: 3.12",
26+
"Programming Language :: Python :: 3.13",
27+
"Programming Language :: Python :: 3.14",
28+
"Topic :: Scientific/Engineering",
29+
]
30+
31+
[tool.hatch.build.targets.sdist]
32+
only-include = ["labkey"]
33+
34+
[project.optional-dependencies]
35+
test = ["pytest>=9.0.2", "mock>=5.2.0", "pytest-cov>=7.0.0"]
36+
dev = ["black>=26.1.0", "pytest>=9.0.2", "mock>=5.2.0", "pytest-cov>=7.0.0", "hatch>=1.16.4"]
37+
38+
[project.urls]
39+
Homepage = "https://github.com/LabKey/labkey-api-python"
40+
141
[tool.black]
242
line-length = 100

setup.py

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)