3232from uuid import uuid4
3333
3434from harmony_service_lib .adapter import BaseHarmonyAdapter
35- from harmony_service_lib .util import stage
35+ from harmony_service_lib .util import generate_output_filename , stage
3636from pystac import Catalog , Item
3737from pystac .item import Asset
3838
@@ -98,8 +98,8 @@ def process_file(self, catalog: Catalog) -> list[Catalog]:
9898 netcdf_url = _get_item_url (items [0 ])
9999 if netcdf_url is None :
100100 raise ValueError ("No URL found for item" )
101- filename = Path (netcdf_url ).stem
102101
102+ zip_file = ""
103103 with TemporaryDirectory () as temp_dir :
104104 # Download file
105105 input_file = download_file (
@@ -112,19 +112,20 @@ def process_file(self, catalog: Catalog) -> list[Catalog]:
112112 # Create the subdirectory
113113 self .logger .info ("Running Casper." )
114114
115+ # Use Harmony generated filename
116+ zip_file = generate_output_filename (zip_file_name , ext = "zip" , is_reformatted = True )
117+ zip_file = f"{ temp_dir } /{ zip_file } "
118+
115119 # --- Run Casper ---
116- zip_file = f"{ temp_dir } /{ zip_file_name } .zip"
117120 convert_to_csv (
118121 input_file ,
119122 zip_file ,
120123 logger = self .logger ,
121124 )
122125
123- self .logger .info (
124- f"Casper conversion completed. Zip file created { zip_file_name } .zip"
125- )
126- staged_url = self ._stage (zip_file , f"{ zip_file_name } .zip" , "application/zip" )
126+ self .logger .info (f"Casper conversion completed. Zip file created { zip_file } " )
127127
128+ staged_url = self ._stage (zip_file , f"{ zip_file .split ('/' )[- 1 ]} " , "application/zip" )
128129 # -- Output to STAC catalog --
129130 result .clear_items ()
130131 properties = {
@@ -138,11 +139,10 @@ def process_file(self, catalog: Catalog) -> list[Catalog]:
138139 None ,
139140 properties ,
140141 )
141- filename = f"{ zip_file_name } .zip"
142142
143143 asset = Asset (
144144 staged_url ,
145- title = filename ,
145+ title = f" { zip_file . split ( '/' )[ - 1 ] } " ,
146146 media_type = "application/zip" ,
147147 roles = ["data" ],
148148 )
0 commit comments