MCPcopy
hub / github.com/mosaicml/composer / test_get_file_object_store

Function test_get_file_object_store

tests/utils/test_file_helpers.py:54–74  ·  view source on GitHub ↗
(tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch)

Source from the content-addressed store, hash-verified

52
53
54def test_get_file_object_store(tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch):
55 pytest.importorskip('libcloud')
56
57 remote_dir = tmp_path / 'remote_dir'
58 os.makedirs(remote_dir)
59 monkeypatch.setenv('OBJECT_STORE_KEY', str(remote_dir)) # for the local option, the key is the path
60 provider = LibcloudObjectStore(
61 provider='local',
62 key_environ='OBJECT_STORE_KEY',
63 container='.',
64 )
65
66 with open(str(remote_dir / 'checkpoint.txt'), 'wb') as f:
67 f.write(b'checkpoint1')
68 get_file(
69 path='checkpoint.txt',
70 object_store=provider,
71 destination=str(tmp_path / 'example'),
72 )
73 with open(str(tmp_path / 'example'), 'rb') as f:
74 assert f.read() == b'checkpoint1'
75
76
77def test_get_file_auto_object_store(tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch):

Callers

nothing calls this directly

Calls 3

LibcloudObjectStoreClass · 0.90
get_fileFunction · 0.90
writeMethod · 0.45

Tested by

no test coverage detected