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

[tests] fix bug in test_tracking.ClearMLTest #2863

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

faaany
Copy link
Contributor

@faaany faaany commented Jun 17, 2024

What does this PR do?

This PR fixes the following failed test:

(accelerate) root@150f3b602a91:/workspace/code# python -m pytest -rA -k "ClearMLTest" tests
============================================================ test session starts =============================================================
platform linux -- Python 3.9.19, pytest-8.0.0, pluggy-1.5.0
rootdir: /workspace/code
plugins: subtests-0.12.1, xdist-3.6.1, hydra-core-1.3.2, anyio-4.2.0
collected 334 items / 329 deselected / 5 selected                                                                                            

tests/test_tracking.py FFFFF                                                                                                           [100%]

================================================================== FAILURES ==================================================================
_______________________________________________________ ClearMLTest.test_init_trackers _______________________________________________________

self = <test_tracking.ClearMLTest testMethod=test_init_trackers>

    def setUp(self):
        super().setUp()
        # ClearML offline session location is stored in CLEARML_CACHE_DIR
>       self.add_mocks(mock.patch.dict(os.environ, {"CLEARML_CACHE_DIR": self.tmpdir}))

tests/test_tracking.py:273: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/conda/envs/accelerate/lib/python3.9/site-packages/accelerate/test_utils/testing.py:472: in add_mocks
    m.start()
/opt/conda/envs/accelerate/lib/python3.9/unittest/mock.py:1842: in start
    result = self.__enter__()
/opt/conda/envs/accelerate/lib/python3.9/unittest/mock.py:1788: in __enter__
    self._patch_dict()
/opt/conda/envs/accelerate/lib/python3.9/unittest/mock.py:1813: in _patch_dict
    in_dict.update(values)
/opt/conda/envs/accelerate/lib/python3.9/_collections_abc.py:941: in update
    self[key] = other[key]
/opt/conda/envs/accelerate/lib/python3.9/os.py:684: in __setitem__
    value = self.encodevalue(value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

value = PosixPath('/tmp/tmpmtomihfy')

    def encode(value):
        if not isinstance(value, str):
>           raise TypeError("str expected, not %s" % type(value).__name__)
E           TypeError: str expected, not PosixPath

/opt/conda/envs/accelerate/lib/python3.9/os.py:756: TypeError

The error message says that the value for os.environ should be a string rather than a PosixPath object. But self.tmpdir from TempDirTestCase is not a string. So we need to turn it to string.

Copy link
Collaborator

@muellerzr muellerzr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a bunch!

@faaany faaany marked this pull request as ready for review June 17, 2024 08:07
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@muellerzr muellerzr merged commit 0284f9a into huggingface:main Jun 17, 2024
23 checks passed
@faaany faaany deleted the environ branch November 4, 2024 06:09
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

Successfully merging this pull request may close these issues.

3 participants