Skip to content
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

cannot find correct tasks api #8836

Open
2 tasks done
TracyMRohlin opened this issue Dec 17, 2024 · 1 comment
Open
2 tasks done

cannot find correct tasks api #8836

TracyMRohlin opened this issue Dec 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@TracyMRohlin
Copy link

Actions before raising this issue

  • I searched the existing issues and did not find anything similar.
  • I read/searched the docs

Steps to Reproduce

I am trying to create a new task from s3 files listed in our cvat bucket. This is using cvat-sdk==2.8.1 .

def get_client(username, password, cvat_host):
    dbutils = DBUtils()
    config = Configuration(
        host=cvat_host,
        username=username,
        password=password
    )
    api_client = ApiClient(config)
    login_serializer_ex_request = models.LoginSerializerExRequest(
        username=username,
        email=f'{username}@procore.com',
        password=password,
    )
    auth_key, resp = api_client.auth_api.create_login(login_serializer_ex_request)
    assert "sessionid" in api_client.cookies
    api_client.set_default_header("Authorization", "Token " + auth_key['key'])
    return api_client

def create_task_from_s3(
        project_id: int,
        file_id: str,
        filenames: list[str],
        subset: str = "train",
    ):
        """Creates a task in CVAT using an S3 bucket as the
        Connected File share it assumes the file share
        is already configured

        Note: make sure image names are sorted
        lexicographically as cvat will do
        this by default, and your tags
        might now be aligned if the paths
        are not sorted
        """

        task_spec = {
            "project_id": project_id, 
            "name": str(file_id),
        }
        task = None
        try:
            # import pdb; pdb.set_trace()
            module = client.tasks # <-------- error occurs here:
            task = client.tasks.create_from_data(
                spec=task_spec,
                data_params={"image_quality": 95},
                resource_type=ResourceType.SHARE,
                resources=filenames,
            )
        except Exception as e:
            print(f"Exception creating task {prostore_file_id}: {e}")
        return task

I did a pdb session and found that there is a bug in the client api:


 def __getattr__(self, key):
    779         notfound = object()
--> 780         api_instance, api_klassname = self._apis.get(key, notfound)
    781         if api_instance is notfound:
    782             raise AttributeError(f"Can't find the '{key}' attribute")

in this case the keys are all 'X_api', e.g., 'tasks_api' and not 'tasks'. Since 'tasks' is not found, not found is returned, but not found is a singleton, not a tuple.

Expected Behavior

return the correct api (tasks_api) when using client.tasks

Possible Solution

No response

Context

No response

Environment

No response

@TracyMRohlin TracyMRohlin added the bug Something isn't working label Dec 17, 2024
@zhiltsov-max
Copy link
Contributor

zhiltsov-max commented Dec 19, 2024

Hi, how the client object is created? It's not clear from the code snippet provided. I can see module = client.tasks, but tasks should not be a module. An example of using high-level Client objects can be found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants