From e51b369ac9be692b6eccbbd9a6d185d9026ec1af Mon Sep 17 00:00:00 2001 From: Benjamin Pritchard Date: Thu, 16 May 2024 10:00:14 -0400 Subject: [PATCH] Handle programs and tags that have uppercase characters --- qcfractal/qcfractal/components/tasks/socket.py | 4 ++++ qcfractal/qcfractal/components/tasks/test_socket_claim.py | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/qcfractal/qcfractal/components/tasks/socket.py b/qcfractal/qcfractal/components/tasks/socket.py index 3252413f6..9b63481c8 100644 --- a/qcfractal/qcfractal/components/tasks/socket.py +++ b/qcfractal/qcfractal/components/tasks/socket.py @@ -249,6 +249,10 @@ def claim_tasks( # to claim absolutely everything. So double check here limit = calculate_limit(self._tasks_claim_limit, limit) + # Force given tags and programs to be lower case + tags = [tag.lower() for tag in tags] + programs = {key.lower(): [x.lower() for x in value] for key, value in programs.items()} + with self.root_socket.optional_session(session) as session: stmt = select(ComputeManagerORM).where(ComputeManagerORM.name == manager_name) stmt = stmt.with_for_update(skip_locked=False) diff --git a/qcfractal/qcfractal/components/tasks/test_socket_claim.py b/qcfractal/qcfractal/components/tasks/test_socket_claim.py index 9167f5b04..b68400a12 100644 --- a/qcfractal/qcfractal/components/tasks/test_socket_claim.py +++ b/qcfractal/qcfractal/components/tasks/test_socket_claim.py @@ -243,7 +243,8 @@ def test_task_socket_claim_tag(storage_socket: SQLAlchemySocket, session: Sessio recs.append(rec) # tag3 should be first, then tag1 - tasks = storage_socket.tasks.claim_tasks(mname1.fullname, mprog1, ["tag3", "tag1"], 2) + # Change capitalization to test case insensitivity + tasks = storage_socket.tasks.claim_tasks(mname1.fullname, mprog1, ["Tag3", "Tag1"], 2) assert len(tasks) == 2 assert tasks[0]["id"] == recs[3].task.id assert tasks[1]["id"] == recs[0].task.id @@ -301,7 +302,9 @@ def test_task_socket_claim_tag_wildcard(storage_socket: SQLAlchemySocket, sessio def test_task_socket_claim_program(storage_socket: SQLAlchemySocket, session: Session): mname1 = ManagerName(cluster="test_cluster", hostname="a_host1", uuid="1234-5678-1234-5678") - mprog1 = {"qcengine": ["unknown"], "psi4": ["unknown"], "geometric": ["v3.0"]} + + # Managers should not send programs with uppercase characters, but be forgiving + mprog1 = {"QCengine": ["unknown"], "psi4": ["unknown"], "Geometric": ["V3.0"]} storage_socket.managers.activate( name_data=mname1, manager_version="v2.0",