proximl 0.5.17__py3-none-any.whl → 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. examples/local_storage.py +0 -2
  2. proximl/__init__.py +1 -1
  3. proximl/checkpoints.py +56 -57
  4. proximl/cli/__init__.py +6 -3
  5. proximl/cli/checkpoint.py +18 -57
  6. proximl/cli/dataset.py +17 -57
  7. proximl/cli/job/__init__.py +89 -67
  8. proximl/cli/job/create.py +51 -24
  9. proximl/cli/model.py +14 -56
  10. proximl/cli/volume.py +18 -57
  11. proximl/datasets.py +50 -55
  12. proximl/jobs.py +269 -69
  13. proximl/models.py +51 -55
  14. proximl/proximl.py +159 -114
  15. proximl/utils/__init__.py +1 -0
  16. proximl/{auth.py → utils/auth.py} +4 -3
  17. proximl/utils/transfer.py +647 -0
  18. proximl/volumes.py +48 -53
  19. {proximl-0.5.17.dist-info → proximl-1.0.1.dist-info}/METADATA +3 -3
  20. {proximl-0.5.17.dist-info → proximl-1.0.1.dist-info}/RECORD +52 -50
  21. tests/integration/test_checkpoints_integration.py +4 -3
  22. tests/integration/test_datasets_integration.py +5 -3
  23. tests/integration/test_jobs_integration.py +33 -27
  24. tests/integration/test_models_integration.py +7 -3
  25. tests/integration/test_volumes_integration.py +2 -2
  26. tests/unit/cli/test_cli_checkpoint_unit.py +312 -1
  27. tests/unit/cloudbender/test_nodes_unit.py +112 -0
  28. tests/unit/cloudbender/test_providers_unit.py +96 -0
  29. tests/unit/cloudbender/test_regions_unit.py +106 -0
  30. tests/unit/cloudbender/test_services_unit.py +141 -0
  31. tests/unit/conftest.py +23 -10
  32. tests/unit/projects/test_project_data_connectors_unit.py +39 -0
  33. tests/unit/projects/test_project_datastores_unit.py +37 -0
  34. tests/unit/projects/test_project_members_unit.py +46 -0
  35. tests/unit/projects/test_project_services_unit.py +65 -0
  36. tests/unit/projects/test_projects_unit.py +16 -0
  37. tests/unit/test_auth_unit.py +17 -2
  38. tests/unit/test_checkpoints_unit.py +256 -71
  39. tests/unit/test_datasets_unit.py +218 -68
  40. tests/unit/test_exceptions.py +133 -0
  41. tests/unit/test_gpu_types_unit.py +11 -1
  42. tests/unit/test_jobs_unit.py +1014 -95
  43. tests/unit/test_main_unit.py +20 -0
  44. tests/unit/test_models_unit.py +218 -70
  45. tests/unit/test_proximl_unit.py +627 -3
  46. tests/unit/test_volumes_unit.py +211 -70
  47. tests/unit/utils/__init__.py +1 -0
  48. tests/unit/utils/test_transfer_unit.py +4260 -0
  49. proximl/cli/connection.py +0 -61
  50. proximl/connections.py +0 -621
  51. tests/unit/test_connections_unit.py +0 -182
  52. {proximl-0.5.17.dist-info → proximl-1.0.1.dist-info}/LICENSE +0 -0
  53. {proximl-0.5.17.dist-info → proximl-1.0.1.dist-info}/WHEEL +0 -0
  54. {proximl-0.5.17.dist-info → proximl-1.0.1.dist-info}/entry_points.txt +0 -0
  55. {proximl-0.5.17.dist-info → proximl-1.0.1.dist-info}/top_level.txt +0 -0
@@ -1,182 +0,0 @@
1
- import re
2
- import json
3
- import os
4
- from unittest.mock import (
5
- Mock,
6
- AsyncMock,
7
- patch,
8
- create_autospec,
9
- call,
10
- mock_open,
11
- )
12
- from pytest import mark, fixture
13
- from aiodocker.containers import DockerContainer
14
- import proximl.connections as specimen
15
- from proximl.jobs import Job
16
- from proximl.datasets import Dataset
17
-
18
-
19
- pytestmark = [mark.sdk, mark.unit, mark.connections]
20
-
21
-
22
- @fixture
23
- def connections(mock_proximl):
24
- yield specimen.Connections(mock_proximl)
25
-
26
-
27
- @fixture
28
- def dataset_con(mock_proximl):
29
- DatasetMock = create_autospec(Dataset)
30
- yield specimen.Connection(
31
- mock_proximl,
32
- entity_type="dataset",
33
- id="data-id-1",
34
- entity=DatasetMock(
35
- mock_proximl,
36
- dataset_uuid="data-id-1",
37
- project_uuid="proj-id-1",
38
- name="first one",
39
- status="new",
40
- ),
41
- )
42
-
43
-
44
- @fixture
45
- def job_con(mock_proximl):
46
- JobMock = create_autospec(Job)
47
- yield specimen.Connection(
48
- mock_proximl,
49
- entity_type="job",
50
- id="job-id-1",
51
- entity=JobMock(
52
- mock_proximl,
53
- **{
54
- "customer_uuid": "cus-id-1",
55
- "project_uuid": "proj-id-1",
56
- "job_uuid": "job-id-1",
57
- "name": "test notebook",
58
- "type": "interactive",
59
- "status": "new",
60
- },
61
- ),
62
- )
63
-
64
-
65
- class ConnectionsTests:
66
- @mark.asyncio
67
- async def test_connections_list(
68
- self,
69
- connections,
70
- ):
71
- with patch("proximl.connections.os") as mock_os:
72
- mock_os.listdir = Mock(
73
- return_value=["job_job-id-1", "dataset_data-id-1", "baddir"]
74
- )
75
- with patch(
76
- "proximl.connections.Connection", autospec=True
77
- ) as mock_connection:
78
- connection = mock_connection.return_value
79
- connections = await connections.list()
80
- connection.check.assert_called
81
- assert len(connections) == 2
82
-
83
- @mark.asyncio
84
- async def test_connections_cleanup(
85
- self,
86
- connections,
87
- ):
88
- with patch("proximl.connections.os") as mock_os:
89
- dir_list = ["job_job-id-1", "dataset_data-id-1"]
90
- mock_os.listdir = Mock(return_value=dir_list)
91
-
92
- with patch(
93
- "proximl.connections._cleanup_containers"
94
- ) as mock_cleanup:
95
- await connections.cleanup_connections()
96
- assert mock_cleanup.mock_calls == [
97
- call(
98
- "proj-id-1",
99
- os.path.expanduser("~/.proximl/connections/proj-id-1"),
100
- dir_list,
101
- "vpn",
102
- ),
103
- call(
104
- "proj-id-1",
105
- os.path.expanduser("~/.proximl/connections/proj-id-1"),
106
- dir_list,
107
- "storage",
108
- ),
109
- ]
110
-
111
- @mark.asyncio
112
- async def test_connections_cleanup_containers(
113
- self,
114
- ):
115
- with patch("proximl.connections.open", mock_open(read_data="keep-me")):
116
-
117
- with patch(
118
- "proximl.connections.aiodocker.Docker", autospec=True
119
- ) as mock_docker:
120
- containers = [
121
- create_autospec(DockerContainer),
122
- create_autospec(DockerContainer),
123
- ]
124
- containers[0].id = "keep-me"
125
- containers[1].id = "delete-me"
126
- docker = mock_docker.return_value
127
- docker.containers = AsyncMock()
128
- docker.containers.list = AsyncMock(return_value=containers)
129
- await specimen._cleanup_containers(
130
- "proj-id-1",
131
- os.path.expanduser("~/.proximl/connections/proj-id-1"),
132
- ["dir_1"],
133
- "job",
134
- )
135
- docker.containers.list.assert_called_once_with(
136
- all=True,
137
- filters=json.dumps(
138
- dict(
139
- label=[
140
- "service=proximl",
141
- "type=job",
142
- "project=proj-id-1",
143
- ]
144
- )
145
- ),
146
- )
147
- containers[0].delete.assert_not_called
148
- containers[1].delete.assert_called_once_with(force=True)
149
-
150
-
151
- class ConnectionTests:
152
- def test_connection_properties(self, dataset_con):
153
- assert isinstance(dataset_con.id, str)
154
- assert isinstance(dataset_con.status, str)
155
- assert isinstance(dataset_con.type, str)
156
- assert dataset_con.type == "dataset"
157
-
158
- def test_connection_str(self, dataset_con):
159
- string = str(dataset_con)
160
- regex = (
161
- r"^Connection for "
162
- + dataset_con.type
163
- + " - "
164
- + dataset_con.id
165
- + ": "
166
- + dataset_con.status
167
- + r"$"
168
- )
169
- assert isinstance(string, str)
170
- assert re.match(regex, string)
171
-
172
- def test_connection_repr(self, dataset_con):
173
- string = repr(dataset_con)
174
- regex = (
175
- r"^Connection\( proximl , "
176
- + dataset_con.id
177
- + ", "
178
- + dataset_con.type
179
- + r"\)$"
180
- )
181
- assert isinstance(string, str)
182
- assert re.match(regex, string)