Closed ionosphere80 closed 3 years ago
Hey @ionosphere80, this is definitely an un-desired behavior of the constructor. As a workaround to unblock you you can provider the address
kwarg.
n = nomad.Nomad(address='http://203.0.113.101')
This will replace https://github.com/jrxFive/python-nomad/blob/master/nomad/__init__.py#L11 and use that value instead of attempting an environment variable lookup of NOMAD_ADDR
. With address
set you do not need set the host
value.
host
is mainly left for legacy purposes, the idea behind NOMAD_ADDR
lookup is as a fallback but, I do think those assumptions should be better exposed and try to come up with a better implementation.
I refactored my code to use address=
and the NOMAD_ADDR
environment variable still overrides it.
Hmmm, I'm not able to recreate that which version of python-nomad are you using? Sorry for all the trouble, hopefully we can figure out what going on.
/ # export NOMAD_ADDR="http://example.com:4646"
/ # python
Python 3.7.1 (default, Nov 16 2018, 06:29:01)
[GCC 6.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nomad
>>> n = nomad.Nomad()
>>> n.address
'http://example.com:4646'
>>> n = nomad.Nomad(address="http://localhost:4646")
>>> n.address
'http://localhost:4646'
Hmm, I can't seem to reproduce it now either. I'm using version 1.1.0.
I'm developing a task log access feature (via the
client/fs/logs
endpoint) in a custom utility that requires connecting to a Nomad server/cluster to determine the Nomad client containing a particular allocation, connecting to that Nomad client, and accessing the stdout/stderr logs for a task in the allocation. Clients using the custom utility often contain theNOMAD_ADDR
environment variable referencing the Nomad server/cluster. During creation of aNomad
object, theNOMAD_ADDR
environment variable seems to override the value of thehost
parameter which prevents the feature from creating an additional Nomad object to access the client containing the allocation. I think the library should useNOMAD_ADDR
as a fallback instead of an override.Assume the following basic code snippet:
Debug output from the
n
object without theNOMAD_ADDR
environment variable:Debug output from the
n
object with theNOMAD_ADDR
environment variable set tohttp://host.domain.com
: