From e8cbed480cccab15bbf8205d3c4f581a99166a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Gu=C5=A1=C4=8Dius?= Date: Thu, 28 Aug 2025 09:44:16 +0300 Subject: [PATCH 1/5] unix socket support --- nomad/__init__.py | 7 ++++++- requirements.txt | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nomad/__init__.py b/nomad/__init__.py index 43437c5..8e96183 100644 --- a/nomad/__init__.py +++ b/nomad/__init__.py @@ -4,10 +4,11 @@ from typing import Optional, Union import requests +from urllib.parse import quote +from requests_unixsocket import Session from nomad import api - class Nomad: # pylint: disable=too-many-public-methods,too-many-instance-attributes """ Nomad API @@ -67,6 +68,8 @@ def __init__( # pylint: disable=too-many-arguments self.secure = secure self.port = port self.address = address or os.getenv("NOMAD_ADDR", None) + if self.address and self.address.startswith("unix://"): + self.address = "http+unix://" + quote(self.address[7:], safe = "") self.user_agent = user_agent self.region = region or os.getenv("NOMAD_REGION", None) self.timeout = timeout @@ -75,6 +78,8 @@ def __init__( # pylint: disable=too-many-arguments self.verify = verify self.cert = cert if all(cert) else () self.session = session + if self.address and self.address.startswith("http+unix://"): + self.session = Session() self.__namespace = namespace or os.getenv("NOMAD_NAMESPACE", None) self.requester_settings = { diff --git a/requirements.txt b/requirements.txt index 6e42168..c5c6223 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ requests==2.32.2 +requests-unixsocket==0.4.1 \ No newline at end of file From 78758b723c2b5b2622799f8c0d08d3e2631ea444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Gu=C5=A1=C4=8Dius?= Date: Thu, 28 Aug 2025 10:10:20 +0300 Subject: [PATCH 2/5] adding missing dep --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c44d07b..d94f5d0 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setuptools.setup( name='python-nomad', version='2.1.0', - install_requires=['requests'], + install_requires=['requests', 'requests-unixsocket'], packages=['nomad', 'nomad.api'], url='http://github.com/jrxfive/python-nomad', license='MIT', From 1c6956034037478f85771102af3f4a59ef30dc2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Gu=C5=A1=C4=8Dius?= Date: Thu, 28 Aug 2025 10:14:45 +0300 Subject: [PATCH 3/5] allow override session --- nomad/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nomad/__init__.py b/nomad/__init__.py index 8e96183..facf938 100644 --- a/nomad/__init__.py +++ b/nomad/__init__.py @@ -78,7 +78,7 @@ def __init__( # pylint: disable=too-many-arguments self.verify = verify self.cert = cert if all(cert) else () self.session = session - if self.address and self.address.startswith("http+unix://"): + if not self.session and self.address and self.address.startswith("http+unix://"): self.session = Session() self.__namespace = namespace or os.getenv("NOMAD_NAMESPACE", None) From a414f3b8f5cb4d9d70f9598c688453bb357cd18d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Gu=C5=A1=C4=8Dius?= Date: Thu, 28 Aug 2025 10:15:18 +0300 Subject: [PATCH 4/5] rev empty line --- nomad/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nomad/__init__.py b/nomad/__init__.py index facf938..55f0d0b 100644 --- a/nomad/__init__.py +++ b/nomad/__init__.py @@ -9,6 +9,7 @@ from nomad import api + class Nomad: # pylint: disable=too-many-public-methods,too-many-instance-attributes """ Nomad API From 385872e6d9c2e995f2bd3423c2ad81981b6bd2ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Gu=C5=A1=C4=8Dius?= Date: Sat, 30 May 2026 18:24:52 +0300 Subject: [PATCH 5/5] evaluate job with namespaces --- nomad/api/job.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nomad/api/job.py b/nomad/api/job.py index 5ba2502..4f7fc56 100644 --- a/nomad/api/job.py +++ b/nomad/api/job.py @@ -192,7 +192,7 @@ def register_job(self, id_, job): """ return self.request(id_, json=job, method="post").json() - def evaluate_job(self, id_): + def evaluate_job(self, id_, force_reschedule=False, namespace=None): """Creates a new evaluation for the given job. This can be used to force run the scheduling logic if necessary. @@ -200,12 +200,20 @@ def evaluate_job(self, id_): arguments: - id_ + - force_reschedule + - namespace returns: dict raises: - nomad.api.exceptions.BaseNomadException - nomad.api.exceptions.URLNotFoundNomadException """ - return self.request(id_, "evaluate", method="post").json() + json_dict = {"JobID": id_} + if force_reschedule: + json_dict["EvalOptions"] = {"ForceReschedule": force_reschedule} + params = {} + if namespace: + params["namespace"] = namespace + return self.request(id_, "evaluate", json=json_dict, params=params, method="post").json() def plan_job(self, id_, job, diff=False, policy_override=False): """Invoke a dry-run of the scheduler for the job.