Skip to content

Commit

Permalink
merged in master
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Jul 17, 2023
2 parents 114da5c + 0a4e688 commit c360f8a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions spinnman/spalloc/spalloc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ class SpallocClient(AbstractContextManager, AbstractSpallocClient):
Basic client library for talking to new Spalloc.
"""
__slots__ = ("__session",
"__machines_url", "__jobs_url", "version")
"__machines_url", "__jobs_url", "version",
"__group", "__collab", "__nmpi_job", "__nmpi_user")

def __init__(
self, service_url, username=None, password=None,
bearer_token=None):
bearer_token=None, group=None, collab=None, nmpi_job=None,
nmpi_user=None):
"""
:param str service_url: The reference to the service.
May have username and password supplied as part of the network
Expand All @@ -89,6 +91,10 @@ def __init__(
f"{v['major-version']}.{v['minor-version']}.{v['revision']}")
self.__machines_url = obj["machines-ref"]
self.__jobs_url = obj["jobs-ref"]
self.__group = group
self.__collab = collab
self.__nmpi_job = nmpi_job
self.__nmpi_user = nmpi_user
logger.info("established session to {} for {}", service_url, username)

@staticmethod
Expand Down Expand Up @@ -158,7 +164,15 @@ def _create(self, create, machine_name):
create["machine-name"] = machine_name
else:
create["tags"] = ["default"]
r = self.__session.post(self.__jobs_url, create)
if self.__group is not None:
create["group"] = self.__group
if self.__collab is not None:
create["nmpi-collab"] = self.__collab
if self.__nmpi_job is not None:
create["nmpi-job-id"] = self.__nmpi_job
if self.__nmpi_user is not None:
create["owner"] = self.__nmpi_user
r = self.__session.post(self.__jobs_url, create, timeout=30)
url = r.headers["Location"]
return _SpallocJob(self.__session, url)

Expand Down

0 comments on commit c360f8a

Please sign in to comment.