@@ -61,8 +61,8 @@ def search_resources_api(
6161 """
6262 Get resources from NVA API
6363
64- This will first fetch the data from the NVA API based on the search parameters
65- then write the data to the specified S3 location
64+ This will use the NVA API to fetch resources based on the provided parameters.
65+ The data will be written to the specified S3 location in parquet format.
6666
6767 Args:
6868 resource_name: Will be used for the output files on S3, avoid using '-'.
@@ -91,7 +91,7 @@ def search_resources_api(
9191 # Filter by contributor and publication year:
9292 uv run datasync nva search-resources-api \
9393 --resource-name "author-publications" \
94- --filter contributor="https://api.nva.unit.no/cristin/person/1773250" \\
94+ --filter contributor="https://api.nva.unit.no/cristin/person/1773250" \
9595 --filter publication_year_since=2020
9696 """
9797 log .debug ("Starting NVA API search with parameters" , filters = filters )
@@ -119,7 +119,14 @@ def search_resources_api(
119119 log .error ("Valid filters" , valid_filters = VALID_PARAMS_NVA_API )
120120 raise typer .Exit (code = 1 )
121121
122- search_params [key ] = value
122+ if key in search_params :
123+ existing = search_params [key ]
124+ if isinstance (existing , list ):
125+ existing .append (value )
126+ else :
127+ search_params [key ] = [existing , value ]
128+ else :
129+ search_params [key ] = value
123130 log .debug ("Parsed search parameters" , search_params = search_params )
124131 if not search_params :
125132 log .error ("Valid filters" , valid_filters = VALID_PARAMS_NVA_API )
@@ -143,7 +150,7 @@ def search_resources_api(
143150 )
144151
145152 log .info (f"Fetching resources from { base_url } " )
146- load_info = pipeline .run (
153+ pipeline .run (
147154 nva_search_source (
148155 base_url = base_url ,
149156 resource_name = resource_name ,
@@ -153,8 +160,6 @@ def search_resources_api(
153160 loader_file_format = "parquet" ,
154161 )
155162
156- log .info ("Pipeline run completed" , load_info = load_info )
157-
158163 if apply_filter :
159164 con = setup_duckdb_s3_connection (
160165 endpoint_url = storage_endpoint_url ,
@@ -174,7 +179,6 @@ def search_resources_api(
174179 write_timestamp (con , storage_bucket , storage_prefix )
175180 con .close ()
176181
177- log .info ("NVA data sync completed" )
178182 log .info (
179183 f"Data available at: { storage_endpoint_url } /{ storage_bucket } /{ storage_prefix } /"
180184 f"main/{ resource_name } .parquet"
0 commit comments