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/4] 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/4] 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/4] 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/4] 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