Skip to content

Commit 8832f88

Browse files
committed
feat: Add User-Agent header to Harmony job requests using package name and version; update changelog (#63)
1 parent bb51fba commit 8832f88

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- [issues/84](https://github.com/podaac/bignbit/issues/84): New parameter in dataset config `subdaily` that sends DataDateTime to GIBS instead of DataDay.
1212
- Added optional `concept_id` keyword to dataset config to provide an override for finding the proper CMR collection concept ID when testing.
1313
### Changed
14+
- [issues/63](https://github.com/podaac/bignbit/issues/63): Harmony job submission now includes a User-Agent header with the package name and version, improving traceability and compliance with best practices.
1415
### Deprecated
1516
### Removed
1617
### Fixed

bignbit/submit_harmony_job.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
import os
55
import urllib.parse
6+
from importlib.metadata import version, PackageNotFoundError
67

78
from cumulus_logger import CumulusLogger
89
from cumulus_process import Process
@@ -61,8 +62,17 @@ def submit_harmony_job(cmr_env, collection_concept_id, collection_name, granule_
6162
harmony_request = generate_harmony_request(collection_concept_id, granule_concept_id, variable, big_config,
6263
destination_bucket_url)
6364

65+
# Get package name and version from installed metadata
66+
pkg_name = "bignbit"
67+
try:
68+
pkg_version = version(pkg_name)
69+
except PackageNotFoundError:
70+
pkg_version = "unknown"
71+
user_agent = f"{pkg_name}/{pkg_version}"
72+
6473
CUMULUS_LOGGER.info("Submitting Harmony request: {}", harmony_client.request_as_url(harmony_request))
65-
job = harmony_client.submit(harmony_request)
74+
# Pass User-Agent header to Harmony client submit
75+
job = harmony_client.submit(harmony_request, headers={"User-Agent": user_agent})
6676
harmony_job = {
6777
'job': job,
6878
'granule_id': granule_id,

0 commit comments

Comments
 (0)