question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'ModelInfo' object has no attribute 'securityStatus'

See original GitHub issue

Describe the bug

Occasionally, a test fails in CI with the error AttributeError: 'ModelInfo' object has no attribute 'securityStatus'. It also happened to me once on my local machine and I was able debug it a bit more. The error came from the fact that the model info was returned by the server without a securityStatus field, even though securityStatus is set to True in the test (see log below).

2 unrelated things here:

  1. Some tests are occasionally failing because of a server error while running the tests. It seems that test stability has been successfully addressed in https://github.com/huggingface/huggingface_hub/pull/682. However, the retry_endpoint decorator cannot work here because it’s not a classic HTTPError but a more pernicious error where the server returns something but not with the expected content. Any idea what could cause that ?

  2. When securityStatus is not returned by the server, ModelInfo does not have the attribute at all because of the following hack:

    # in ModelInfo.__init__()
    # (...)
    for k, v in kwargs.items():
        setattr(self, k, v)
    

    I remember that I read somewhere this is because we want older versions of huggingface_hub to still contain future informations, which is a good reason for having it. However, since this attribute is now expected and even tested (see this test), I would be favorable to add it as a permanent attribute to ModelInfo (with a default value to None for example).

Reproduction

Happens occasionally. See https://github.com/huggingface/huggingface_hub/runs/7918045010?check_suite_focus=true for example.

Logs

self = <tests.test_hf_api.HfApiPublicTest testMethod=test_model_info_with_security>

    @with_production_testing
    def test_model_info_with_security(self):
        _api = HfApi()
        model = _api.model_info(
            repo_id=DUMMY_MODEL_ID,
            revision=DUMMY_MODEL_ID_REVISION_ONE_SPECIFIC_COMMIT,
            securityStatus=True,
        )
>       self.assertEqual(model.securityStatus, {"containsInfected": False})
E       AttributeError: 'ModelInfo' object has no attribute 'securityStatus'

System Info

Github CI (commit 3ce9e18129f690be1c528c9cd1d13bc37a58aab5 for example)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
LysandreJikcommented, Aug 23, 2022

Adding it with a default value of None sounds good to me. There was a discussion about a similar attribute here which seems to echo what you’re proposing, so all good for me.

1reaction
Wauplincommented, Aug 23, 2022

Makes total sense @LysandreJik ! I’ll take care of it 😃

My “let’s just ignore the failing test 😕” seems so lazy now that I read it again 😁

Read more comments on GitHub >

github_iconTop Results From Across the Web

'ModelInfo' object has no attribute '__attrs_init__' #2609 - GitHub
Describe the bug AttributeError occurs when executing the sample code below. (1.0.0-rc1 version) Please tell me how to solve it. import ...
Read more >
[Django] #31678: "AttributeError: 'ManyToOneRel' object has ...
#31678: "AttributeError: 'ManyToOneRel' object has no attribute 'select_format'" fails in 3.0.7
Read more >
AttributeError: object ... has no attribute - python - Stack Overflow
I have this in my fb.h file: static fbClass *getInstance(); void clearFBblit(); int getFBdiff(int ret); void setFBdiff(int top, int right, ...
Read more >
[Solved] AttributeError: 'module' object has no attribute
Click here to subscribe - https://www.youtube.com/channel/UCeVMnSShP_Iviwkknt83cww▻Instagram ...
Read more >
'module' object has no attribute and ImportError - YouTube
This video covers the AttributeError : 'module' object has no attribute and ImportError: No module name errors in Python.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found