From d40a2f637beb36f60b77fe435e1f441fa392c32a Mon Sep 17 00:00:00 2001 From: mike-gangl <59702631+mike-gangl@users.noreply.github.com> Date: Fri, 29 Mar 2024 13:01:42 -0700 Subject: [PATCH] 0.4.0 release (#85) Co-authored-by: Anil Natha * Added support for custom metadata definition and search (#81) * Added support for custom metadata definition and search * Updated CHANGELOG.md * Update collection.py (#82) remove print statement that was annoying me. * Stac updates (#84) * added stac out put options to data_services call, added properties parsing to datasets * aded test dataset for properties * updated changelog * bump version * Update CHANGELOG.md Updated 0.4.0 release and date. --------- Co-authored-by: Anil Natha Co-authored-by: Rishi Verma Co-authored-by: Anil Natha Co-authored-by: Rob Tapella Co-authored-by: Nga Chung <17833879+ngachung@users.noreply.github.com> --- CHANGELOG.md | 18 ++- poetry.lock | 131 +++++++++--------- pyproject.toml | 2 +- tests/test_files/config_override.cfg | 2 + tests/test_files/dataset_with_properties.json | 1 + tests/test_unity_data_service.py | 50 +++++++ tests/test_unity_py.py | 12 ++ tests/test_unity_stac.py | 9 ++ unity_sds_client/resources/collection.py | 2 +- unity_sds_client/resources/dataset.py | 8 +- unity_sds_client/services/data_service.py | 124 ++++++++++++++++- unity_sds_client/unity.py | 8 +- 12 files changed, 289 insertions(+), 78 deletions(-) create mode 100644 tests/test_files/config_override.cfg create mode 100644 tests/test_files/dataset_with_properties.json create mode 100644 tests/test_unity_data_service.py diff --git a/CHANGELOG.md b/CHANGELOG.md index e1eaaef..84f5946 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,25 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.4.0] - 2024-03-29 +### Added +* We've added the ability to override settings in the default config file by passing in a config file with the settings needing to be overridden when instantiating a Unity object. [56](https://github.com/unity-sds/unity-py/issues/56) +* Collection creation (create_collection) through dataService library +* Added support for defining custom metadata for project and venue. +* Added methods to return STAC content instead of unity domain objects if requested +* Added properties parsing of stac metadata to dataset objects +### Fixed +### Changed +* Updated get_collections and get_collection_data to support limit parameter. +* Updated get_collection_data to support filter parameter which takes CQL string. +### Removed +### Security +### Deprecated + + +## [0.3.0] - 2024-02-12 -## Unreleased [0.3.0] ### Added ### Fixed * fixed an issue with encoding a json deploy request twice [71](https://github.com/unity-sds/unity-py/issues/71) diff --git a/poetry.lock b/poetry.lock index 3cef4a5..0ea361e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2,13 +2,13 @@ [[package]] name = "certifi" -version = "2023.11.17" +version = "2024.2.2" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2023.11.17-py3-none-any.whl", hash = "sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474"}, - {file = "certifi-2023.11.17.tar.gz", hash = "sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1"}, + {file = "certifi-2024.2.2-py3-none-any.whl", hash = "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"}, + {file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"}, ] [[package]] @@ -123,63 +123,63 @@ files = [ [[package]] name = "coverage" -version = "7.3.2" +version = "7.4.2" description = "Code coverage measurement for Python" optional = false python-versions = ">=3.8" files = [ - {file = "coverage-7.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d872145f3a3231a5f20fd48500274d7df222e291d90baa2026cc5152b7ce86bf"}, - {file = "coverage-7.3.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:310b3bb9c91ea66d59c53fa4989f57d2436e08f18fb2f421a1b0b6b8cc7fffda"}, - {file = "coverage-7.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f47d39359e2c3779c5331fc740cf4bce6d9d680a7b4b4ead97056a0ae07cb49a"}, - {file = "coverage-7.3.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:aa72dbaf2c2068404b9870d93436e6d23addd8bbe9295f49cbca83f6e278179c"}, - {file = "coverage-7.3.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:beaa5c1b4777f03fc63dfd2a6bd820f73f036bfb10e925fce067b00a340d0f3f"}, - {file = "coverage-7.3.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:dbc1b46b92186cc8074fee9d9fbb97a9dd06c6cbbef391c2f59d80eabdf0faa6"}, - {file = "coverage-7.3.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:315a989e861031334d7bee1f9113c8770472db2ac484e5b8c3173428360a9148"}, - {file = "coverage-7.3.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d1bc430677773397f64a5c88cb522ea43175ff16f8bfcc89d467d974cb2274f9"}, - {file = "coverage-7.3.2-cp310-cp310-win32.whl", hash = "sha256:a889ae02f43aa45032afe364c8ae84ad3c54828c2faa44f3bfcafecb5c96b02f"}, - {file = "coverage-7.3.2-cp310-cp310-win_amd64.whl", hash = "sha256:c0ba320de3fb8c6ec16e0be17ee1d3d69adcda99406c43c0409cb5c41788a611"}, - {file = "coverage-7.3.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ac8c802fa29843a72d32ec56d0ca792ad15a302b28ca6203389afe21f8fa062c"}, - {file = "coverage-7.3.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:89a937174104339e3a3ffcf9f446c00e3a806c28b1841c63edb2b369310fd074"}, - {file = "coverage-7.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e267e9e2b574a176ddb983399dec325a80dbe161f1a32715c780b5d14b5f583a"}, - {file = "coverage-7.3.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2443cbda35df0d35dcfb9bf8f3c02c57c1d6111169e3c85fc1fcc05e0c9f39a3"}, - {file = "coverage-7.3.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4175e10cc8dda0265653e8714b3174430b07c1dca8957f4966cbd6c2b1b8065a"}, - {file = "coverage-7.3.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:0cbf38419fb1a347aaf63481c00f0bdc86889d9fbf3f25109cf96c26b403fda1"}, - {file = "coverage-7.3.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:5c913b556a116b8d5f6ef834038ba983834d887d82187c8f73dec21049abd65c"}, - {file = "coverage-7.3.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:1981f785239e4e39e6444c63a98da3a1db8e971cb9ceb50a945ba6296b43f312"}, - {file = "coverage-7.3.2-cp311-cp311-win32.whl", hash = "sha256:43668cabd5ca8258f5954f27a3aaf78757e6acf13c17604d89648ecc0cc66640"}, - {file = "coverage-7.3.2-cp311-cp311-win_amd64.whl", hash = "sha256:e10c39c0452bf6e694511c901426d6b5ac005acc0f78ff265dbe36bf81f808a2"}, - {file = "coverage-7.3.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:4cbae1051ab791debecc4a5dcc4a1ff45fc27b91b9aee165c8a27514dd160836"}, - {file = "coverage-7.3.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:12d15ab5833a997716d76f2ac1e4b4d536814fc213c85ca72756c19e5a6b3d63"}, - {file = "coverage-7.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3c7bba973ebee5e56fe9251300c00f1579652587a9f4a5ed8404b15a0471f216"}, - {file = "coverage-7.3.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fe494faa90ce6381770746077243231e0b83ff3f17069d748f645617cefe19d4"}, - {file = "coverage-7.3.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f6e9589bd04d0461a417562649522575d8752904d35c12907d8c9dfeba588faf"}, - {file = "coverage-7.3.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:d51ac2a26f71da1b57f2dc81d0e108b6ab177e7d30e774db90675467c847bbdf"}, - {file = "coverage-7.3.2-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:99b89d9f76070237975b315b3d5f4d6956ae354a4c92ac2388a5695516e47c84"}, - {file = "coverage-7.3.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:fa28e909776dc69efb6ed975a63691bc8172b64ff357e663a1bb06ff3c9b589a"}, - {file = "coverage-7.3.2-cp312-cp312-win32.whl", hash = "sha256:289fe43bf45a575e3ab10b26d7b6f2ddb9ee2dba447499f5401cfb5ecb8196bb"}, - {file = "coverage-7.3.2-cp312-cp312-win_amd64.whl", hash = "sha256:7dbc3ed60e8659bc59b6b304b43ff9c3ed858da2839c78b804973f613d3e92ed"}, - {file = "coverage-7.3.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f94b734214ea6a36fe16e96a70d941af80ff3bfd716c141300d95ebc85339738"}, - {file = "coverage-7.3.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:af3d828d2c1cbae52d34bdbb22fcd94d1ce715d95f1a012354a75e5913f1bda2"}, - {file = "coverage-7.3.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:630b13e3036e13c7adc480ca42fa7afc2a5d938081d28e20903cf7fd687872e2"}, - {file = "coverage-7.3.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c9eacf273e885b02a0273bb3a2170f30e2d53a6d53b72dbe02d6701b5296101c"}, - {file = "coverage-7.3.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d8f17966e861ff97305e0801134e69db33b143bbfb36436efb9cfff6ec7b2fd9"}, - {file = "coverage-7.3.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b4275802d16882cf9c8b3d057a0839acb07ee9379fa2749eca54efbce1535b82"}, - {file = "coverage-7.3.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:72c0cfa5250f483181e677ebc97133ea1ab3eb68645e494775deb6a7f6f83901"}, - {file = "coverage-7.3.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:cb536f0dcd14149425996821a168f6e269d7dcd2c273a8bff8201e79f5104e76"}, - {file = "coverage-7.3.2-cp38-cp38-win32.whl", hash = "sha256:307adb8bd3abe389a471e649038a71b4eb13bfd6b7dd9a129fa856f5c695cf92"}, - {file = "coverage-7.3.2-cp38-cp38-win_amd64.whl", hash = "sha256:88ed2c30a49ea81ea3b7f172e0269c182a44c236eb394718f976239892c0a27a"}, - {file = "coverage-7.3.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b631c92dfe601adf8f5ebc7fc13ced6bb6e9609b19d9a8cd59fa47c4186ad1ce"}, - {file = "coverage-7.3.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:d3d9df4051c4a7d13036524b66ecf7a7537d14c18a384043f30a303b146164e9"}, - {file = "coverage-7.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5f7363d3b6a1119ef05015959ca24a9afc0ea8a02c687fe7e2d557705375c01f"}, - {file = "coverage-7.3.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2f11cc3c967a09d3695d2a6f03fb3e6236622b93be7a4b5dc09166a861be6d25"}, - {file = "coverage-7.3.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:149de1d2401ae4655c436a3dced6dd153f4c3309f599c3d4bd97ab172eaf02d9"}, - {file = "coverage-7.3.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:3a4006916aa6fee7cd38db3bfc95aa9c54ebb4ffbfc47c677c8bba949ceba0a6"}, - {file = "coverage-7.3.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9028a3871280110d6e1aa2df1afd5ef003bab5fb1ef421d6dc748ae1c8ef2ebc"}, - {file = "coverage-7.3.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:9f805d62aec8eb92bab5b61c0f07329275b6f41c97d80e847b03eb894f38d083"}, - {file = "coverage-7.3.2-cp39-cp39-win32.whl", hash = "sha256:d1c88ec1a7ff4ebca0219f5b1ef863451d828cccf889c173e1253aa84b1e07ce"}, - {file = "coverage-7.3.2-cp39-cp39-win_amd64.whl", hash = "sha256:b4767da59464bb593c07afceaddea61b154136300881844768037fd5e859353f"}, - {file = "coverage-7.3.2-pp38.pp39.pp310-none-any.whl", hash = "sha256:ae97af89f0fbf373400970c0a21eef5aa941ffeed90aee43650b81f7d7f47637"}, - {file = "coverage-7.3.2.tar.gz", hash = "sha256:be32ad29341b0170e795ca590e1c07e81fc061cb5b10c74ce7203491484404ef"}, + {file = "coverage-7.4.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:bf54c3e089179d9d23900e3efc86d46e4431188d9a657f345410eecdd0151f50"}, + {file = "coverage-7.4.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fe6e43c8b510719b48af7db9631b5fbac910ade4bd90e6378c85ac5ac706382c"}, + {file = "coverage-7.4.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8b98c89db1b150d851a7840142d60d01d07677a18f0f46836e691c38134ed18b"}, + {file = "coverage-7.4.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c5f9683be6a5b19cd776ee4e2f2ffb411424819c69afab6b2db3a0a364ec6642"}, + {file = "coverage-7.4.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:78cdcbf7b9cb83fe047ee09298e25b1cd1636824067166dc97ad0543b079d22f"}, + {file = "coverage-7.4.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:2599972b21911111114100d362aea9e70a88b258400672626efa2b9e2179609c"}, + {file = "coverage-7.4.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:ef00d31b7569ed3cb2036f26565f1984b9fc08541731ce01012b02a4c238bf03"}, + {file = "coverage-7.4.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:20a875bfd8c282985c4720c32aa05056f77a68e6d8bbc5fe8632c5860ee0b49b"}, + {file = "coverage-7.4.2-cp310-cp310-win32.whl", hash = "sha256:b3f2b1eb229f23c82898eedfc3296137cf1f16bb145ceab3edfd17cbde273fb7"}, + {file = "coverage-7.4.2-cp310-cp310-win_amd64.whl", hash = "sha256:7df95fdd1432a5d2675ce630fef5f239939e2b3610fe2f2b5bf21fa505256fa3"}, + {file = "coverage-7.4.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:a8ddbd158e069dded57738ea69b9744525181e99974c899b39f75b2b29a624e2"}, + {file = "coverage-7.4.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:81a5fb41b0d24447a47543b749adc34d45a2cf77b48ca74e5bf3de60a7bd9edc"}, + {file = "coverage-7.4.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2412e98e70f16243be41d20836abd5f3f32edef07cbf8f407f1b6e1ceae783ac"}, + {file = "coverage-7.4.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ddb79414c15c6f03f56cc68fa06994f047cf20207c31b5dad3f6bab54a0f66ef"}, + {file = "coverage-7.4.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cf89ab85027427d351f1de918aff4b43f4eb5f33aff6835ed30322a86ac29c9e"}, + {file = "coverage-7.4.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:a178b7b1ac0f1530bb28d2e51f88c0bab3e5949835851a60dda80bff6052510c"}, + {file = "coverage-7.4.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:06fe398145a2e91edaf1ab4eee66149c6776c6b25b136f4a86fcbbb09512fd10"}, + {file = "coverage-7.4.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:18cac867950943fe93d6cd56a67eb7dcd2d4a781a40f4c1e25d6f1ed98721a55"}, + {file = "coverage-7.4.2-cp311-cp311-win32.whl", hash = "sha256:f72cdd2586f9a769570d4b5714a3837b3a59a53b096bb954f1811f6a0afad305"}, + {file = "coverage-7.4.2-cp311-cp311-win_amd64.whl", hash = "sha256:d779a48fac416387dd5673fc5b2d6bd903ed903faaa3247dc1865c65eaa5a93e"}, + {file = "coverage-7.4.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:adbdfcda2469d188d79771d5696dc54fab98a16d2ef7e0875013b5f56a251047"}, + {file = "coverage-7.4.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ac4bab32f396b03ebecfcf2971668da9275b3bb5f81b3b6ba96622f4ef3f6e17"}, + {file = "coverage-7.4.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:006d220ba2e1a45f1de083d5022d4955abb0aedd78904cd5a779b955b019ec73"}, + {file = "coverage-7.4.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3733545eb294e5ad274abe131d1e7e7de4ba17a144505c12feca48803fea5f64"}, + {file = "coverage-7.4.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:42a9e754aa250fe61f0f99986399cec086d7e7a01dd82fd863a20af34cbce962"}, + {file = "coverage-7.4.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:2ed37e16cf35c8d6e0b430254574b8edd242a367a1b1531bd1adc99c6a5e00fe"}, + {file = "coverage-7.4.2-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:b953275d4edfab6cc0ed7139fa773dfb89e81fee1569a932f6020ce7c6da0e8f"}, + {file = "coverage-7.4.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:32b4ab7e6c924f945cbae5392832e93e4ceb81483fd6dc4aa8fb1a97b9d3e0e1"}, + {file = "coverage-7.4.2-cp312-cp312-win32.whl", hash = "sha256:f5df76c58977bc35a49515b2fbba84a1d952ff0ec784a4070334dfbec28a2def"}, + {file = "coverage-7.4.2-cp312-cp312-win_amd64.whl", hash = "sha256:34423abbaad70fea9d0164add189eabaea679068ebdf693baa5c02d03e7db244"}, + {file = "coverage-7.4.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5b11f9c6587668e495cc7365f85c93bed34c3a81f9f08b0920b87a89acc13469"}, + {file = "coverage-7.4.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:51593a1f05c39332f623d64d910445fdec3d2ac2d96b37ce7f331882d5678ddf"}, + {file = "coverage-7.4.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69f1665165ba2fe7614e2f0c1aed71e14d83510bf67e2ee13df467d1c08bf1e8"}, + {file = "coverage-7.4.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b3c8bbb95a699c80a167478478efe5e09ad31680931ec280bf2087905e3b95ec"}, + {file = "coverage-7.4.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:175f56572f25e1e1201d2b3e07b71ca4d201bf0b9cb8fad3f1dfae6a4188de86"}, + {file = "coverage-7.4.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:8562ca91e8c40864942615b1d0b12289d3e745e6b2da901d133f52f2d510a1e3"}, + {file = "coverage-7.4.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:d9a1ef0f173e1a19738f154fb3644f90d0ada56fe6c9b422f992b04266c55d5a"}, + {file = "coverage-7.4.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:f40ac873045db4fd98a6f40387d242bde2708a3f8167bd967ccd43ad46394ba2"}, + {file = "coverage-7.4.2-cp38-cp38-win32.whl", hash = "sha256:d1b750a8409bec61caa7824bfd64a8074b6d2d420433f64c161a8335796c7c6b"}, + {file = "coverage-7.4.2-cp38-cp38-win_amd64.whl", hash = "sha256:b4ae777bebaed89e3a7e80c4a03fac434a98a8abb5251b2a957d38fe3fd30088"}, + {file = "coverage-7.4.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3ff7f92ae5a456101ca8f48387fd3c56eb96353588e686286f50633a611afc95"}, + {file = "coverage-7.4.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:861d75402269ffda0b33af94694b8e0703563116b04c681b1832903fac8fd647"}, + {file = "coverage-7.4.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3507427d83fa961cbd73f11140f4a5ce84208d31756f7238d6257b2d3d868405"}, + {file = "coverage-7.4.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bf711d517e21fb5bc429f5c4308fbc430a8585ff2a43e88540264ae87871e36a"}, + {file = "coverage-7.4.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c00e54f0bd258ab25e7f731ca1d5144b0bf7bec0051abccd2bdcff65fa3262c9"}, + {file = "coverage-7.4.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:f8e845d894e39fb53834da826078f6dc1a933b32b1478cf437007367efaf6f6a"}, + {file = "coverage-7.4.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:840456cb1067dc350af9080298c7c2cfdddcedc1cb1e0b30dceecdaf7be1a2d3"}, + {file = "coverage-7.4.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:c11ca2df2206a4e3e4c4567f52594637392ed05d7c7fb73b4ea1c658ba560265"}, + {file = "coverage-7.4.2-cp39-cp39-win32.whl", hash = "sha256:3ff5bdb08d8938d336ce4088ca1a1e4b6c8cd3bef8bb3a4c0eb2f37406e49643"}, + {file = "coverage-7.4.2-cp39-cp39-win_amd64.whl", hash = "sha256:ac9e95cefcf044c98d4e2c829cd0669918585755dd9a92e28a1a7012322d0a95"}, + {file = "coverage-7.4.2-pp38.pp39.pp310-none-any.whl", hash = "sha256:f593a4a90118d99014517c2679e04a4ef5aee2d81aa05c26c734d271065efcb6"}, + {file = "coverage-7.4.2.tar.gz", hash = "sha256:1a5ee18e3a8d766075ce9314ed1cb695414bae67df6a4b0805f5137d93d6f1cb"}, ] [package.dependencies] @@ -293,13 +293,13 @@ files = [ [[package]] name = "pluggy" -version = "1.3.0" +version = "1.4.0" description = "plugin and hook calling mechanisms for python" optional = false python-versions = ">=3.8" files = [ - {file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"}, - {file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"}, + {file = "pluggy-1.4.0-py3-none-any.whl", hash = "sha256:7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981"}, + {file = "pluggy-1.4.0.tar.gz", hash = "sha256:8c85c2876142a764e5b7548e7d9a0e0ddb46f5185161049a79b7e974454223be"}, ] [package.extras] @@ -354,13 +354,13 @@ validation = ["jsonschema (>=4.18,<5.0)"] [[package]] name = "pytest" -version = "7.4.3" +version = "7.4.4" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.7" files = [ - {file = "pytest-7.4.3-py3-none-any.whl", hash = "sha256:0d009c083ea859a71b76adf7c1d502e4bc170b80a8ef002da5806527b9591fac"}, - {file = "pytest-7.4.3.tar.gz", hash = "sha256:d989d136982de4e3b29dabcc838ad581c64e8ed52c11fbe86ddebd9da0818cd5"}, + {file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"}, + {file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"}, ] [package.dependencies] @@ -482,17 +482,18 @@ files = [ [[package]] name = "urllib3" -version = "2.1.0" +version = "2.2.1" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.8" files = [ - {file = "urllib3-2.1.0-py3-none-any.whl", hash = "sha256:55901e917a5896a349ff771be919f8bd99aff50b79fe58fec595eb37bbc56bb3"}, - {file = "urllib3-2.1.0.tar.gz", hash = "sha256:df7aa8afb0148fa78488e7899b2c59b5f4ffcfa82e6c54ccb9dd37c1d7b52d54"}, + {file = "urllib3-2.2.1-py3-none-any.whl", hash = "sha256:450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d"}, + {file = "urllib3-2.2.1.tar.gz", hash = "sha256:d0570876c61ab9e520d776c38acbbb5b05a776d3f9ff98a5c8fd5162a444cf19"}, ] [package.extras] brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] +h2 = ["h2 (>=4,<5)"] socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] diff --git a/pyproject.toml b/pyproject.toml index f0f1aed..9303871 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "unity-sds-client" -version = "0.3.0" +version = "0.4.0" description = "Unity-Py is a Python client to simplify interactions with NASA's Unity Platform." authors = ["Anil Natha, Mike Gangl"] readme = "README.md" diff --git a/tests/test_files/config_override.cfg b/tests/test_files/config_override.cfg new file mode 100644 index 0000000..4c82bae --- /dev/null +++ b/tests/test_files/config_override.cfg @@ -0,0 +1,2 @@ +[TEST] +client_id = THIS_IS_A_TEST_CLIENT_ID \ No newline at end of file diff --git a/tests/test_files/dataset_with_properties.json b/tests/test_files/dataset_with_properties.json new file mode 100644 index 0000000..1fd43cf --- /dev/null +++ b/tests/test_files/dataset_with_properties.json @@ -0,0 +1 @@ +{"numberMatched":{"total_size":2},"numberReturned":2,"stac_version":"1.0.0","type":"FeatureCollection","links":[{"rel":"self","href":"https://dxebrgu0bc9w7.cloudfront.net/am-uds-dapa/collections/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/items?limit=10"},{"rel":"root","href":"https://dxebrgu0bc9w7.cloudfront.net"}],"features":[{"type":"Feature","stac_version":"1.0.0","id":"urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001","properties":{"Description":"This catalog contains the output data products of the SISTER fractional cover PGE, including a fractional cover cloud-optimized GeoTIFF. Execution artifacts including the runconfig file and execution log file are included with the fractional cover data.","soil":{"0.0":0.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"vegetation":{"0.0":0.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"water":{"0.0":0.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"snow_ice":{"0.0":1862737.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"datetime":"2024-03-19T04:54:33.703000Z","start_datetime":"2023-08-07T18:27:55Z","end_datetime":"2023-08-07T18:28:07Z","created":"2023-08-07T18:27:55Z","updated":"2024-03-19T04:55:14.767000Z","status":"completed","provider":"unity"},"geometry":{"type":"Point","coordinates":[0.0,0.0]},"links":[{"rel":"collection","href":"."},{"rel":"self","href":"https://dxebrgu0bc9w7.cloudfront.net/am-uds-dapa/collections/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/items/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001","type":"application/json","title":"urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001"}],"assets":{"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.cmr.xml":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001/SISTER_EMIT_L2B_FRCOV_20230807T182755_001.cmr.xml","title":"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.cmr.xml","description":"size=1766;checksumType=md5;checksum=bd1eec65627f63e998113952c3778f6d;","roles":["metadata"]},"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.json":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001/SISTER_EMIT_L2B_FRCOV_20230807T182755_001.json","title":"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.json","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["metadata"]},"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.tif":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001/SISTER_EMIT_L2B_FRCOV_20230807T182755_001.tif","title":"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.tif","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["data"]},"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.log":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001/SISTER_EMIT_L2B_FRCOV_20230807T182755_001.log","title":"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.log","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["metadata"]},"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.png":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20230807T182755_001/SISTER_EMIT_L2B_FRCOV_20230807T182755_001.png","title":"SISTER_EMIT_L2B_FRCOV_20230807T182755_001.png","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["browse"]}},"bbox":[-180.0,-90.0,180.0,90.0],"stac_extensions":[],"collection":"urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1"},{"type":"Feature","stac_version":"1.0.0","id":"urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001","properties":{"Description":"This catalog contains the output data products of the SISTER fractional cover PGE, including a fractional cover cloud-optimized GeoTIFF. Execution artifacts including the runconfig file and execution log file are included with the fractional cover data.","soil":{"0.0":0.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"vegetation":{"0.0":0.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"water":{"0.0":0.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"snow_ice":{"0.0":93871.0,"0.1":0.0,"0.2":0.0,"0.3":0.0,"0.4":0.0,"0.5":0.0,"0.6":0.0,"0.7":0.0,"0.8":0.0,"0.9":0.0,"1.0":0.0},"datetime":"2024-03-18T18:04:15.591000Z","start_datetime":"2024-01-03T13:19:36Z","end_datetime":"2024-01-03T13:19:48Z","created":"2024-01-03T13:19:36Z","updated":"2024-03-18T18:04:27.773000Z","status":"completed","provider":"unity"},"geometry":{"type":"Point","coordinates":[0.0,0.0]},"links":[{"rel":"collection","href":"."},{"rel":"self","href":"https://dxebrgu0bc9w7.cloudfront.net/am-uds-dapa/collections/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/items/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001","type":"application/json","title":"urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001"}],"assets":{"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.cmr.xml":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001/SISTER_EMIT_L2B_FRCOV_20240103T131936_001.cmr.xml","title":"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.cmr.xml","description":"size=1766;checksumType=md5;checksum=a8c0e55579d2f1b47eb6e99188082559;","roles":["metadata"]},"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.json":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001/SISTER_EMIT_L2B_FRCOV_20240103T131936_001.json","title":"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.json","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["metadata"]},"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.tif":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001/SISTER_EMIT_L2B_FRCOV_20240103T131936_001.tif","title":"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.tif","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["data"]},"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.png":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001/SISTER_EMIT_L2B_FRCOV_20240103T131936_001.png","title":"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.png","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["browse"]},"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.log":{"href":"s3://sps-test-ds-storage/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1/urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1:SISTER_EMIT_L2B_FRCOV_20240103T131936_001/SISTER_EMIT_L2B_FRCOV_20240103T131936_001.log","title":"SISTER_EMIT_L2B_FRCOV_20240103T131936_001.log","description":"size=-1;checksumType=md5;checksum=unknown;","roles":["metadata"]}},"bbox":[-180.0,-90.0,180.0,90.0],"stac_extensions":[],"collection":"urn:nasa:unity:unity:test:SBG-L2B_FRCOV___1"}]} \ No newline at end of file diff --git a/tests/test_unity_data_service.py b/tests/test_unity_data_service.py new file mode 100644 index 0000000..f876565 --- /dev/null +++ b/tests/test_unity_data_service.py @@ -0,0 +1,50 @@ +from unity_sds_client.unity import Unity +from unity_sds_client.unity_exception import UnityException +from unity_sds_client.unity_session import UnitySession +from unity_sds_client.resources.collection import Collection +from unity_sds_client.unity_services import UnityServices as Services + +import pytest + + +@pytest.fixture +def cleanup_update_test(): + yield None + print("Cleanup...") + + +def test_collection_creation(cleanup_update_test): + #no venue, project + with pytest.raises(UnityException): + s = Unity() + ds = s.client(Services.DATA_SERVICE) + ds.create_collection(Collection("urn:nasa:unity:myproject:myvenue:identifier"), True) + #no Venue + with pytest.raises(UnityException): + s = Unity() + s.set_project("unity") + ds = s.client(Services.DATA_SERVICE) + ds.create_collection(Collection("urn:nasa:unity:myproject:myvenue:identifier"), True) + #null collections + # does not match name + with pytest.raises(UnityException): + s = Unity() + s.set_project("unity") + s.set_venue("test") + ds = s.client(Services.DATA_SERVICE) + ds.create_collection(None, True) + + #does not match name + with pytest.raises(UnityException): + s = Unity() + s.set_project("unity") + s.set_venue("test") + ds = s.client(Services.DATA_SERVICE) + ds.create_collection( Collection("urn:nasa:unity:myproject:myvenue:identifier"), True) + + # does not match name + s = Unity() + s.set_project("unity") + s.set_venue("test") + ds = s.client(Services.DATA_SERVICE) + ds.create_collection(Collection("urn:nasa:unity:unity:test:my_collection_id"), True) \ No newline at end of file diff --git a/tests/test_unity_py.py b/tests/test_unity_py.py index 78165e4..b79e3b5 100644 --- a/tests/test_unity_py.py +++ b/tests/test_unity_py.py @@ -16,6 +16,10 @@ def test_default_unity_client(): client = Unity() assert True == True +def test_unity_client_config_override(): + client = Unity(config_file_override="tests/test_files/config_override.cfg") + setting = client._session._config.get("TEST","client_id") + assert setting == "THIS_IS_A_TEST_CLIENT_ID" @pytest.mark.regression def test_example_regression_test(cleanup_update_test): @@ -25,6 +29,14 @@ def test_example_regression_test(cleanup_update_test): collections = dataManager.get_collections() assert len(collections) > 0 +@pytest.mark.regression +def test_example_regression_test(cleanup_update_test): + print("Example collection test") + s = Unity() + dataManager = s.client(Services.DATA_SERVICE) + collections_json = dataManager.get_collections(output_stac=True) + assert collections_json is not None + @pytest.mark.regression def test_example_process(cleanup_update_test): diff --git a/tests/test_unity_stac.py b/tests/test_unity_stac.py index ec0fb43..ce7856f 100644 --- a/tests/test_unity_stac.py +++ b/tests/test_unity_stac.py @@ -56,6 +56,15 @@ def test_read_stac(): assert len(data_files) == 1 assert data_files[0].roles == ["metadata"] + # Try a "classic" catalog + item files stac catalog + collection = Collection.from_stac("tests/test_files/dataset_with_properties.json") + datasets = collection.datasets + # Added 3/26/24 to check the properties being added + assert datasets[0].properties is not None + assert datasets[0].properties['soil'] + print("Properties is not null") + + def test_write_stac(): collection = Collection.from_stac("tests/test_files/cmr_granules.json") diff --git a/unity_sds_client/resources/collection.py b/unity_sds_client/resources/collection.py index cfeb183..bcf0383 100644 --- a/unity_sds_client/resources/collection.py +++ b/unity_sds_client/resources/collection.py @@ -28,6 +28,7 @@ def __init__(self, id): self._beginning_time = None self._ending_time = None + def add_dataset(self, dataset: Dataset): self._datasets.append(dataset) @@ -199,7 +200,6 @@ def from_stac(stac_file): ds = Dataset(item.id, id, item.properties.get("start_datetime", None), item.properties.get("end_datetime", None), item.properties.get("created", None)) if item.collection_id is not None and item.collection_id != id: - print ("if2") ds = Dataset(item.id, item.collection_id, item.properties.get("start_datetime", None), item.properties.get("end_datetime", None), item.properties.get("created", None)) diff --git a/unity_sds_client/resources/dataset.py b/unity_sds_client/resources/dataset.py index 4cd1ed6..f7e7347 100644 --- a/unity_sds_client/resources/dataset.py +++ b/unity_sds_client/resources/dataset.py @@ -12,7 +12,7 @@ def __str__(self): def __repr__(self): return self.__str__() - def __init__(self, name, collection_id, start_time, end_time, creation_time ): + def __init__(self, name, collection_id, start_time, end_time, creation_time, properties=None ): """Dataset object construction) Parameters @@ -44,6 +44,12 @@ def __init__(self, name, collection_id, start_time, end_time, creation_time ): self.geometry = None self.bbox = None + #add non-reserved properties + if properties is not None: + for key, value in properties.items(): + if key not in ['start_datetime','created', 'end_datetime']: + self.properties[key] = value + def add_data_file(self, datafile: type=DataFile): """adds a data file to a dataset diff --git a/unity_sds_client/services/data_service.py b/unity_sds_client/services/data_service.py index 4463728..be2838c 100644 --- a/unity_sds_client/services/data_service.py +++ b/unity_sds_client/services/data_service.py @@ -1,4 +1,6 @@ import requests + +from unity_sds_client.unity_exception import UnityException from unity_sds_client.unity_session import UnitySession from unity_sds_client.resources.collection import Collection from unity_sds_client.resources.dataset import Dataset @@ -38,7 +40,7 @@ def __init__( if endpoint is None: self.endpoint = self._session.get_unity_href() - def get_collections(self): + def get_collections(self, limit=10, output_stac=False): """Returns a list of collections Returns @@ -49,7 +51,10 @@ def get_collections(self): """ url = self.endpoint + "am-uds-dapa/collections" token = self._session.get_auth().get_token() - response = requests.get(url, headers={"Authorization": "Bearer " + token}) + response = requests.get(url, headers={"Authorization": "Bearer " + token}, params={"limit": limit}) + if output_stac: + return response.json() + # build collection objects here collections = [] for data_set in response.json()['features']: @@ -57,16 +62,21 @@ def get_collections(self): return collections - def get_collection_data(self, collection: type= Collection): + def get_collection_data(self, collection: type = Collection, limit=10, filter: str = None, output_stac=False): datasets = [] url = self.endpoint + f'am-uds-dapa/collections/{collection.collection_id}/items' token = self._session.get_auth().get_token() - response = requests.get(url, headers={"Authorization": "Bearer " + token}) + params = {"limit": limit} + if filter is not None: + params["filter"] = filter + response = requests.get(url, headers={"Authorization": "Bearer " + token}, params=params) + if output_stac: + return response.json() results = response.json()['features'] for dataset in results: - ds = Dataset(dataset['id'], collection.collection_id, dataset['properties']['start_datetime'], dataset['properties']['end_datetime'], dataset['properties']['created']) - + ds = Dataset(dataset['id'], collection.collection_id, dataset['properties']['start_datetime'], dataset['properties']['end_datetime'], dataset['properties']['created'], properties=dataset['properties']) + for asset_key in dataset['assets']: location = dataset['assets'][asset_key]['href'] file_type = dataset['assets'][asset_key].get('type', "") @@ -78,3 +88,105 @@ def get_collection_data(self, collection: type= Collection): datasets.append(ds) return datasets + + def create_collection(self, collection: type = Collection, dry_run=False): + + # Collection must not be None + if collection is None: + raise UnityException("Invalid collection provided.") + + # test version Information? + + # Test collection ID name: project and venue + if self._session._project is None or self._session._venue is None: + raise UnityException("To create a collection, the Unity session Project and Venue must be set!") + + if not collection.collection_id.startswith(f"urn:nasa:unity:{self._session._project}:{self._session._venue}"): + raise UnityException(f"Collection Identifiers must start with urn:nasa:unity:{self._session._project}:{self._session._venue}") + + collection = { + "title": "Collection " + collection.collection_id, + "type": "Collection", + "id": collection.collection_id, + "stac_version": "1.0.0", + "description": "TODO", + "providers": [ + {"name": "unity"} + ], + "links": [ + { + "rel": "root", + "href": "./collection.json?bucket=unknown_bucket®ex=%7BcmrMetadata.Granule.Collection.ShortName%7D___%7BcmrMetadata.Granule.Collection.VersionId%7D", + "type": "application/json", + "title": "test_file01.nc" + }, + { + "rel": "item", + "href": "./collection.json?bucket=protected®ex=%5Etest_file.%2A%5C.nc%24", + "type": "data", + "title": "test_file01.nc" + }, + { + "rel": "item", + "href": "./collection.json?bucket=protected®ex=%5Etest_file.%2A%5C.nc%5C.cas%24", + "type": "metadata", + "title": "test_file01.nc.cas" + }, + { + "rel": "item", + "href": "./collection.json?bucket=private®ex=%5Etest_file.%2A%5C.cmr%5C.xml%24", + "type": "metadata", + "title": "test_file01.cmr.xml" + } + ], + "stac_extensions": [], + "extent": { + "spatial": { + "bbox": [ + [ + 0, + 0, + 0, + 0 + ] + ] + }, + "temporal": { + "interval": [ + [ + "2022-10-04T00:00:00.000Z", + "2022-10-04T23:59:59.999Z" + ] + ] + } + }, + "license": "proprietary", + "summaries": { + "granuleId": [ + "^test_file.*$" + ], + "granuleIdExtraction": [ + "(^test_file.*)(\\.nc|\\.nc\\.cas|\\.cmr\\.xml)" + ], + "process": [ + "stac" + ] + } + } + if not dry_run: + url = self.endpoint + f'am-uds-dapa/collections' + token = self._session.get_auth().get_token() + response = requests.post(url, headers={"Authorization": "Bearer " + token}, json=collection) + if response.status_code != 202: + raise UnityException("Error creating collection: " + response.message) + + def define_custom_metadata(self, metadata: dict): + if self._session._project is None or self._session._venue is None: + raise UnityException("To add custom metadata, the Unity session Project and Venue must be set!") + + url = self.endpoint + f'am-uds-dapa/admin/custom_metadata/{self._session._project}' + token = self._session.get_auth().get_token() + response = requests.put(url, headers={"Authorization": "Bearer " + token}, + params={"venue": self._session._venue}, json=metadata) + if response.status_code != 200: + raise UnityException("Error adding custom metadata: " + response.message) diff --git a/unity_sds_client/unity.py b/unity_sds_client/unity.py index b3f6d91..a539601 100644 --- a/unity_sds_client/unity.py +++ b/unity_sds_client/unity.py @@ -15,13 +15,15 @@ class Unity(object): is passed to different services and resources as needed. """ - def __init__(self, environment: UnityEnvironments = UnityEnvironments.TEST): + def __init__(self, environment: UnityEnvironments = UnityEnvironments.TEST, config_file_override:str = None): """ :param environment: the default environment for a session to work with. Defaults to 'TEST' unity environment. + :param config_file_override: absolute path to a config file containing settings to override default config """ env = environment config = _read_config([ - os.path.dirname(os.path.realpath(__file__)) + "/envs/environments.cfg".format(str(env.value).lower()) + os.path.dirname(os.path.realpath(__file__)) + "/envs/environments.cfg".format(str(env.value).lower()), + config_file_override ]) self._session = UnitySession(env.value, config) @@ -37,7 +39,7 @@ def set_venue(self, venue): :param venue: the venue to use when interacting with venue specific services. Used in building the restful endpoint. """ - self._session._venue = venue + self._session._venue = venue def set_venue_id(self, venue_id): """