Skip to content

Commit

Permalink
Handle programs and tags that have uppercase characters
Browse files Browse the repository at this point in the history
  • Loading branch information
bennybp committed May 16, 2024
1 parent 3e6e5c5 commit e51b369
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions qcfractal/qcfractal/components/tasks/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions qcfractal/qcfractal/components/tasks/test_socket_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit e51b369

Please sign in to comment.