@@ -237,6 +237,13 @@ def upload_video_to_project(
237237 :return: filenames of uploaded images
238238 :rtype: list of strs
239239 """
240+ project , project_folder = get_project_and_folder_metadata (project )
241+ upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
242+ if upload_state == "External" :
243+ raise SABaseException (
244+ 0 ,
245+ "The function does not support projects containing images attached with URLs"
246+ )
240247 logger .info ("Uploading from video %s." , str (video_path ))
241248 rotate_code = None
242249 try :
@@ -390,6 +397,12 @@ def upload_videos_from_folder_to_project(
390397 :rtype: tuple of list of strs
391398 """
392399 project , project_folder = get_project_and_folder_metadata (project )
400+ upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
401+ if upload_state == "External" :
402+ raise SABaseException (
403+ 0 ,
404+ "The function does not support projects containing images attached with URLs"
405+ )
393406 if recursive_subfolders :
394407 logger .warning (
395408 "When using recursive subfolder parsing same name videos in different subfolders will overwrite each other."
@@ -480,6 +493,12 @@ def upload_images_from_folder_to_project(
480493 project_folder_name = project ["name" ] + (
481494 f'/{ project_folder ["name" ]} ' if project_folder else ""
482495 )
496+ upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
497+ if upload_state == "External" :
498+ raise SABaseException (
499+ 0 ,
500+ "The function does not support projects containing images attached with URLs"
501+ )
483502 if recursive_subfolders :
484503 logger .info (
485504 "When using recursive subfolder parsing same name images in different subfolders will overwrite each other."
@@ -812,6 +831,12 @@ def upload_images_to_project(
812831 project_folder_name = project ["name" ] + (
813832 f'/{ project_folder ["name" ]} ' if project_folder else ""
814833 )
834+ upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
835+ if upload_state == "External" :
836+ raise SABaseException (
837+ 0 ,
838+ "The function does not support projects containing images attached with URLs"
839+ )
815840 if not isinstance (img_paths , list ):
816841 raise SABaseException (
817842 0 , "img_paths argument to upload_images_to_project should be a list"
@@ -939,13 +964,12 @@ def attach_image_urls_to_project(
939964 project_folder_name = project ["name" ] + (
940965 f'/{ project_folder ["name" ]} ' if project_folder else ""
941966 )
942- upload_state = project .get ("upload_state" )
943- if upload_state == "basic " :
967+ upload_state = common . upload_state_int_to_str ( project .get ("upload_state" ) )
968+ if upload_state == "Basic " :
944969 raise SABaseException (
945970 0 ,
946971 "You cannot attach URLs in this type of project. Please attach it in an external storage project"
947972 )
948- upload_state = "external"
949973 annotation_status = common .annotation_status_str_to_int (annotation_status )
950974 team_id , project_id = project ["team_id" ], project ["id" ]
951975 image_data = pd .read_csv (attachments )
@@ -1144,7 +1168,13 @@ def upload_images_from_public_urls_to_project(
11441168 images_to_upload = []
11451169 duplicate_images_filenames = []
11461170 path_to_url = {}
1147-
1171+ project , project_folder = get_project_and_folder_metadata (project )
1172+ upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
1173+ if upload_state == "External" :
1174+ raise SABaseException (
1175+ 0 ,
1176+ "The function does not support projects containing images attached with URLs"
1177+ )
11481178 finish_event = threading .Event ()
11491179 tqdm_thread = threading .Thread (
11501180 target = _tqdm_download ,
@@ -1246,6 +1276,13 @@ def upload_images_from_google_cloud_to_project(
12461276 images_to_upload = []
12471277 duplicate_images_filenames = []
12481278 path_to_url = {}
1279+ project , project_folder = get_project_and_folder_metadata (project )
1280+ upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
1281+ if upload_state == "External" :
1282+ raise SABaseException (
1283+ 0 ,
1284+ "The function does not support projects containing images attached with URLs"
1285+ )
12491286 cloud_client = storage .Client (project = google_project )
12501287 bucket = cloud_client .get_bucket (bucket_name )
12511288 image_blobs = bucket .list_blobs (prefix = folder_path )
@@ -1322,6 +1359,13 @@ def upload_images_from_azure_blob_to_project(
13221359 images_to_upload = []
13231360 duplicate_images_filenames = []
13241361 path_to_url = {}
1362+ project , project_folder = get_project_and_folder_metadata (project )
1363+ upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
1364+ if upload_state == "External" :
1365+ raise SABaseException (
1366+ 0 ,
1367+ "The function does not support projects containing images attached with URLs"
1368+ )
13251369 connect_key = os .getenv ('AZURE_STORAGE_CONNECTION_STRING' )
13261370 blob_service_client = BlobServiceClient .from_connection_string (connect_key )
13271371 container_client = blob_service_client .get_container_client (container_name )
0 commit comments