diff --git a/CHANGE.txt b/CHANGE.txt index c047aea..b6a6d4a 100644 --- a/CHANGE.txt +++ b/CHANGE.txt @@ -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 ============================== diff --git a/Makefile b/Makefile deleted file mode 100644 index e7a5d1e..0000000 --- a/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -.PHONY: build -build: - python -m build - -.PHONY: release-test -release-test: - twine upload dist/* -r testpypi - -.PHONY: release -release: - twine upload dist/* -r pypi - -.PHONY: install -install: - pip install -e '.[dev,build]' - -.PHONY: uninstall -uninstall: - pip uninstall -y labkey - -.PHONY: clean -clean: - rm -rf ./dist/ - rm -rf ./labkey.egg-info \ No newline at end of file diff --git a/README.md b/README.md index 0fcface..89a6e8d 100644 --- a/README.md +++ b/README.md @@ -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 ``` @@ -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 @@ -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 ``` You should now have a `dist/` folder with two files: diff --git a/justfile b/justfile new file mode 100644 index 0000000..09b56af --- /dev/null +++ b/justfile @@ -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 diff --git a/labkey/__init__.py b/labkey/__init__.py index 435850d..ff1d523 100644 --- a/labkey/__init__.py +++ b/labkey/__init__.py @@ -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" diff --git a/labkey/query.py b/labkey/query.py index a17fbd4..24a7160 100644 --- a/labkey/query.py +++ b/labkey/query.py @@ -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, @@ -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" @@ -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" diff --git a/labkey/server_context.py b/labkey/server_context.py index d586a64..7de7322 100644 --- a/labkey/server_context.py +++ b/labkey/server_context.py @@ -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, @@ -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): @@ -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://" diff --git a/pyproject.toml b/pyproject.toml index aa4949a..8fb88bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 diff --git a/setup.py b/setup.py deleted file mode 100644 index 4db7d67..0000000 --- a/setup.py +++ /dev/null @@ -1,68 +0,0 @@ -# -# Copyright (c) 2015-2017 LabKey Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -""" -Setup script for Python client API for LabKey Server. - -Also installs included versions of third party libraries, if those libraries -are not already installed. -""" -import re -from setuptools import setup - -packages = ["labkey"] - -with open("labkey/__init__.py", "r") as fd: - version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - -long_desc = "Python client API for LabKey Server. Supports query and experiment APIs." - -tests_require = ["pytest", "requests", "mock", "pytest-cov"] -dev_require = ["pytest", "requests", "mock", "pytest-cov", "black"] -build_require = ["setuptools", "build", "twine", "wheel", "packaging"] - -setup( - name="labkey", - version=version, - description="Python client API for LabKey Server", - long_description=long_desc, - license="Apache License 2.0", - author="LabKey", - author_email="alanv@labkey.com", - maintainer="Alan Vezina", - maintainer_email="alanv@labkey.com", - url="https://github.com/LabKey/labkey-api-python", - packages=packages, - package_data={}, - python_requires=">=3.11", # Note: update README.md supported versions if you change this - install_requires=["requests"], - extras_require={"test": tests_require, "dev": dev_require, "build": build_require}, - keywords="labkey api client", - classifiers=[ - "Development Status :: 4 - Beta", - "Environment :: Console", - "Intended Audience :: Science/Research", - "Intended Audience :: System Administrators", - "License :: OSI Approved :: Apache Software License", - "Operating System :: MacOS", - "Operating System :: Microsoft", - "Operating System :: POSIX", - "Programming Language :: Python :: 3", - "Topic :: Scientific/Engineering", - ], -)