Skip to content

Commit 9ecd918

Browse files
authored
Merge pull request #93 from oberonia78/s1c_update
S1c update
2 parents 3e270f8 + 8fe11e5 commit 9ecd918

File tree

6 files changed

+55
-31
lines changed

6 files changed

+55
-31
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,33 @@ jobs:
4141

4242
# Set the conda environment up using Mamba and install dependencies
4343
- name: Setup Environment
44-
uses: mamba-org/setup-micromamba@main
44+
uses: mamba-org/setup-micromamba@v2
4545
with:
4646
environment-file: ${{ matrix.env-file.file }}
4747
environment-name: RTC
48+
init-shell: bash # let the action touch ~/.bash_profile
49+
log-level: debug # shows solver problems early
50+
post-cleanup: none
4851

4952
# Install the S1-Reader OPERA-ADT project.
5053
- name: Install S1-Reader
5154
run: |
5255
curl -sSL \
53-
https://github.com/opera-adt/s1-reader/archive/refs/tags/v0.2.2.tar.gz \
56+
https://github.com/opera-adt/s1-reader/archive/refs/tags/v0.2.5.tar.gz \
5457
-o s1_reader_src.tar.gz \
5558
&& tar -xvf s1_reader_src.tar.gz \
56-
&& ln -s s1-reader-0.2.2 s1-reader \
59+
&& ln -s s1-reader-0.2.5 s1-reader \
5760
&& rm s1_reader_src.tar.gz \
58-
&& python -m pip install ./s1-reader
61+
&& python -m pip install -e ./s1-reader
5962
6063
# Setup the project
6164
- name: Install Project
6265
run: python -m pip install .
6366

64-
# Test the project.
67+
# # Test the project.
6568
- name: Test Project
6669
run: |
67-
pytest -vrpP
70+
pytest -vrpP tests/
6871
6972
build_docker:
7073

@@ -100,4 +103,4 @@ jobs:
100103
# Build the image.
101104
- name: Build docker image
102105
run: |
103-
sh build_docker_image.sh
106+
bash build_docker_image.sh

Docker/Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
FROM oraclelinux:8
1+
ARG BASE_IMAGE=oraclelinux:8.8
2+
3+
FROM ${BASE_IMAGE}
4+
5+
# ARG is out of scope here unless re-declared
6+
ARG BASE_IMAGE
27

38
LABEL author="OPERA ADT" \
49
description="RTC cal/val release R4" \
@@ -37,9 +42,9 @@ SHELL ["conda", "run", "-n", "RTC", "/bin/bash", "-c"]
3742
WORKDIR /home/rtc_user/OPERA
3843

3944
# installing OPERA s1-reader
40-
RUN curl -sSL https://github.com/isce-framework/s1-reader/archive/refs/tags/v0.2.4.tar.gz -o s1_reader_src.tar.gz &&\
45+
RUN curl -sSL https://github.com/isce-framework/s1-reader/archive/refs/tags/v0.2.5.tar.gz -o s1_reader_src.tar.gz &&\
4146
tar -xvf s1_reader_src.tar.gz &&\
42-
ln -s s1-reader-0.2.4 s1-reader &&\
47+
ln -s s1-reader-0.2.5 s1-reader &&\
4348
rm s1_reader_src.tar.gz &&\
4449
python -m pip install ./s1-reader
4550

Docker/environment.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
name: rtc_s1_sas_final
22
channels:
33
- conda-forge
4+
- nodefaults
45
dependencies:
56
- python>=3.9,<3.10
67
- gdal>=3.0
7-
- s1reader>=0.2.4
8+
- s1reader>=0.2.5
89
- numpy>=1.20
910
- pybind11>=2.5
1011
- pyre>=1.11.2
11-
1212
- scipy!=1.10.0
1313
- isce3==0.15.0
1414
# Workaround for the issue with `libabseil` (09/11/2023)
15-
- libabseil=20230125.3
15+
- libabseil=20230125.3

Docker/lockfile.lock

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,4 @@ https://conda.anaconda.org/conda-forge/linux-64/libgdal-3.7.1-h880a63b_9.conda
155155
https://conda.anaconda.org/conda-forge/noarch/pooch-1.7.0-pyha770c72_3.conda
156156
https://conda.anaconda.org/conda-forge/linux-64/gdal-3.7.1-py39h41b90d8_9.conda
157157
https://conda.anaconda.org/conda-forge/linux-64/scipy-1.11.2-py39h6183b62_0.conda
158-
https://conda.anaconda.org/conda-forge/linux-64/isce3-0.15.0-py39h431996e_0.conda
159-
158+
https://conda.anaconda.org/conda-forge/linux-64/isce3-0.15.0-py39h431996e_0.conda

build_docker_image.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ REPO=opera
44
IMAGE=rtc
55
TAG=final_1.0.4
66

7+
docker_build_args=(--rm --force-rm --network host -t $REPO/$IMAGE:$TAG -f Docker/Dockerfile)
8+
9+
if [ $# -eq 0 ]; then
10+
echo "Base image was not specified. Using the default image specified in the Dockerfile."
11+
else
12+
echo "Using $1 as the base image."
13+
docker_build_args+=(--build-arg BASE_IMAGE=$1)
14+
fi
15+
716
echo "IMAGE is $REPO/$IMAGE:$TAG"
817

918
# fail on any non-zero exit codes
@@ -13,8 +22,7 @@ set -ex
1322
python3 setup.py sdist
1423

1524
# build image
16-
docker build --rm --force-rm --network host -t $REPO/$IMAGE:$TAG -f Docker/Dockerfile .
17-
25+
docker build "${docker_build_args[@]}" .
1826
# run tests - to be worked on when the RTC test module is in place
1927
#docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/mnt" -w /mnt -it --network host "${IMAGE}:$t" pytest /mnt/tests/
2028

tests/test_rtc_s1_workflow.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import requests
55
import tarfile
66
from osgeo import gdal
7+
from requests.adapters import HTTPAdapter
8+
from urllib3.util.retry import Retry
79

810
from rtc.runconfig import RunConfig, load_parameters
911
from rtc.core import create_logger
@@ -149,28 +151,35 @@ def test_workflow():
149151
os.makedirs(test_data_directory, exist_ok=True)
150152

151153
dataset_name = 's1b_los_angeles'
152-
dataset_url = ('https://zenodo.org/record/7753472/files/'
154+
dataset_url = ('https://zenodo.org/records/7753472/files/'
153155
's1b_los_angeles.tar.gz?download=1')
154156

155157
tests_dir = os.path.dirname(__file__)
156158
dataset_dir = os.path.join(test_data_directory, dataset_name)
157159
if FLAG_ALWAYS_DOWNLOAD or not os.path.isdir(dataset_dir):
158160

159-
160-
161161
print(f'Test dataset {dataset_name} not found. Downloading'
162162
f' file {dataset_url}.')
163-
response = requests.get(dataset_url)
164-
response.raise_for_status()
165-
166-
compressed_filename = os.path.join(test_data_directory,
167-
os.path.basename(dataset_url))
168-
169-
open(compressed_filename, 'wb').write(response.content)
170-
171-
print(f'Extracting downloaded file {compressed_filename}')
172-
with tarfile.open(compressed_filename) as compressed_file:
173-
compressed_file.extractall(test_data_directory)
163+
# To avoid the issue in downloading, try again.
164+
session = requests.Session()
165+
retries = Retry(
166+
total=5, # up to 5 attempts
167+
backoff_factor=2, # 2 s, 4 s, 8 s, …
168+
status_forcelist=[502, 503, 504],
169+
)
170+
session.mount("https://", HTTPAdapter(max_retries=retries))
171+
172+
compressed_path = os.path.join(test_data_directory,
173+
f"{dataset_name}.tar.gz")
174+
with session.get(dataset_url, stream=True, timeout=120) as r:
175+
r.raise_for_status()
176+
with open(compressed_path, "wb") as f:
177+
for chunk in r.iter_content(chunk_size=1024 * 1024): # 1 MB
178+
f.write(chunk)
179+
180+
print(f"Extracting {compressed_path}")
181+
with tarfile.open(compressed_path, "r:gz") as tf:
182+
tf.extractall(test_data_directory)
174183

175184
# create logger
176185
log_file = os.path.join('data', 'log.txt')

0 commit comments

Comments
 (0)