sol-ocf commited on
Commit
ba9ca64
·
verified ·
1 Parent(s): 5061f4b

Upload client.py with huggingface_hub

Browse files
Files changed (2) hide show
  1. .gitattributes +1 -0
  2. client.py +3 -59
.gitattributes CHANGED
@@ -210,3 +210,4 @@ tmp/raw/2024/01/29/0000/icon_global_icosahedral_single-level_2024012900_023_T_2M
210
  tmp/raw/2024/01/29/0000/icon_global_icosahedral_single-level_2024012900_012_T_2M.grib2 filter=lfs diff=lfs merge=lfs -text
211
  tmp/raw/2024/01/29/0000/icon_global_icosahedral_single-level_2024012900_000_T_2M.grib2 filter=lfs diff=lfs merge=lfs -text
212
  tmp/raw/2024/01/29/0000/icon_global_icosahedral_single-level_2024012900_029_T_2M.grib2 filter=lfs diff=lfs merge=lfs -text
 
 
210
  tmp/raw/2024/01/29/0000/icon_global_icosahedral_single-level_2024012900_012_T_2M.grib2 filter=lfs diff=lfs merge=lfs -text
211
  tmp/raw/2024/01/29/0000/icon_global_icosahedral_single-level_2024012900_000_T_2M.grib2 filter=lfs diff=lfs merge=lfs -text
212
  tmp/raw/2024/01/29/0000/icon_global_icosahedral_single-level_2024012900_029_T_2M.grib2 filter=lfs diff=lfs merge=lfs -text
213
+ client.py filter=lfs diff=lfs merge=lfs -text
client.py CHANGED
@@ -1,59 +1,3 @@
1
- import os
2
- import pathlib
3
- import unittest
4
-
5
- from .client import Client
6
-
7
- USER = "openclimatefix"
8
- RAW = pathlib.Path("raw")
9
-
10
-
11
- class TestHuggingFaceClient(unittest.TestCase):
12
- repoID: str
13
- client: Client
14
-
15
- @classmethod
16
- def setUpClass(cls) -> None:
17
- cls.repoID = "PolyAI/minds14"
18
- cls.client = Client(repoID=cls.repoID)
19
-
20
- def test_get_size(self) -> None:
21
- """Test that the size of a file is returned correctly."""
22
- name_size_map: dict[str, int] = {
23
- "README.md": 5292,
24
- "data": 471355396,
25
- }
26
- for name, exp in name_size_map.items():
27
- with self.subTest(msg=name):
28
- self.assertEqual(self.client._get_size(p=pathlib.Path(name)), exp)
29
-
30
- def test_exists(self) -> None:
31
- """Test that the existence of a file is returned correctly."""
32
- name_exists_map: dict[str, bool] = {
33
- "README.md": True,
34
- "data": True,
35
- "nonexistent1": False,
36
- "nonexistent/nonexistent2": False,
37
- }
38
- for name, exp in name_exists_map.items():
39
- with self.subTest(msg=name):
40
- self.assertEqual(self.client.exists(dst=pathlib.Path(name)), exp)
41
-
42
- def test_upload_to_huggingface(self) -> None:
43
- """Test that a file is uploaded correctly."""
44
-
45
- client = Client(
46
- repoID="sol-ocf/test-dwd-global",
47
- token=os.environ["HUGGINGFACE_TOKEN"],
48
- )
49
-
50
- name_size_map: dict[str, int] = {
51
- "client.py": 5292,
52
- }
53
- for name, exp in name_size_map.items():
54
- with self.subTest(msg=name):
55
- client.store(
56
- src=pathlib.Path(__file__),
57
- dst=pathlib.Path(name),
58
- )
59
- self.assertEqual(client._get_size(p=pathlib.Path(name)), exp)
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da9e08c0d7b8a7c93b0a1957d19ba24213924448f287ab85937dde4a2f828984
3
+ size 1809584