@@ -417,14 +417,6 @@ def upload_video_to_project(
417417
418418 limit = _get_available_image_counts (project , folder )
419419
420- upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
421- project_type = project .get ("type" )
422-
423- if upload_state == "External" :
424- raise SABaseException (
425- 0 ,
426- f"The function does not support projects containing { project_type } attached with URLs"
427- )
428420 logger .info ("Uploading from video %s." , str (video_path ))
429421 tempdir = tempfile .TemporaryDirectory ()
430422 upload_file_names = []
@@ -519,14 +511,7 @@ def upload_videos_from_folder_to_project(
519511 :rtype: tuple of list of strs
520512 """
521513 project , folder = get_project_and_folder_metadata (project )
522- upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
523- project_type = project .get ("type" )
524514
525- if upload_state == "External" :
526- raise SABaseException (
527- 0 ,
528- f"The function does not support projects containing { project_type } attached with URLs"
529- )
530515 if recursive_subfolders :
531516 logger .warning (
532517 "When using recursive subfolder parsing same name videos in different subfolders will overwrite each other."
@@ -618,14 +603,7 @@ def upload_images_from_folder_to_project(
618603 project_folder_name = project ["name" ] + (
619604 f'/{ project_folder ["name" ]} ' if project_folder else ""
620605 )
621- upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
622- project_type = project .get ("type" )
623606
624- if upload_state == "External" :
625- raise SABaseException (
626- 0 ,
627- f"The function does not support projects containing { project_type } attached with URLs"
628- )
629607 if recursive_subfolders :
630608 logger .info (
631609 "When using recursive subfolder parsing same name images in different subfolders will overwrite each other."
@@ -720,14 +698,7 @@ def upload_images_to_project(
720698 """
721699 project , folder = get_project_and_folder_metadata (project )
722700 folder_name = project ["name" ] + (f'/{ folder ["name" ]} ' if folder else "" )
723- upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
724- project_type = project .get ("type" )
725701
726- if upload_state == "External" :
727- raise SABaseException (
728- 0 ,
729- f"The function does not support projects containing { project_type } attached with URLs"
730- )
731702 if not isinstance (img_paths , list ):
732703 raise SABaseException (
733704 0 , "img_paths argument to upload_images_to_project should be a list"
@@ -793,8 +764,8 @@ def attach_image_urls_to_project(
793764 :return: attached images, failed images, skipped images
794765 :rtype: (list, list, list)
795766 """
796- get_project_and_folder_metadata (project )
797- return attach_file_urls_to_project (project , attachments , annotation_status )
767+ project , folder = get_project_and_folder_metadata (project )
768+ return attach_file_urls_to_project (project , folder , attachments , annotation_status )
798769
799770
800771@Trackable
@@ -832,13 +803,7 @@ def upload_images_from_public_urls_to_project(
832803 duplicate_images_filenames = []
833804 path_to_url = {}
834805 project , project_folder = get_project_and_folder_metadata (project )
835- upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
836- project_type = project .get ('type' )
837- if upload_state == "External" :
838- raise SABaseException (
839- 0 ,
840- f"The function does not support projects containing { project_type } attached with URLs"
841- )
806+
842807 finish_event = threading .Event ()
843808 tqdm_thread = threading .Thread (
844809 target = _tqdm_download ,
@@ -942,14 +907,7 @@ def upload_images_from_google_cloud_to_project(
942907 duplicate_images_filenames = []
943908 path_to_url = {}
944909 project , project_folder = get_project_and_folder_metadata (project )
945- upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
946- project_type = project .get ("type" )
947910
948- if upload_state == "External" :
949- raise SABaseException (
950- 0 ,
951- f"The function does not support projects containing { project_type } attached with URLs"
952- )
953911 cloud_client = storage .Client (project = google_project )
954912 bucket = cloud_client .get_bucket (bucket_name )
955913 image_blobs = bucket .list_blobs (prefix = folder_path )
@@ -1028,13 +986,6 @@ def upload_images_from_azure_blob_to_project(
1028986 duplicate_images_filenames = []
1029987 path_to_url = {}
1030988 project , project_folder = get_project_and_folder_metadata (project )
1031- upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
1032- project_type = project .get ('type' )
1033- if upload_state == "External" :
1034- raise SABaseException (
1035- 0 ,
1036- f"The function does not support projects containing { project_type } attached with URLs"
1037- )
1038989 connect_key = os .getenv ('AZURE_STORAGE_CONNECTION_STRING' )
1039990 blob_service_client = BlobServiceClient .from_connection_string (connect_key )
1040991 container_client = blob_service_client .get_container_client (container_name )
@@ -2013,10 +1964,11 @@ def attach_video_urls_to_project(
20131964 :return: attached videos, failed videos, skipped videos
20141965 :rtype: (list, list, list)
20151966 """
2016- return attach_file_urls_to_project (project , attachments , annotation_status )
1967+ project , folder = get_project_and_folder_metadata (project )
1968+ return attach_file_urls_to_project (project ,folder , attachments , annotation_status )
20171969
20181970
2019- def attach_file_urls_to_project (project , attachments , annotation_status ):
1971+ def attach_file_urls_to_project (project ,folder , attachments , annotation_status ):
20201972 """Link files on external storage to SuperAnnotate.
20211973
20221974 :param project: project name or project folder path
@@ -2031,7 +1983,6 @@ def attach_file_urls_to_project(project, attachments, annotation_status):
20311983 :return: attached files, failed files, skipped files
20321984 :rtype: (list, list, list)
20331985 """
2034- project , folder = get_project_and_folder_metadata (project )
20351986 folder_name = project ["name" ] + (f'/{ folder ["name" ]} ' if folder else "" )
20361987 upload_state = common .upload_state_int_to_str (project .get ("upload_state" ))
20371988 if upload_state == "Basic" :
@@ -2104,5 +2055,6 @@ def attach_document_urls_to_project(
21042055 :return: attached videos, failed videos, skipped videos
21052056 :rtype: (list, list, list)
21062057 """
2107- return attach_file_urls_to_project (project , attachments , annotation_status )
2058+ project , folder = get_project_and_folder_metadata (project )
2059+ return attach_file_urls_to_project (project ,folder , attachments , annotation_status )
21082060
0 commit comments