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

fix: remove duplicated collection id prefix #72

Merged
merged 14 commits into from
Dec 9, 2024
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -42,8 +42,10 @@ def generate_sample_stac(self, filepath: str):
file_checksum = FileUtils.get_checksum(filepath, True)
# https://github.com/stac-extensions/file
# https://github.com/stac-extensions/file/blob/main/examples/item.json
granule_id = os.path.splitext(filename)[0]
granule_id = granule_id if granule_id.startswith(self.__collection_id) else f'{self.__collection_id}:{granule_id}'
sample_stac_item = Item(
id=f'{self.__collection_id}:{os.path.splitext(filename)[0]}',
id=granule_id,
stac_extensions=["https://stac-extensions.github.io/file/v2.1.0/schema.json"],
geometry={
"type": "Point",
@@ -78,7 +80,8 @@ def execute_job(self, job_obj, lock) -> bool:
updating_assets = {}
try:
LOGGER.audit(f'uploading auxiliary file: {job_obj}')
s3_url = self.__s3.upload(job_obj, self.__staging_bucket, f'{self.__collection_id}/{self.__collection_id}:{sample_stac_item.id}', self.__delete_files)
# NOTE: sample_stac_item.id is guaranteed to start with colleciton id.
s3_url = self.__s3.upload(job_obj, self.__staging_bucket, f'{self.__collection_id}/{sample_stac_item.id}', self.__delete_files)
updating_assets[os.path.basename(s3_url)] = s3_url
uploading_current_granule_stac = f'{s3_url}.stac.json'
self.__s3.set_s3_url(uploading_current_granule_stac)
6 changes: 2 additions & 4 deletions tests/integration_tests/test_docker_stage_out.py
Original file line number Diff line number Diff line change
@@ -1454,7 +1454,7 @@ def test_03_03_upload_auxiliary_files(self):
self.assertTrue(result_key.startswith('test_file'), f'worng asset key: {result_key}')
self.assertTrue(f'{result_key}.stac.json' in upload_result['assets'], f'missing assets#metadata asset: test_file_0.json')
self.assertTrue('href' in upload_result['assets'][f'{result_key}.stac.json'], 'missing assets#metadata__cas#href')
self.assertTrue(upload_result['assets'][f'{result_key}.stac.json']['href'].startswith(f's3://{os.environ["STAGING_BUCKET"]}/{os.environ["COLLECTION_ID"]}/'), f"wrong HREF (no S3?): upload_result['assets'][f'{result_key}.stac.json']['href']")
self.assertTrue(upload_result['assets'][f'{result_key}.stac.json']['href'].startswith(f's3://{os.environ["STAGING_BUCKET"]}/{os.environ["COLLECTION_ID"]}/{os.environ["COLLECTION_ID"]}:test_file_'), f"wrong HREF (no S3?): upload_result['assets'][f'{result_key}.stac.json']['href']")
"""
Example output:
{
@@ -1479,9 +1479,7 @@ def test_03_03_upload_auxiliary_files(self):
'collection': 'NEW_COLLECTION_EXAMPLE_L1B___9'}]}
"""
s3 = AwsS3()
s3_keys = [k for k in s3.get_child_s3_files(os.environ['STAGING_BUCKET'],
f"stage_out/successful_features_{starting_time}",
)]
s3_keys = [k for k in s3.get_child_s3_files(os.environ['STAGING_BUCKET'], f"stage_out/successful_features_{starting_time}")]
s3_keys = sorted(s3_keys)
print(f's3_keys: {s3_keys}')
self.assertTrue(len(s3_keys) > 0, f'empty files in S3')