From e399d1dac0fecec5f8551697a8a7fdbec226858d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 12:20:28 +0000 Subject: [PATCH 01/13] Bump ruff from 0.12.7 to 0.12.8 in the pip-deps group Bumps the pip-deps group with 1 update: [ruff](https://github.com/astral-sh/ruff). Updates `ruff` from 0.12.7 to 0.12.8 - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.12.7...0.12.8) --- updated-dependencies: - dependency-name: ruff dependency-version: 0.12.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: pip-deps ... Signed-off-by: dependabot[bot] --- requirements-static.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-static.txt b/requirements-static.txt index 01b0c99..6d5c5e5 100644 --- a/requirements-static.txt +++ b/requirements-static.txt @@ -1,4 +1,4 @@ -ruff==0.12.7 +ruff==0.12.9 mypy==1.17.1 lxml-stubs types-shapely From 659857a105b61e210f311a724d8cb2e78735cf00 Mon Sep 17 00:00:00 2001 From: William Horn Date: Mon, 18 Aug 2025 07:45:16 -0800 Subject: [PATCH 02/13] Use replace to update lineage statement instead of elementtree.write --- src/hyp3_opera_rtc/upload_rtc.py | 11 +++++++++-- tests/test_upload_rtc.py | 19 +++++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/hyp3_opera_rtc/upload_rtc.py b/src/hyp3_opera_rtc/upload_rtc.py index fc23ee5..86f2ce9 100644 --- a/src/hyp3_opera_rtc/upload_rtc.py +++ b/src/hyp3_opera_rtc/upload_rtc.py @@ -70,9 +70,16 @@ def update_xml_with_asf_lineage(xml_path: Path) -> None: lineage = lineage_search[0] version = hyp3_opera_rtc.__version__ assert lineage.text is not None - lineage.text = f'{lineage.text.replace("JPL", "ASF")} via HyP3 OPERA-RTC v{version}' - iso_tree.write(str(xml_path)) + old_lineage = lineage.text + new_lineage = f'{old_lineage.replace("JPL", "ASF")} via HyP3 OPERA-RTC v{version}' + + with xml_path.open('r+') as f: + xml_text = f.read() + f.seek(0) + + updated_xml = xml_text.replace(old_lineage, new_lineage) + f.write(updated_xml) def main() -> None: diff --git a/tests/test_upload_rtc.py b/tests/test_upload_rtc.py index 8cddd23..286dbe9 100644 --- a/tests/test_upload_rtc.py +++ b/tests/test_upload_rtc.py @@ -92,16 +92,23 @@ def test_get_xml_with_asf_lineage(iso_xml_path): version = hyp3_opera_rtc.__version__ with iso_xml_path.open() as f: - xml_text = f.read() - assert 'ASF' not in xml_text - assert f'via HyP3 OPERA-RTC {version}' not in xml_text + xml_lines = f.readlines() upload_rtc.update_xml_with_asf_lineage(iso_xml_path) + + def is_lineage_statment(text: str) -> bool: + return 'ASF' in text and f'via HyP3 OPERA-RTC v{version}' in text + with iso_xml_path.open() as f: - xml_text = f.read() + updated_xml_lines = f.readlines() + + assert all( + old_line == updated_line + for old_line, updated_line in zip(xml_lines, updated_xml_lines) + if not is_lineage_statment(updated_line) + ) - assert 'ASF' in xml_text - assert f'via HyP3 OPERA-RTC v{version}' in xml_text + assert sum(is_lineage_statment(line) for line in updated_xml_lines) == 1 def test_cant_find_lineage_in_xml(tmp_path): From 14b482206fb7ca7b70879ad119ab86ee53212ed5 Mon Sep 17 00:00:00 2001 From: William Horn Date: Mon, 18 Aug 2025 07:48:05 -0800 Subject: [PATCH 03/13] Update function name --- tests/test_upload_rtc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_upload_rtc.py b/tests/test_upload_rtc.py index 286dbe9..fc51ef7 100644 --- a/tests/test_upload_rtc.py +++ b/tests/test_upload_rtc.py @@ -96,7 +96,7 @@ def test_get_xml_with_asf_lineage(iso_xml_path): upload_rtc.update_xml_with_asf_lineage(iso_xml_path) - def is_lineage_statment(text: str) -> bool: + def is_updated_lineage_statment(text: str) -> bool: return 'ASF' in text and f'via HyP3 OPERA-RTC v{version}' in text with iso_xml_path.open() as f: @@ -105,10 +105,10 @@ def is_lineage_statment(text: str) -> bool: assert all( old_line == updated_line for old_line, updated_line in zip(xml_lines, updated_xml_lines) - if not is_lineage_statment(updated_line) + if not is_updated_lineage_statment(updated_line) ) - assert sum(is_lineage_statment(line) for line in updated_xml_lines) == 1 + assert sum(is_updated_lineage_statment(line) for line in updated_xml_lines) == 1 def test_cant_find_lineage_in_xml(tmp_path): From fd91df9c154ba3bd52c7d149fe52ac9ef0cd7c46 Mon Sep 17 00:00:00 2001 From: William Horn Date: Mon, 18 Aug 2025 09:36:24 -0800 Subject: [PATCH 04/13] Read and write seperatly when updating xmls --- src/hyp3_opera_rtc/upload_rtc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hyp3_opera_rtc/upload_rtc.py b/src/hyp3_opera_rtc/upload_rtc.py index 86f2ce9..2902f25 100644 --- a/src/hyp3_opera_rtc/upload_rtc.py +++ b/src/hyp3_opera_rtc/upload_rtc.py @@ -74,10 +74,10 @@ def update_xml_with_asf_lineage(xml_path: Path) -> None: old_lineage = lineage.text new_lineage = f'{old_lineage.replace("JPL", "ASF")} via HyP3 OPERA-RTC v{version}' - with xml_path.open('r+') as f: + with xml_path.open('r') as f: xml_text = f.read() - f.seek(0) + with xml_path.open('w') as f: updated_xml = xml_text.replace(old_lineage, new_lineage) f.write(updated_xml) From 36ff1b8311b56197dc248be6eeac984cb7d7b07b Mon Sep 17 00:00:00 2001 From: William Horn Date: Mon, 18 Aug 2025 09:37:19 -0800 Subject: [PATCH 05/13] refactor --- src/hyp3_opera_rtc/upload_rtc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hyp3_opera_rtc/upload_rtc.py b/src/hyp3_opera_rtc/upload_rtc.py index 2902f25..13d6ef0 100644 --- a/src/hyp3_opera_rtc/upload_rtc.py +++ b/src/hyp3_opera_rtc/upload_rtc.py @@ -77,8 +77,9 @@ def update_xml_with_asf_lineage(xml_path: Path) -> None: with xml_path.open('r') as f: xml_text = f.read() + updated_xml = xml_text.replace(old_lineage, new_lineage) + with xml_path.open('w') as f: - updated_xml = xml_text.replace(old_lineage, new_lineage) f.write(updated_xml) From 62c34cfaf4cf5f80005d7815e0d3e5927e06ac7a Mon Sep 17 00:00:00 2001 From: William Horn Date: Mon, 18 Aug 2025 10:01:45 -0800 Subject: [PATCH 06/13] Update test to use expected xml file --- tests/data/updated-opera_v1.0.iso.xml | 1900 +++++++++++++++++++++++++ tests/test_upload_rtc.py | 33 +- 2 files changed, 1916 insertions(+), 17 deletions(-) create mode 100644 tests/data/updated-opera_v1.0.iso.xml diff --git a/tests/data/updated-opera_v1.0.iso.xml b/tests/data/updated-opera_v1.0.iso.xml new file mode 100644 index 0000000..459ee6e --- /dev/null +++ b/tests/data/updated-opera_v1.0.iso.xml @@ -0,0 +1,1900 @@ + + + + + OPERA_L2_RTC-S1_20231204T090220Z_S1A_30_v1.0 + + + + eng + + + + utf8 + + + + dataset + + + + + + Jet Propulsion Laboratory + + + + + + + 4800 Oak Grove Drive + + + Pasadena + + + CA + + + 91109 + + + USA + + + ops@jpl.nasa.gov + + + + + + + pointOfContact + + + + + + 2023-12-04T09:02:20.0710170000Z + + + + ISO 19115-2 Geographic Information - Metadata Part 2 Extensions for imagery and gridded data + + + ISO 19115-2:2019(E) + + + + + 2 + + + + + row + + + 3305 + + + 30.0 + + + + + + + column + + + 1506 + + + -30.0 + + + + + area + + + true + + + + + + + + + + + European Petroleum Survey Group (EPSG) Geodetic Parameter Dataset + + + + + 32626 + + + + + + + + + + + + + OPERA_L2_RTC-S1_20231204T090220Z_S1A_30_v1.0 + + + Radiometric Terrain Corrected (RTC) from Sentinel-1 + + + + + + 2023-12-04T09:02:20.0710170000Z + + + creation + + + + + 1.0 + + + + + + OPERA_L2_RTC-S1_20231204T090220Z_S1A_30_v1.0 + + + gov.nasa.esdis.umm.producergranuleid + + + ProducerGranuleId + + + + + + + + 2.1.0 + + + gov.nasa.esdis.umm.otherid + + + OtherId: PGEVersionId + + + + + + + + 1.0.1 + + + gov.nasa.esdis.umm.otherid + + + OtherId: SASVersionId + + + + + + + Jet Propulsion Repository + + + + + + originator + + + + + documentDigital + + + + + The OPERA Level 2 Radiometric Terrain Corrected (L2_RTC) product is derived from the original Copernicus Sentinel-1 (S1) A/B SLC data, with a temporal product sampling coincident with the availability of Sentinel-1 A/B SLC data. Each OPERA RTC product corresponds to a single Copernicus S1 A/B burst. + + + completed + + + + + + asNeeded + + + + + + + + OPERA + + + JPL + + + RTC + + + Radiometric + + + Terrain + + + Corrected + + + project + + + + + NASA Project Keywords + + + + + + NASA + + + User Support Office + + + + + + + https://support.earthdata.nasa.gov/ + + + Earthdata Support + + + File an issue or provide feedback + + + information + + + + + + + custodian + + + + + + + + + + + + S1 + + + platform + + + + + NASA Platform Keywords + + + + + + NASA + + + User Support Office + + + + + + + https://support.earthdata.nasa.gov/ + + + Earthdata Support + + + File an issue or provide feedback + + + information + + + + + + + custodian + + + + + + + + + + + + Sentinel 1 A/B + + instrument + + + + + NASA Instrument Keywords + + + + + + NASA + + + User Support Office + + + + + + + https://support.earthdata.nasa.gov/ + + + Earthdata Support + + + File an issue or provide feedback + + + information + + + + + + + custodian + + + + + + + + + + + + + + RTC_S1_PGE + + + gov.nasa.esdis.umm.collectionshortname + + + CollectionShortName + + + + + LargerWorkCitation + + + + + + + + + + 2.1.0 + + + gov.nasa.esdis.umm.collectionversion + + + CollectionVersion + + + + + LargerWorkCitation + + + + + + + + + + OPERA Project Homepage + + + + + + + + + + https://www.jpl.nasa.gov/go/opera + + + OPERA Project Homepage + + + information + + + + + + + custodian + + + + + + + LargerWorkCitation + + + + + grid + + + + eng + + + + utf8 + + + geoscientificInformation + + + Data product generated in HDF5 format with ISO 19115 conformant metadata. + + + + + + + + -30.94886170511729 + -29.866406758810424 + 35.9176028763907 + 36.355539817138066 + + + + + + + + + 2017-05-27T19:56:54.267407Z + 2017-05-27T19:56:57.336353Z + + + + + + + + + + + + + + MeasuredParameters + + + physicalMeasurement + + + + + + + + + + + instrumentInformation + + + AbsoluteOrbitNumber + + + Absolute orbit number + + + Unitless + + + int + + + + + 16772 + + + + + + + instrumentInformation + + + AcquisitionMode + + + Acquisition Mode + + + Unitless + + + string + + + + + IW + + + + + + + instrumentInformation + + + BoundingBox + + + Bounding box of the product, in order of xmin, ymin, xmax, ymax + + + string + + + + + [143640.0, 3982020.0, 242790.0, 4027200.0] + + + + + + + instrumentInformation + + + BurstID + + + Burst identification (burst ID) + + + Unitless + + + string + + + + + t075_159159_iw1 + + + + + + + processingInformation + + + CEOSAnalysisReadyDataDocumentIdentifier + + + CEOS Analysis Ready Data Document Identifier + + + boolean + + + + + https://ceos.org/ard/files/PFS/NRB/v5.5/CARD4L-PFS_NRB_v5.5.pdf + + + + + + + processingInformation + + + CEOSAnalysisReadyDataProductType + + + CEOS Analysis Ready Data Product Type + + + string + + + + + Normalised Radar Backscatter + + + + + + + processingInformation + + + ContactInformation + + + Contact email address + + + string + + + + + operasds@jpl.nasa.gov + + + + + + + processingInformation + + + DataAccess + + + Data Access URL + + + string + + + + + https://search.asf.alaska.edu/#/?dataset=OPERA-S1&productTypes=RTC + + + + + + + instrumentInformation + + + TrackNumber + + + Track number + + + Unitless + + + int + + + + + 75 + + + + + + + contentInformation + + + ProductType + + + Product type + + + string + + + + + RTC-S1-STATIC + + + + + + + contentInformation + + + Project + + + Project name + + + string + + + + + OPERA + + + + + + + instrumentInformation + + + RadarBand + + + Acquired frequency band + + + string + + + + + C + + + + + + + processingInformation + + + SubSwathID + + + Sub Swath ID + + + string + + + + + IW1 + + + + + + + contentInformation + + + ProductVersion + + + Product version + + + string + + + + + 1.0 + + + + + + + instrumentInformation + + + LookDirection + + + Look direction can be left or right + + + string + + + + + right + + + + + + + instrumentInformation + + + OrbitPassDirection + + + Orbit direction can be ascending or descending + + + string + + + + + ascending + + + + + + + instrumentInformation + + + Platform + + + Platform name + + + string + + + + + Sentinel-1A + + + + + + + instrumentInformation + + + ZeroDopplerStartTime + + + Azimuth start time of the product + + + dateTimeString + + + + + 2017-05-27T19:56:54.267407Z + + + + + + + instrumentInformation + + + ZeroDopplerEndTime + + + Azimuth stop time of the product + + + dateTimeString + + + + + 2017-05-27T19:56:57.336353Z + + + + + + + contentInformation + + + Institution + + + Institution name + + + string + + + + + NASA JPL + + + + + + + instrumentInformation + + + InstrumentName + + + Name of the instrument used to collect the remote sensing data provided in this product + + + string + + + + + Sentinel-1A CSAR + + + + + + + contentInformation + + + IsGeocoded + + + Flag to indicate radar geometry or geocoded product + + + boolean + + + + + True + + + + + + + processingInformation + + + ProcessingDatetime + + + Processing date and time + + + string + + + + + 2023-12-04T09:13:35.170570Z + + + + + + + processingInformation + + + ProcessingType + + + NOMINAL (or) URGENT (or) CUSTOM (or) UNDEFINED + + + string + + + + + NOMINAL + + + + + + + processingInformation + + + ProductLevel + + + Product level. L0A: Unprocessed instrument data; L0B: Reformatted, unprocessed instrument data; L1: Processed instrument data in radar coordinates system; and L2: Processed instrument data in geocoded coordinates system + + + string + + + + + L2 + + + + + + + processingInformation + + + ProductSpecificationVersion + + + Product specification version which represents the schema of this product + + + string + + + + + 1.0 + + + + + + + contentInformation + + + ListOfPolarizations + + + List of processed polarization layers + + + string + + + + + ["VV"] + + + + + + + contentInformation + + + YCoordinateSpacing + + + Nominal spacing in meters between consecutive lines + + + Meters + + + float + + + + + -30.0 + + + + + + + contentInformation + + + XCoordinateSpacing + + + Nominal spacing in meters between consecutive pixels + + + Meters + + + float + + + + + 30.0 + + + + + + + processingParameter + + + Projection + + + EPSG Projection Value + + + int + + + + + 32626 + + + + + + + processingParameter + + + BistaticDelayCorrectedApplied + + + Flag to indicate if Bi-static Delay correction was applied + + + boolean + + + + + False + + + + + + + processingParameter + + + StaticTroposphericGeolocationCorrectedApplied + + + Flag to indicate if the Static Tropospheric Geolocation correction was applied + + + boolean + + + + + False + + + + + + + processingParameter + + + FilteringApplied + + + Flag to indicate if filtering was applied + + + boolean + + + + + False + + + + + + + processingParameter + + + BurstGeogridSnapX + + + Burst Geogrid Snap X value + + + int + + + + + 30.0 + + + + + + + processingParameter + + + BurstGeogridSnapY + + + Burst Geogrid Snap Y value + + + int + + + + + 30.0 + + + + + + + processingParameter + + + InputBackscatterNormalizationConvention + + + Normalization convention for input backscatter + + + string + + + + + beta0 + + + + + + + processingParameter + + + OutputBackscatterDecibelConversionEquation + + + Output Backscatter Decibel Conversion Equation + + + string + + + + + 10*log10(backscatter_linear) + + + + + + + processingParameter + + + OutputBackscatterExpressionConvention + + + Output Backscatter Expression Convention + + + string + + + + + linear backscatter intensity + + + + + + + processingParameter + + + OutputBackscatterNormalizationConvention + + + Output Backscatter Normalization Convention + + + string + + + + + gamma0 + + + + + + + processingParameter + + + PreprocessingMultilookingApplied + + + Flag to indicate if Pre Processing Multilooking was applied + + + boolean + + + + + False + + + + + + + processingParameter + + + WetTroposphericGeolocationCorrectionApplied + + + Flag to indicate if the Wet Tropospheric Geolocation Correction was applied + + + boolean + + + + + False + + + + + + + processingInformation + + + DemEgmModel + + + DEM Earth Gravitational Model + + + string + + + + + Earth Gravitational Model 2008 (EGM2008) + + + + + + + processingInformation + + + DemInterpolation + + + DEM interpolation method + + + string + + + + + biquintic + + + + + + + processingInformation + + + Geocoding + + + Geocoding algorithm + + + string + + + + + Area-Based SAR Geocoding with Adaptive Multilooking (GEO-AP) + + + + + + + processingInformation + + + GeocodingAlgorithmReference + + + Geocoding algorithm reference document + + + string + + + + + Gustavo H. X. Shiroma, Marco Lavalle, and Sean M. Buckley, "An Area-Based Projection Algorithm for SAR Radiometric Terrain Correction and Geocoding," in IEEE Transactions on Geoscience and Remote Sensing, vol. 60, pp. 1-23, 2022, Art no. 5222723, doi: 10.1109/TGRS.2022.3147472. + + + + + + + processingInformation + + + RadiometricTerrainCorrection + + + Radiometric terrain correction (RTC) algorithm + + + string + + + + + Area-Based SAR Radiometric Terrain Correction (RTC-AP) + + + + + + + processingInformation + + + RadiometricTerrainCorrectionAlgorithmReference + + + Radiometric terrain correction algorithm reference document + + + string + + + + + Gustavo H. X. Shiroma, Marco Lavalle, and Sean M. Buckley, "An Area-Based Projection Algorithm for SAR Radiometric Terrain Correction and Geocoding," in IEEE Transactions on Geoscience and Remote Sensing, vol. 60, pp. 1-23, 2022, Art no. 5222723, doi: 10.1109/TGRS.2022.3147472. + + + + + + + processingInformation + + + S1ReaderVersion + + + S1-Reader version used for processing + + + string + + + + + 0.2.2 + + + + + + + processingInformation + + + ISCEVersion + + + ISCE version used for processing + + + string + + + + + 0.15.0 + + + + + + + processingInformation + + + SoftwareVersion + + + Software version used for processing + + + string + + + + + 1.0.1 + + + + + + + processingInformation + + + L1SlcGranules + + + List of input L1 SLC products used + + + string + + + + + ["S1A_IW_SLC__1SDV_20170527T195629_20170527T195657_016772_01BDE2_30A5.zip"] + + + + + + + processingInformation + + + orbitFiles + + + List of input orbit files used + + + string + + + + + ["S1A_OPER_AUX_POEORB_OPOD_20210302T202525_V20170526T225942_20170528T005942.EOF"] + + + + + + + processingInformation + + + AnnotationFiles + + + List of input annotation files used + + + string + + + + + ["calibration-s1a-iw1-slc-vv-20170527t195629-20170527t195657-016772-01bde2-004.xml", "noise-s1a-iw1-slc-vv-20170527t195629-20170527t195657-016772-01bde2-004.xml"] + + + + + + + processingInformation + + + DemSource + + + Source description for the utilized DEM file + + + string + + + + + Digital Elevation Model (DEM) for the NASA OPERA project version 1.1 (v1.1) based on the Copernicus DEM 30-m and Copernicus 90-m referenced to the WGS84 ellipsoid + + + + + + + instrumentInformation + + + OrbitInterpolationMethod + + + Orbit Interpolation Method + + + string + + + + + Hermite + + + + + + + instrumentInformation + + + OrbitReferenceEpoch + + + Reference epoch in the format YYYY-MM-DDTHH:MM:SS.SSS + + + string + + + + + 2017-05-25T19:56:54.267407000 + + + + + + + instrumentInformation + + + OrbitType + + + PrOE (or) NOE (or) MOE (or) POE (or) Custom + + + string + + + + + POE precise orbit + + + + + + + + + + + + + + + + + + GeoTIFF + + + + + + + + + free + + + + + + + + + + + + + + + dataset + + + + + + + OPERA L2 RTC product generated by ASF using Sentinel-1 input data and SAS version 1.0.1 via HyP3 OPERA-RTC v1.0.0 + + + + + + PGEVersionClass + + + + + + + PGEName: RTC_S1_PGE PGEVersion: 2.1.0 + + + gov.nasa.esdis.umm.pgeversionclass + + + PGEVersionClass + + + + + + + + + Radiometric Terrain Corrected (RTC) Product - OPERA_L2_RTC-S1_20231204T090220Z_S1A_30_v1.0 + + + + + + + + + + ProductionDateTime + + + 2023-12-04T09:02:20.0710170000Z + + + + + + + + GranuleInput + + + + + + /home/rtc_user/input_dir/S1A_IW_SLC__1SDV_20170527T195629_20170527T195657_016772_01BDE2_30A5.zip + + + + + + + + + + + Reference DEM - /home/rtc_user/input_dir/dem.vrt + + + + + + + Orbit Ephemerides - /home/rtc_user/input_dir/S1A_OPER_AUX_POEORB_OPOD_20210302T202525_V20170526T225942_20170528T005942.EOF + + + + + + + Burst Database - /home/rtc_user/input_dir/opera_burst_database.sqlite3 + + + + + + + + + + + asNeeded + + + + diff --git a/tests/test_upload_rtc.py b/tests/test_upload_rtc.py index fc51ef7..85536e6 100644 --- a/tests/test_upload_rtc.py +++ b/tests/test_upload_rtc.py @@ -88,27 +88,18 @@ def test_update_xmls(update_mock, tmp_path): update_mock.assert_has_calls(calls, any_order=True) -def test_get_xml_with_asf_lineage(iso_xml_path): - version = hyp3_opera_rtc.__version__ - - with iso_xml_path.open() as f: - xml_lines = f.readlines() - +@patch.object(hyp3_opera_rtc, '__version__', '1.0.0') +def test_get_xml_with_asf_lineage(iso_xml_path, updated_xml_path): upload_rtc.update_xml_with_asf_lineage(iso_xml_path) - def is_updated_lineage_statment(text: str) -> bool: - return 'ASF' in text and f'via HyP3 OPERA-RTC v{version}' in text + with updated_xml_path.open() as expected_file, iso_xml_path.open() as xml_file: + expected = expected_file.read() + updated = xml_file.read() - with iso_xml_path.open() as f: - updated_xml_lines = f.readlines() + with (Path(__file__).parent / 'data' / 'test-output-opera_v1.0.iso.xml').open('w') as f: + f.write(updated) + assert expected == updated - assert all( - old_line == updated_line - for old_line, updated_line in zip(xml_lines, updated_xml_lines) - if not is_updated_lineage_statment(updated_line) - ) - - assert sum(is_updated_lineage_statment(line) for line in updated_xml_lines) == 1 def test_cant_find_lineage_in_xml(tmp_path): @@ -128,6 +119,14 @@ def iso_xml_path(tmp_path): return xml_output_path +@pytest.fixture +def updated_xml_path(tmp_path): + xml_output_path = tmp_path / 'updated-opera_v1.0.iso.xml' + shutil.copy(Path(__file__).parent / 'data' / 'updated-opera_v1.0.iso.xml', xml_output_path) + + return xml_output_path + + @pytest.fixture def rtc_burst_results_dir(tmp_path, rtc_burst_output_files): (tmp_path / 'burst-dir').mkdir(parents=True) From fff9dc7cd4919ab060d03abab7949725af51116d Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 18 Aug 2025 10:04:52 -0800 Subject: [PATCH 07/13] delete newline --- tests/data/updated-opera_v1.0.iso.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/updated-opera_v1.0.iso.xml b/tests/data/updated-opera_v1.0.iso.xml index 459ee6e..50c0e93 100644 --- a/tests/data/updated-opera_v1.0.iso.xml +++ b/tests/data/updated-opera_v1.0.iso.xml @@ -1897,4 +1897,4 @@ - + \ No newline at end of file From 84d31e92446200b978e7f6f2f1434e8751760598 Mon Sep 17 00:00:00 2001 From: William Horn Date: Mon, 18 Aug 2025 10:09:26 -0800 Subject: [PATCH 08/13] Remove saving updated xml in test --- tests/test_prep_rtc.py | 2 +- tests/test_upload_rtc.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_prep_rtc.py b/tests/test_prep_rtc.py index 10a072c..a1fe826 100644 --- a/tests/test_prep_rtc.py +++ b/tests/test_prep_rtc.py @@ -9,7 +9,7 @@ def test_parse_response_for_params(): - test_response = json.loads(Path('tests/data/burst_response.json').read_text()) + test_response = json.loads((Path(__file__).parent / 'data' / 'burst_response.json').read_text()) slc_name, burst_id = prep_rtc.parse_response_for_burst_params(test_response) assert slc_name == 'S1A_IW_SLC__1SDV_20250413T020809_20250413T020836_058732_07464F_EF1E' assert burst_id == 't035_073251_iw2' diff --git a/tests/test_upload_rtc.py b/tests/test_upload_rtc.py index 85536e6..8aa46c1 100644 --- a/tests/test_upload_rtc.py +++ b/tests/test_upload_rtc.py @@ -96,8 +96,6 @@ def test_get_xml_with_asf_lineage(iso_xml_path, updated_xml_path): expected = expected_file.read() updated = xml_file.read() - with (Path(__file__).parent / 'data' / 'test-output-opera_v1.0.iso.xml').open('w') as f: - f.write(updated) assert expected == updated From c984bef55a3b1af398c8503dd40188004a7c4c2d Mon Sep 17 00:00:00 2001 From: William Horn Date: Mon, 18 Aug 2025 10:10:18 -0800 Subject: [PATCH 09/13] Ruff --- tests/test_upload_rtc.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_upload_rtc.py b/tests/test_upload_rtc.py index 8aa46c1..096a2cb 100644 --- a/tests/test_upload_rtc.py +++ b/tests/test_upload_rtc.py @@ -99,7 +99,6 @@ def test_get_xml_with_asf_lineage(iso_xml_path, updated_xml_path): assert expected == updated - def test_cant_find_lineage_in_xml(tmp_path): xml_path = tmp_path / 'f.xml' with xml_path.open(mode='w') as f: From 8568eb95e97f0d23cebafd51cd5c2a60d6668ebb Mon Sep 17 00:00:00 2001 From: William Horn Date: Mon, 18 Aug 2025 10:13:35 -0800 Subject: [PATCH 10/13] Changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e32421e..e118392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/) and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.1.7] + +### Fixed + +- Lineage update keep ISO XML file formatted the same as original file + ## [0.1.6] ### Added From 1945c1e1334285c0f81e20d79903ddf66decc4a9 Mon Sep 17 00:00:00 2001 From: William Horn Date: Mon, 18 Aug 2025 10:15:14 -0800 Subject: [PATCH 11/13] Update CHANGELOG.md Co-authored-by: Jake Herrmann --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e118392..2fa6347 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed -- Lineage update keep ISO XML file formatted the same as original file +- Fix lineage statement replacement to keep ISO XML file formatted the same as original file ## [0.1.6] From 82ee54cdb58544f23be8aa038c17c763b5c54f03 Mon Sep 17 00:00:00 2001 From: William Horn Date: Mon, 18 Aug 2025 10:21:32 -0800 Subject: [PATCH 12/13] Remove updated_xml fixture --- tests/test_upload_rtc.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/tests/test_upload_rtc.py b/tests/test_upload_rtc.py index 096a2cb..02424b7 100644 --- a/tests/test_upload_rtc.py +++ b/tests/test_upload_rtc.py @@ -89,14 +89,13 @@ def test_update_xmls(update_mock, tmp_path): @patch.object(hyp3_opera_rtc, '__version__', '1.0.0') -def test_get_xml_with_asf_lineage(iso_xml_path, updated_xml_path): +def test_get_xml_with_asf_lineage(iso_xml_path, tmp_path): upload_rtc.update_xml_with_asf_lineage(iso_xml_path) - with updated_xml_path.open() as expected_file, iso_xml_path.open() as xml_file: - expected = expected_file.read() - updated = xml_file.read() + expected_updated_xml = Path(__file__).parent / 'data' / 'updated-opera_v1.0.iso.xml' - assert expected == updated + expected, updated = expected_updated_xml.read_text(), iso_xml_path.read_text() + assert expected == updated def test_cant_find_lineage_in_xml(tmp_path): @@ -116,14 +115,6 @@ def iso_xml_path(tmp_path): return xml_output_path -@pytest.fixture -def updated_xml_path(tmp_path): - xml_output_path = tmp_path / 'updated-opera_v1.0.iso.xml' - shutil.copy(Path(__file__).parent / 'data' / 'updated-opera_v1.0.iso.xml', xml_output_path) - - return xml_output_path - - @pytest.fixture def rtc_burst_results_dir(tmp_path, rtc_burst_output_files): (tmp_path / 'burst-dir').mkdir(parents=True) From 1f5c88753a272a692d5e88483b40029ee755b217 Mon Sep 17 00:00:00 2001 From: William Horn Date: Mon, 18 Aug 2025 10:24:08 -0800 Subject: [PATCH 13/13] remove extra fixture --- tests/test_upload_rtc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_upload_rtc.py b/tests/test_upload_rtc.py index 02424b7..56274d1 100644 --- a/tests/test_upload_rtc.py +++ b/tests/test_upload_rtc.py @@ -89,7 +89,7 @@ def test_update_xmls(update_mock, tmp_path): @patch.object(hyp3_opera_rtc, '__version__', '1.0.0') -def test_get_xml_with_asf_lineage(iso_xml_path, tmp_path): +def test_get_xml_with_asf_lineage(iso_xml_path): upload_rtc.update_xml_with_asf_lineage(iso_xml_path) expected_updated_xml = Path(__file__).parent / 'data' / 'updated-opera_v1.0.iso.xml'