@@ -18,6 +18,23 @@ def foundry_client(client):
1818 return FoundryClient (client )
1919
2020
21+ @pytest .fixture ()
22+ def text_data_row (dataset , random_str ):
23+ global_key = "https://storage.googleapis.com/lb-artifacts-testing-public/sdk_integration_test/sample-text-1.txt-{random_str}"
24+ task = dataset .create_data_rows ([{
25+ "row_data" :
26+ "https://storage.googleapis.com/lb-artifacts-testing-public/sdk_integration_test/sample-text-1.txt" ,
27+ "media_type" :
28+ "TEXT" ,
29+ "global_key" :
30+ global_key
31+ }])
32+ task .wait_till_done ()
33+ dr = dataset .data_rows ().get_one ()
34+ yield dr
35+ dr .delete ()
36+
37+
2138@pytest .fixture ()
2239def ontology (client , random_str ):
2340 object_features = [
@@ -108,13 +125,23 @@ def test_run_foundry_app_returns_model_run_id(foundry_client, data_row, app):
108125 assert model_run .uid == model_run_id
109126
110127
111- def test_run_foundry_app_with_non_existent_data_rows (foundry_client , data_row ,
112- app , random_str ):
113- data_rows = lb .GlobalKeys ([data_row .global_key , "non-existent-global-key" ])
114- task = foundry_client .run_app (
115- model_run_name = f"test-app-with-wrong-key-{ random_str } " ,
116- data_rows = data_rows ,
117- app_id = app .id )
118- task .wait_till_done ()
119- # The incorrect data row is filtered out and the task still completes with the correct data row
120- assert task .status == 'COMPLETE'
128+ def test_run_foundry_with_invalid_data_row_id (foundry_client , app , random_str ):
129+ invalid_datarow_id = 'invalid-global-key'
130+ data_rows = lb .GlobalKeys ([invalid_datarow_id ])
131+ with pytest .raises (lb .exceptions .LabelboxError ) as exception :
132+ foundry_client .run_app (
133+ model_run_name = f"test-app-with-invalid-datarow-id-{ random_str } " ,
134+ data_rows = data_rows ,
135+ app_id = app .id )
136+ assert invalid_datarow_id in exception .value
137+
138+
139+ def test_run_foundry_with_invalid_global_key (foundry_client , app , random_str ):
140+ invalid_global_key = 'invalid-global-key'
141+ data_rows = lb .GlobalKeys ([invalid_global_key ])
142+ with pytest .raises (lb .exceptions .LabelboxError ) as exception :
143+ foundry_client .run_app (
144+ model_run_name = f"test-app-with-invalid-global-key-{ random_str } " ,
145+ data_rows = data_rows ,
146+ app_id = app .id )
147+ assert invalid_global_key in exception .value
0 commit comments