Skip to content

API client attach data to task ssl error #9306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
valavanisleonidas opened this issue Apr 6, 2025 · 1 comment
Open

API client attach data to task ssl error #9306

valavanisleonidas opened this issue Apr 6, 2025 · 1 comment

Comments

@valavanisleonidas
Copy link

valavanisleonidas commented Apr 6, 2025

Hello team,

I am trying to attach data to a task using python cvat-sdk. I have 125 images of size 700MB and I get error

urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='app.cvat.ai', port=443): Max retries exceeded with url: /api/tasks/1301577/data/ (Caused by SSLError(SSLError(5, '[SYS] unknown error (_ssl.c:2417)'))) 
python version  3.12.7
cvat_sdk        2.32.0

code

self.sdk_config = Configuration(
            host=CVAT_HOST,
            api_key={"Authorization": f"Token {self.token}"}
        )

    def upload_images(self, task_id: int, image_dir: str) -> None:
        
        image_files = [
            os.path.join(image_dir, f)
            for f in sorted(os.listdir(image_dir))
            if os.path.splitext(f)[1].lower() in UPLOAD_EXTENSIONS
        ]

        if not image_files:
            raise ValueError(f"No valid images found in {image_dir}")

        zip_path = os.path.join(image_dir, "upload.zip")
        with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zipf:
            for img in image_files:
                zipf.write(img, arcname=os.path.basename(img))
        print("send data")
        with ApiClient(self.sdk_config) as client:
            with open(zip_path, "rb") as f:
                task_data = DataRequest(
                    image_quality=70,
                    client_files=[f],
                    compression="ZIP"
                )

                (result, _) = client.tasks_api.create_data(
                    task_id,
                    data_request=task_data,
                    _content_type="multipart/form-data",
                    _request_timeout=(300, 600)
                )

        os.remove(zip_path)

I tried to increase the _request_timeout param but didnt work. If i upload batches of 50 images it works but it creates different jobs and i want them all in one.

Thank you in advance

@zhiltsov-max
Copy link
Contributor

Hi, please try to use the high-level SDK instead, example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants