I ran into a problem where harmony when running an ASDC provided example. The snippet to reproduce the problem is shown below, and will fail if the user has an environmental variable named ENVIRONMENT defined. The computational cluster that I work on has ENVIRONMENT=BATCH or ENVIRONMENT=INTERACTVIE set depending on how it was accessed.
The harmony.config.Config class defers all properties to the environment (if present) in the __getattribute__ interface override. I would happily submit a PR that sets certain properties to use actual properties. I would propose the following: environment, localhost_port, harmony_hostname, url_scheme, root_url, and edl_validation_url. At present, these can be overwritten by the environmental variables. At the bare-minimum, I don't think environment should be overwritten because it is set by instantiation.
Example Code
from datetime import datetime
from harmony import BBox, WKT, Client, Collection, Request, Environment
import os
os.environ['ENVIRONMENT'] = 'BATCH' # not required if actually set in user's environment, as is my cluster
# work around:
# del os.environ['ENVIRONMENT']
harmony_client = Client(env=Environment.PROD)
# "Nitrogen Dioxide total column"
request = Request(
collection=Collection(id="C2930725014-LARC_CLOUD"),
granule_name=["TEMPO_NO2_L2_V03_20250406T215103Z_S012G07.nc"],
)
request.is_valid()
job_id = harmony_client.submit(request)
results = harmony_client.download_all(job_id, directory='./tmp', overwrite=True)
Example Error
The error that you get is:
Traceback (most recent call last):
File "/work/ROMO/users/user/temp/testharm/test.py", line 5, in <module>
harmony_client = Client(env=Environment.PROD)
File "/home/user/.local/lib/python3.9/site-packages/harmony/client.py", line 158, in __init__
validate_auth(self.config, self._session())
File "/home/user/.local/lib/python3.9/site-packages/harmony/auth.py", line 144, in validate_auth
url = config.edl_validation_url
File "/home/user/.local/lib/python3.9/site-packages/harmony/config.py", line 98, in __getattribute__
var = object.__getattribute__(self, name)
File "/home/user/.local/lib/python3.9/site-packages/harmony/config.py", line 77, in edl_validation_url
return f'{self.root_url}/jobs'
File "/home/user/.local/lib/python3.9/site-packages/harmony/config.py", line 98, in __getattribute__
var = object.__getattribute__(self, name)
File "/home/user/.local/lib/python3.9/site-packages/harmony/config.py", line 70, in root_url
return f'{self.url_scheme}://{self.harmony_hostname}'
File "/home/user/.local/lib/python3.9/site-packages/harmony/config.py", line 98, in __getattribute__
var = object.__getattribute__(self, name)
File "/home/user/.local/lib/python3.9/site-packages/harmony/config.py", line 59, in harmony_hostname
return HOSTNAMES[self.environment]
KeyError: 'BATCH'
I ran into a problem where harmony when running an ASDC provided example. The snippet to reproduce the problem is shown below, and will fail if the user has an environmental variable named ENVIRONMENT defined. The computational cluster that I work on has ENVIRONMENT=BATCH or ENVIRONMENT=INTERACTVIE set depending on how it was accessed.
The
harmony.config.Configclass defers all properties to the environment (if present) in the__getattribute__interface override. I would happily submit a PR that sets certain properties to use actual properties. I would propose the following: environment, localhost_port, harmony_hostname, url_scheme, root_url, and edl_validation_url. At present, these can be overwritten by the environmental variables. At the bare-minimum, I don't think environment should be overwritten because it is set by instantiation.Example Code
Example Error
The error that you get is: