Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search S3 if granules are not Explicitly Provided #50

Merged
merged 46 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
78314e3
search s3 bucket&prefix for granules if none provided
AndrewPlayer3 Oct 2, 2024
981d7a9
updated changelog
AndrewPlayer3 Oct 2, 2024
795b71c
filter to only s1[ab]_iw_raw when searching s3
AndrewPlayer3 Oct 2, 2024
ef0d7d1
raise error if both gslc-bucket and granules are provided
AndrewPlayer3 Oct 2, 2024
f17be66
moved s3 functions to utils
AndrewPlayer3 Oct 2, 2024
1ef9f09
added test for getting gslc uris from s3
AndrewPlayer3 Oct 2, 2024
0905b01
moved tests for s3 functions
AndrewPlayer3 Oct 2, 2024
00a0303
removed unused import
AndrewPlayer3 Oct 2, 2024
723873a
corrected changelog
AndrewPlayer3 Oct 2, 2024
762f240
better changelog
AndrewPlayer3 Oct 2, 2024
d880b47
simplify gslc s3 search interface, fix pycharm warnings
jtherrmann Oct 4, 2024
5c04c22
temp hard-code granules sub-prefix, fix a typo
jtherrmann Oct 4, 2024
c7464cc
add --use-granules-from-s3 option
jtherrmann Oct 5, 2024
8c84b23
remove unexpected kwarg
jtherrmann Oct 5, 2024
09e1531
update time_series --bounds interface to match back_projection
jtherrmann Oct 7, 2024
f06485c
finish implementing gslc prefix option
jtherrmann Oct 9, 2024
0081c55
check if bucket and bucket_prefix given in back_projection workflow
jtherrmann Oct 9, 2024
e50a7e2
newlines
jtherrmann Oct 9, 2024
6d580b4
Merge pull request #51 from ASFHyP3/jth-search-s3
jtherrmann Oct 10, 2024
a781acf
rename dockerfile for test purposes
AndrewPlayer3 Oct 11, 2024
b8dc431
pin python to <3.13 due to hyp3lib bug
jtherrmann Oct 11, 2024
36a52de
Merge branch 'search-s3' of github.com:ASFHyP3/hyp3-srg into search-s3
jtherrmann Oct 11, 2024
512de27
testing multiple docker build
AndrewPlayer3 Oct 14, 2024
a00f8bb
Merge branch 'search-s3' of https://github.com/asfhyp3/hyp3-srg into …
AndrewPlayer3 Oct 14, 2024
f3d9a3e
fixed grammar in comment
AndrewPlayer3 Oct 14, 2024
9cf7e11
fail on particular input granule
jtherrmann Oct 14, 2024
4a8d440
add todo
jtherrmann Oct 14, 2024
183bd48
pin to actions develop
jtherrmann Oct 14, 2024
6f7866d
remove failure for particular granule
jtherrmann Oct 14, 2024
ad1adc3
renamed docker files
AndrewPlayer3 Oct 15, 2024
de18cff
Merge branch 'search-s3' of https://github.com/asfhyp3/hyp3-srg into …
AndrewPlayer3 Oct 15, 2024
36a0f05
pin docker action to latest release
jtherrmann Oct 15, 2024
604dea6
update changelog, revert python pin
jtherrmann Oct 15, 2024
5ab1d46
changelog version
jtherrmann Oct 15, 2024
54f8e6b
remove old todo
jtherrmann Oct 15, 2024
180f1b5
changelog tweak
jtherrmann Oct 15, 2024
f4bb3b8
remove references to manually pushing gpu image
AndrewPlayer3 Oct 15, 2024
441b41a
Merge branch 'search-s3' of https://github.com/asfhyp3/hyp3-srg into …
AndrewPlayer3 Oct 15, 2024
aa2a427
removed unnecessary checks
AndrewPlayer3 Oct 15, 2024
4a656d5
move s3 to global scope
AndrewPlayer3 Oct 15, 2024
27af46a
simplified search s3 function and removed test
AndrewPlayer3 Oct 15, 2024
62a4f82
Update src/hyp3_srg/utils.py
AndrewPlayer3 Oct 15, 2024
76dd5e0
Merge pull request #56 from ASFHyP3/jth-search-s3-updates
jtherrmann Oct 15, 2024
c2eed41
imports
jtherrmann Oct 15, 2024
46dd802
fix actions tags
jtherrmann Oct 15, 2024
7e82cc7
python 3.13
jtherrmann Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions .github/workflows/test-and-build.yml
jtherrmann marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,36 @@ jobs:
with:
local_package_name: hyp3_srg
python_versions: >-
["3.10", "3.11", "3.12"]
["3.10", "3.11", "3.12", "3.13"]

call-version-info-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected]
with:
python_version: "3.10"

call-docker-ghcr-workflow:
call-docker-ghcr-workflow-cpu:
needs: call-version-info-workflow
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/reusable-docker-ghcr.yml@v0.11.2
uses: ASFHyP3/actions/.github/workflows/reusable-docker-ghcr.yml@v0.12.0
with:
version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }}
version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }}.cpu
release_branch: main
develop_branch: develop
user: tools-bot
file: Dockerfile
secrets:
USER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

call-docker-ghcr-workflow-gpu:
needs: call-version-info-workflow
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected]
with:
version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }}.gpu
release_branch: main
develop_branch: develop
user: tools-bot
file: Dockerfile.gpu
secrets:
USER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ 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.9.0]

### Added
* A new `--use-gslc-prefix` option has been added to the `back_projection` and `time_series` workflows:
* This option causes `back_projection` to upload the GSLC outputs to a `GSLC_granules/` subprefix located within the S3 bucket and prefix given by the `--bucket` and `--bucket-prefix` options.
* This option causes `time_series` to download the GSLC inputs from the `GSLC_granules/` subprefix located within the bucket and prefix given by the `--bucket` and `--bucket-prefix` options.

### Changed
* Releases and test deployments now trigger a Docker build for both a GPU-based image and a CPU-based image. The GPU image tag ends with `.gpu` and the CPU image tag ends with `.cpu`.

### Fixed
* Fixed the parsing for the `--bounds` option for `time_series`.

## [0.8.0]

### Added
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,17 @@ aws ssm get-parameters --names /aws/service/ecs/optimized-ami/amazon-linux-2/gpu
### GPU Docker Container
Once you have a compute environment set up as described above, you can build the GPU version of the container by running:
```bash
docker build --build-arg="GPU_ARCH={YOUR_ARCH}" -t ghcr.io/asfhyp3/hyp3-srg:{RELEASE}.gpu -f Dockerfile.gpu .
docker build --build-arg="GPU_ARCH={YOUR_ARCH}" -t srg -f Dockerfile.gpu .
```

You can get the value of `COMPUTE_CAPABILITY_VERSION` by running `nvidia-smi` on the instance to obtain GPU type, then cross-reference this information with NVIDIA's [GPU type compute capability list](https://developer.nvidia.com/cuda-gpus). For a g6.2xlarge instance, this would be:
```bash
docker --build-arg="GPU_ARCH=89" -t ghcr.io/asfhyp3/hyp3-srg:{RELEASE}.gpu -f Dockerfile.gpu .
docker --build-arg="GPU_ARCH=89" -t srg -f Dockerfile.gpu .
```
The compute capability version will always be the same for a given instance type, so you will only need to look this up once per instance type.
The default value for this argument is `89` - the correct value for g6.2xlarge instances.
**THE COMPUTE CAPABILITY VERSION MUST MATCH ON BOTH THE BUILDING AND RUNNING MACHINE!**

The value of `RELEASE` can be obtained from the git tags.

You can push a manual container to HyP3-SRG's container repository by following [this guide](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#pushing-container-images).

### EC2 Setup
> [!CAUTION]
> Running the docker container on an Amazon Linux 2023 Deep Learning AMI runs, but will result in all zero outputs. Work is ongoing to determine what is causing this issue. For now, we recommend using option 2.3.
Expand All @@ -104,5 +100,5 @@ When running on an EC2 instance, the following setup is recommended:
3. Use the latest AWS ECS-optimized GPU AMI (`aws ssm get-parameters --names /aws/service/ecs/optimized-ami/amazon-linux-2/gpu/recommended --region us-west-2`)
3. Build the GPU docker container with the correct compute capability version (see section above). To determine this value, run `nvidia-smi` on the instance to obtain GPU type, then cross-referencke this information with NVIDIA's [GPU type compute capability list](https://developer.nvidia.com/cuda-gpus). For a g6.2xlarge instance, this would be:
```bash
docker --build-arg="GPU_ARCH=89" -t ghcr.io/asfhyp3/hyp3-srg:{RELEASE}.gpu -f Dockerfile.gpu .
docker --build-arg="GPU_ARCH=89" -t srg -f Dockerfile.gpu .
```
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ dependencies:
- asf_search
# For running
- hyp3lib>=3,<4
- s1_orbits
- s1_orbits
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"hyp3lib>=3,<4",
Expand Down
18 changes: 18 additions & 0 deletions src/hyp3_srg/back_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def back_project(
earthdata_password: str = None,
bucket: str = None,
bucket_prefix: str = '',
use_gslc_prefix: bool = False,
work_dir: Optional[Path] = None,
gpu: bool = False,
):
Expand All @@ -104,9 +105,15 @@ def back_project(
earthdata_password: Password for NASA's EarthData service
bucket: AWS S3 bucket for uploading the final product(s)
bucket_prefix: Add a bucket prefix to the product(s)
use_gslc_prefix: Upload GSLCs to a subprefix
work_dir: Working directory for processing
gpu: Use the GPU-based version of the workflow
"""
if use_gslc_prefix:
if not (bucket and bucket_prefix):
raise ValueError('bucket and bucket_prefix must be given if use_gslc_prefix is True')
bucket_prefix += '/GSLC_granules'

utils.set_creds('EARTHDATA', earthdata_username, earthdata_password)
if work_dir is None:
work_dir = Path.cwd()
Expand Down Expand Up @@ -149,6 +156,14 @@ def main():
parser.add_argument('--earthdata-password', default=None, help="Password for NASA's EarthData")
parser.add_argument('--bucket', help='AWS S3 bucket HyP3 for upload the final product(s)')
parser.add_argument('--bucket-prefix', default='', help='Add a bucket prefix to product(s)')
parser.add_argument(
'--use-gslc-prefix',
action='store_true',
help=(
'Upload GSLC granules to a subprefix located within the bucket and prefix given by the'
' --bucket and --bucket-prefix options'
)
)
parser.add_argument('--gpu', default=False, action='store_true', help='Use the GPU-based version of the workflow.')
parser.add_argument(
'--bounds',
Expand All @@ -159,11 +174,14 @@ def main():
)
parser.add_argument('granules', type=str.split, nargs='+', help='Level-0 S1 granule(s) to back-project.')
args = parser.parse_args()

args.granules = [item for sublist in args.granules for item in sublist]

if args.bounds is not None:
args.bounds = [float(item) for sublist in args.bounds for item in sublist]
if len(args.bounds) != 4:
parser.error('Bounds must have exactly 4 values: [min lon, min lat, max lon, max lat] in EPSG:4326.')

back_project(**args.__dict__)


Expand Down
2 changes: 1 addition & 1 deletion src/hyp3_srg/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def download_dem_for_srg(bounds: list[float], work_dir: Optional[Path]):

Args:
bounds: The bounds of the extent of the desired DEM - [min_lon, min_lat, max_lon, max_lat].
work_dir: The directory to save create the DEM in
work_dir: The directory to save the DEM in

Returns:
The path to the downloaded DEM
Expand Down
Loading
Loading