idmtools-platform-container 0.0.0.dev0__py3-none-any.whl → 0.0.2__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 (71) hide show
  1. docker_image/BASE_VERSION +1 -0
  2. docker_image/Dockerfile +48 -0
  3. docker_image/Dockerfile_buildenv +46 -0
  4. docker_image/ImageName +1 -0
  5. docker_image/README.md +78 -0
  6. docker_image/__init__.py +6 -0
  7. docker_image/build_docker_image.py +145 -0
  8. docker_image/debian/BASE_VERSION +1 -0
  9. docker_image/debian/Dockerfile +40 -0
  10. docker_image/debian/ImageName +1 -0
  11. docker_image/debian/README.md +48 -0
  12. docker_image/debian/pip.conf +3 -0
  13. docker_image/debian/requirements.txt +1 -0
  14. docker_image/docker_image_history.py +101 -0
  15. docker_image/pip.conf +3 -0
  16. docker_image/push_docker_image.py +62 -0
  17. docker_image/requirements.txt +1 -0
  18. docker_image/rocky_meta_runtime.txt +37 -0
  19. idmtools_platform_container/__init__.py +18 -8
  20. idmtools_platform_container/cli/__init__.py +5 -0
  21. idmtools_platform_container/cli/container.py +682 -0
  22. idmtools_platform_container/container_operations/__init__.py +5 -0
  23. idmtools_platform_container/container_operations/docker_operations.py +593 -0
  24. idmtools_platform_container/container_platform.py +375 -0
  25. idmtools_platform_container/platform_operations/__init__.py +5 -0
  26. idmtools_platform_container/platform_operations/experiment_operations.py +112 -0
  27. idmtools_platform_container/platform_operations/simulation_operations.py +58 -0
  28. idmtools_platform_container/plugin_info.py +79 -0
  29. idmtools_platform_container/utils/__init__.py +5 -0
  30. idmtools_platform_container/utils/general.py +136 -0
  31. idmtools_platform_container/utils/status.py +130 -0
  32. idmtools_platform_container-0.0.2.dist-info/METADATA +212 -0
  33. idmtools_platform_container-0.0.2.dist-info/RECORD +69 -0
  34. idmtools_platform_container-0.0.2.dist-info/entry_points.txt +5 -0
  35. idmtools_platform_container-0.0.2.dist-info/licenses/LICENSE.TXT +3 -0
  36. {idmtools_platform_container-0.0.0.dev0.dist-info → idmtools_platform_container-0.0.2.dist-info}/top_level.txt +2 -0
  37. tests/inputs/Assets/MyLib/functions.py +2 -0
  38. tests/inputs/__init__.py +0 -0
  39. tests/inputs/model.py +28 -0
  40. tests/inputs/model1.py +31 -0
  41. tests/inputs/model3.py +21 -0
  42. tests/inputs/model_file.py +18 -0
  43. tests/inputs/run.sh +1 -0
  44. tests/inputs/sleep.py +9 -0
  45. tests/test_container_cli/__init__.py +0 -0
  46. tests/test_container_cli/helper.py +57 -0
  47. tests/test_container_cli/test_base.py +14 -0
  48. tests/test_container_cli/test_cancel.py +96 -0
  49. tests/test_container_cli/test_clear_results.py +54 -0
  50. tests/test_container_cli/test_container.py +72 -0
  51. tests/test_container_cli/test_file_container_cli.py +121 -0
  52. tests/test_container_cli/test_get_detail.py +60 -0
  53. tests/test_container_cli/test_history.py +136 -0
  54. tests/test_container_cli/test_history_count.py +53 -0
  55. tests/test_container_cli/test_inspect.py +53 -0
  56. tests/test_container_cli/test_install.py +48 -0
  57. tests/test_container_cli/test_is_running.py +69 -0
  58. tests/test_container_cli/test_jobs.py +138 -0
  59. tests/test_container_cli/test_list_containers.py +99 -0
  60. tests/test_container_cli/test_packages.py +41 -0
  61. tests/test_container_cli/test_path.py +96 -0
  62. tests/test_container_cli/test_ps.py +47 -0
  63. tests/test_container_cli/test_remove_container.py +78 -0
  64. tests/test_container_cli/test_status.py +149 -0
  65. tests/test_container_cli/test_stop_container.py +71 -0
  66. tests/test_container_cli/test_sync_history.py +98 -0
  67. tests/test_container_cli/test_verify_docker.py +28 -0
  68. tests/test_container_cli/test_volume.py +28 -0
  69. idmtools_platform_container-0.0.0.dev0.dist-info/METADATA +0 -41
  70. idmtools_platform_container-0.0.0.dev0.dist-info/RECORD +0 -5
  71. {idmtools_platform_container-0.0.0.dev0.dist-info → idmtools_platform_container-0.0.2.dist-info}/WHEEL +0 -0
@@ -0,0 +1,78 @@
1
+ import os
2
+ import sys
3
+ from time import sleep
4
+ from unittest.mock import patch
5
+ import pytest
6
+ import idmtools_platform_container.cli.container as container_cli
7
+ from idmtools.entities.command_task import CommandTask
8
+ from idmtools.entities.experiment import Experiment
9
+ from idmtools_platform_container.container_platform import ContainerPlatform
10
+
11
+ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
12
+ from test_base import TestContainerPlatformCliBase
13
+
14
+
15
+ @pytest.mark.serial
16
+ @pytest.mark.cli
17
+ class TestContainerPlatformRemoveContainerCli(TestContainerPlatformCliBase):
18
+
19
+ @patch('rich.console.Console.print')
20
+ def test_remove_container(self, mock_console):
21
+ command = "sleep 100"
22
+ task = CommandTask(command=command)
23
+ experiment = Experiment.from_task(task, name="run_command")
24
+ platform = ContainerPlatform(job_directory=self.job_directory, new_container=True)
25
+ experiment.run(wait_until_done=False, platform=platform)
26
+ result = self.runner.invoke(container_cli.container, ['stop-container', platform.container_id])
27
+ self.assertEqual(result.exit_code, 0)
28
+ sleep(1)
29
+ result = self.runner.invoke(container_cli.container, ['remove-container', platform.container_id])
30
+ self.assertEqual(result.exit_code, 0)
31
+ with patch('rich.console.Console.print') as mock_console:
32
+ result = self.runner.invoke(container_cli.container, ['inspect', platform.container_id])
33
+ self.assertEqual(result.exit_code, 0)
34
+ self.assertTrue(f"Container {platform.container_id} not found.", mock_console.call_args_list[0].args[0])
35
+
36
+ @patch('idmtools_platform_container.cli.container.user_logger')
37
+ def test_remove_container_running_container(self, mock_user_logger):
38
+ command = "sleep 100"
39
+ task = CommandTask(command=command)
40
+ experiment = Experiment.from_task(task, name="run_command")
41
+ platform = ContainerPlatform(job_directory=self.job_directory, new_container=True)
42
+ experiment.run(wait_until_done=False, platform=platform)
43
+ result = self.runner.invoke(container_cli.container, ['remove-container', platform.container_id])
44
+ self.assertEqual(result.exit_code, 0)
45
+ mock_user_logger.warning.assert_called_with(
46
+ f"Container {platform.container_id} is running, need to stop first.")
47
+
48
+ result = self.runner.invoke(container_cli.container, ['stop-container', platform.container_id, '--remove'])
49
+ self.assertEqual(result.exit_code, 0)
50
+
51
+ @patch('idmtools_platform_container.cli.container.user_logger')
52
+ def test_remove_container_invalid(self, mock_user_logger):
53
+ command = "sleep 100"
54
+ platform = ContainerPlatform(job_directory=self.job_directory, new_container=True)
55
+ task = CommandTask(command=command)
56
+ experiment = Experiment.from_task(task, name="run_command")
57
+ experiment.run(wait_until_done=False, platform=platform)
58
+ sleep(1)
59
+ result = self.runner.invoke(container_cli.container, ['remove-container', "abcd"])
60
+ sleep(1)
61
+ mock_user_logger.warning.assert_called_with("Container abcd not found.")
62
+ result = self.runner.invoke(container_cli.container, ['stop-container', platform.container_id, '--remove'])
63
+ self.assertEqual(result.exit_code, 0)
64
+
65
+ def test_remove_container_help(self):
66
+ result = self.runner.invoke(container_cli.container, ['remove-container', "--help"])
67
+ expected_help = ('Usage: container remove-container [OPTIONS] [CONTAINER_ID]\n'
68
+ '\n'
69
+ ' Remove stopped containers.\n'
70
+ '\n'
71
+ ' Arguments:\n'
72
+ '\n'
73
+ ' CONTAINER_ID: Container ID (optional)\n'
74
+ '\n'
75
+ 'Options:\n'
76
+ ' --help Show this message and exit.\n')
77
+ self.assertEqual(result.exit_code, 0)
78
+ self.assertEqual(result.output, expected_help)
@@ -0,0 +1,149 @@
1
+ import os
2
+ import sys
3
+ import unittest
4
+ from unittest import mock
5
+ import pytest
6
+ from idmtools.builders import SimulationBuilder
7
+ from idmtools.core import ItemType
8
+ from idmtools.entities.command_task import CommandTask
9
+ from idmtools.entities.experiment import Experiment
10
+ import idmtools_platform_container.cli.container as container_cli
11
+ from idmtools.entities.templated_simulation import TemplatedSimulations
12
+ from idmtools_platform_container.container_platform import ContainerPlatform
13
+ from idmtools_platform_container.utils.general import normalize_path
14
+
15
+ script_dir = os.path.dirname(os.path.abspath(__file__))
16
+ sys.path.append(script_dir)
17
+ from test_base import TestContainerPlatformCliBase
18
+ from helper import get_actual_rich_table_values, found_job_id_by_experiment, cleaned_str
19
+
20
+
21
+ @pytest.mark.serial
22
+ @pytest.mark.cli
23
+ class TestContainerPlatformStatusCli(TestContainerPlatformCliBase):
24
+ def test_status(self):
25
+ command = "python3 Assets/sleep.py"
26
+ task = CommandTask(command=command)
27
+ task.common_assets.add_asset(os.path.join(script_dir, "..", "inputs", "sleep.py"))
28
+ experiment = Experiment.from_task(task, name="run_command")
29
+ experiment.run(wait_until_done=False)
30
+ exp_dir = self.platform.get_directory_by_id(experiment.id, ItemType.EXPERIMENT)
31
+
32
+ # test status with experiment id
33
+ with mock.patch('rich.console.Console.print') as mock_console:
34
+ result = self.runner.invoke(container_cli.container, ['status', experiment.id])
35
+ self.assertEqual(result.exit_code, 0)
36
+ self.assertIn(normalize_path(exp_dir), mock_console.call_args_list[0].args[0])
37
+ self.assertIn('Simulation Count', cleaned_str(mock_console.call_args_list[1][0][0]))
38
+ self.assertIn('SUCCEEDED', cleaned_str(mock_console.call_args_list[2][0][0]))
39
+ self.assertIn('FAILED', cleaned_str(mock_console.call_args_list[3][0][0]))
40
+ self.assertIn('RUNNING', cleaned_str(mock_console.call_args_list[4][0][0]))
41
+ self.assertIn('PENDING', cleaned_str(mock_console.call_args_list[5][0][0]))
42
+
43
+ # test status with experiment id and container id
44
+ with mock.patch('rich.console.Console.print') as mock_console_container:
45
+ result = self.runner.invoke(container_cli.container,
46
+ ['status', experiment.id, '-c', self.platform.container_id])
47
+ self.assertEqual(result.exit_code, 0)
48
+ self.assertIn(normalize_path(exp_dir), mock_console_container.call_args_list[0].args[0])
49
+ self.assertIn('Simulation Count', cleaned_str(mock_console_container.call_args_list[1][0][0]))
50
+ self.assertIn('SUCCEEDED', cleaned_str(mock_console_container.call_args_list[2][0][0]))
51
+ self.assertIn('FAILED', cleaned_str(mock_console_container.call_args_list[3][0][0]))
52
+ self.assertIn('RUNNING', cleaned_str(mock_console_container.call_args_list[4][0][0]))
53
+ self.assertIn('PENDING', cleaned_str(mock_console_container.call_args_list[5][0][0]))
54
+
55
+ # test status with simulation id
56
+ with mock.patch('rich.console.Console.print') as mock_console_sim:
57
+ print("simulations", experiment.simulations[0].id)
58
+ result = self.runner.invoke(container_cli.container, ['status', experiment.simulations[0].id])
59
+ self.assertEqual(result.exit_code, 0)
60
+ self.assertIn(f'SIMULATION {experiment.simulations[0].id} is ',
61
+ mock_console_sim.call_args_list[0][0][0])
62
+
63
+ # test status with wrong id
64
+ with mock.patch('idmtools_platform_container.cli.container.user_logger') as user_logger:
65
+ result = self.runner.invoke(container_cli.container, ['status', "sim_id"])
66
+ self.assertEqual(result.exit_code, 0)
67
+ user_logger.warning.assert_called_with("Job sim_id not found.")
68
+
69
+ # test status with job id
70
+ with mock.patch('rich.console.Console.print') as mock_console_jobs:
71
+ # first find job id:
72
+ result = self.runner.invoke(container_cli.container, ['jobs'])
73
+ self.assertEqual(result.exit_code, 0)
74
+ actual_table = get_actual_rich_table_values(mock_console_jobs)
75
+ job_id, container_id = found_job_id_by_experiment(actual_table, experiment.id)
76
+ # test status with job id
77
+ with mock.patch('rich.console.Console.print') as mock_console_job:
78
+ result = self.runner.invoke(container_cli.container, ['status', job_id])
79
+ self.assertEqual(result.exit_code, 0)
80
+ self.assertIn(normalize_path(exp_dir), mock_console_job.call_args_list[0].args[0])
81
+ self.assertIn('Simulation Count', cleaned_str(mock_console_job.call_args_list[1][0][0]))
82
+ self.assertIn('SUCCEEDED', cleaned_str(mock_console_job.call_args_list[2][0][0]))
83
+ self.assertIn('FAILED', cleaned_str(mock_console_job.call_args_list[3][0][0]))
84
+ self.assertIn('RUNNING', cleaned_str(mock_console_job.call_args_list[4][0][0]))
85
+ self.assertIn('PENDING', cleaned_str(mock_console_job.call_args_list[5][0][0]))
86
+
87
+ # clean up container
88
+ result = self.runner.invoke(container_cli.container, ['stop-container', self.platform.container_id], '--remove')
89
+ self.assertEqual(result.exit_code, 0)
90
+
91
+ # test status with verbose and limit. For this test, we generate 9 simulations, but only show 2 in the output
92
+ @mock.patch('rich.console.Console.print')
93
+ def test_status_with_verbose_and_limit(self, mock_console):
94
+ platform = ContainerPlatform(job_directory=self.job_directory, new_container=True)
95
+ command = "python3 Assets/sleep.py"
96
+ task = CommandTask(command=command)
97
+ task.common_assets.add_asset(os.path.join(script_dir, "..", "inputs", "sleep.py"))
98
+ ts = TemplatedSimulations(base_task=task)
99
+ sb = SimulationBuilder()
100
+
101
+ def update_parameter_callback(simulation, sleep_time):
102
+ simulation.task.command.add_argument(sleep_time)
103
+ return {'sleep_time': sleep_time}
104
+
105
+ sb.add_sweep_definition(update_parameter_callback, sleep_time=range(1, 10))
106
+ ts.add_builder(sb)
107
+ experiment = Experiment.from_template(ts, name="run_sweep_sleep")
108
+ experiment.run(wait_until_done=True, platform=platform)
109
+ exp_dir = platform.get_directory_by_id(experiment.id, ItemType.EXPERIMENT)
110
+ # we only show 2 simulation details in the output
111
+ result = self.runner.invoke(container_cli.container,
112
+ ['status', experiment.id, '-l', 2, '--verbose'])
113
+ self.assertEqual(result.exit_code, 0)
114
+ self.assertIn(normalize_path(exp_dir), mock_console.call_args_list[0].args[0])
115
+ self.assertEqual('Simulation Count: 9', cleaned_str(mock_console.call_args_list[1][0][0]))
116
+ self.assertEqual('SUCCEEDED (9)', cleaned_str(mock_console.call_args_list[2][0][0]))
117
+ self.assertEqual('...', cleaned_str(mock_console.call_args_list[5][0][0]))
118
+ self.assertEqual('FAILED (0)', cleaned_str(mock_console.call_args_list[6][0][0]))
119
+ self.assertIn('RUNNING', cleaned_str(mock_console.call_args_list[7][0][0]))
120
+ self.assertIn('PENDING', cleaned_str(mock_console.call_args_list[8][0][0]))
121
+ # verify there are 2 lines with simulations
122
+ simulation_ids = [simulation.id for simulation in experiment.simulations]
123
+ self.assertTrue(cleaned_str(mock_console.call_args_list[3][0][0]) in simulation_ids)
124
+ self.assertTrue(cleaned_str(mock_console.call_args_list[4][0][0]) in simulation_ids)
125
+ # clean up container
126
+ result = self.runner.invoke(container_cli.container, ['stop-container', platform.container_id], '--remove')
127
+ self.assertEqual(result.exit_code, 0)
128
+
129
+ def test_status_help(self):
130
+ result = self.runner.invoke(container_cli.container, ['status', "--help"])
131
+ expected_help = ('Usage: container status [OPTIONS] ITEM_ID\n'
132
+ '\n'
133
+ ' Check the status of an Experiment/Simulation.\n'
134
+ '\n'
135
+ ' Arguments:\n'
136
+ '\n'
137
+ ' ITEM_ID: Experiment/Simulation ID or Job ID\n'
138
+ '\n'
139
+ 'Options:\n'
140
+ ' -c, --container_id TEXT Container Id\n'
141
+ ' -l, --limit INTEGER Max number of simulations to show\n'
142
+ ' --verbose / --no-verbose Display with working directory or not\n'
143
+ ' --help Show this message and exit.\n')
144
+ self.assertEqual(result.exit_code, 0)
145
+ self.assertEqual(result.output, expected_help)
146
+
147
+
148
+ if __name__ == '__main__':
149
+ unittest.main()
@@ -0,0 +1,71 @@
1
+ import os
2
+ import sys
3
+ from time import sleep
4
+ from unittest.mock import patch
5
+ import pytest
6
+ import idmtools_platform_container.cli.container as container_cli
7
+ from idmtools.entities.command_task import CommandTask
8
+ from idmtools.entities.experiment import Experiment
9
+ from idmtools_platform_container.container_platform import ContainerPlatform
10
+
11
+ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
12
+ from test_base import TestContainerPlatformCliBase
13
+
14
+
15
+ @pytest.mark.serial
16
+ @pytest.mark.cli
17
+ class TestContainerPlatformStopContainerCli(TestContainerPlatformCliBase):
18
+
19
+ @patch('rich.console.Console.print')
20
+ def test_stop_container(self, mock_console):
21
+ command = "sleep 100"
22
+ task = CommandTask(command=command)
23
+ experiment = Experiment.from_task(task, name="run_command")
24
+ experiment.run(wait_until_done=False)
25
+ sleep(1)
26
+ result = self.runner.invoke(container_cli.container, ['stop-container', self.platform.container_id], '--remove')
27
+ sleep(1)
28
+ self.assertTrue(f"Container {self.platform.container_id} is stopped.", mock_console.call_args_list[0].args[0])
29
+
30
+ def test_stop_container_with_stopped_container(self):
31
+ command = "sleep 100"
32
+ task = CommandTask(command=command)
33
+ experiment = Experiment.from_task(task, name="run_command")
34
+ platform = ContainerPlatform(job_directory=self.job_directory, new_container=True)
35
+ experiment.run(wait_until_done=False, platform=platform)
36
+ sleep(1)
37
+ result = self.runner.invoke(container_cli.container, ['stop-container', platform.container_id])
38
+ sleep(1)
39
+ with patch('idmtools_platform_container.cli.container.user_logger') as mock_user_logger:
40
+ # call stop container again to see what happens
41
+ result = self.runner.invoke(container_cli.container, ['stop-container', platform.container_id])
42
+ self.assertEqual(result.exit_code, 0)
43
+ mock_user_logger.warning.assert_called_with(f"Not found running Container {platform.container_id}.")
44
+
45
+ @patch('idmtools_platform_container.cli.container.user_logger')
46
+ def test_stop_container_invalid(self, mock_user_logger):
47
+ command = "sleep 100"
48
+ platform = ContainerPlatform(job_directory=self.job_directory, new_container=True)
49
+ task = CommandTask(command=command)
50
+ experiment = Experiment.from_task(task, name="run_command")
51
+ experiment.run(wait_until_done=False, platform=platform)
52
+ sleep(1)
53
+ result = self.runner.invoke(container_cli.container, ['stop-container', "abcd"])
54
+ sleep(1)
55
+ mock_user_logger.warning.assert_called_with("Not found running Container abcd.")
56
+
57
+ def test_stop_container_help(self):
58
+ result = self.runner.invoke(container_cli.container, ['stop-container', "--help"])
59
+ expected_help = ('Usage: container stop-container [OPTIONS] [CONTAINER_ID]\n'
60
+ '\n'
61
+ ' Stop running container(s).\n'
62
+ '\n'
63
+ ' Arguments:\n'
64
+ '\n'
65
+ ' CONTAINER_ID: Container ID (optional)\n'
66
+ '\n'
67
+ 'Options:\n'
68
+ ' --remove / --no-remove Remove the container or not\n'
69
+ ' --help Show this message and exit.\n')
70
+ self.assertEqual(result.exit_code, 0)
71
+ self.assertEqual(result.output, expected_help)
@@ -0,0 +1,98 @@
1
+ import os
2
+ import shutil
3
+ import sys
4
+ import unittest
5
+ from unittest.mock import patch
6
+ import pytest
7
+
8
+ from idmtools.core import ItemType
9
+ from idmtools.entities import Suite
10
+ from idmtools.entities.command_task import CommandTask
11
+ from idmtools.entities.experiment import Experiment
12
+ import idmtools_platform_container.cli.container as container_cli
13
+ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
14
+ from test_base import TestContainerPlatformCliBase
15
+
16
+ @pytest.mark.serial
17
+ @pytest.mark.cli
18
+ class TestContainerPlatformSyncHistoryCli(TestContainerPlatformCliBase):
19
+ @patch('rich.console.Console.print')
20
+ def test_sync_history(self, mock_console):
21
+ # first clear the history
22
+ result = self.runner.invoke(container_cli.container, ['clear-history'])
23
+ self.assertEqual(result.exit_code, 0)
24
+ command = "sleep 100"
25
+ task = CommandTask(command=command)
26
+ experiment = Experiment.from_task(task, name="run_command")
27
+ experiment.run(wait_until_done=False)
28
+ # verify there is 1 job in history
29
+ result = self.runner.invoke(container_cli.container, ['history'])
30
+ self.assertEqual(result.exit_code, 0)
31
+ self.assertEqual('There are 1 Experiment cache in history.', mock_console.call_args_list[0].args[0])
32
+ # remove experiment folder
33
+ exp_folder = self.platform.get_directory_by_id(experiment.id, ItemType.EXPERIMENT)
34
+ shutil.rmtree(exp_folder, ignore_errors=False)
35
+ result = self.runner.invoke(container_cli.container, ['history'])
36
+ self.assertEqual(result.exit_code, 0)
37
+ self.assertEqual('There are 1 Experiment cache in history.', mock_console.call_args_list[0].args[0])
38
+ # call sync-history
39
+ result = self.runner.invoke(container_cli.container, ['sync-history'])
40
+ self.assertEqual(result.exit_code, 0)
41
+ with patch('rich.console.Console.print') as mock_console1:
42
+ result = self.runner.invoke(container_cli.container, ['history'])
43
+ self.assertEqual(result.exit_code, 0)
44
+ self.assertEqual('There are 0 Experiment cache in history.', mock_console1.call_args_list[0].args[0])
45
+
46
+ # clean up container
47
+ result = self.runner.invoke(container_cli.container, ['stop-container', self.platform.container_id], '--remove')
48
+ self.assertEqual(result.exit_code, 0)
49
+
50
+ @patch('rich.console.Console.print')
51
+ def test_sync_history_with_suite(self, mock_console):
52
+ # first clear the history
53
+ result = self.runner.invoke(container_cli.container, ['clear-history'])
54
+ self.assertEqual(result.exit_code, 0)
55
+ command = "sleep 100"
56
+ task = CommandTask(command=command)
57
+ experiment = Experiment.from_task(task, name="run_command")
58
+ experiment2 = Experiment.from_task(task, name="run_command")
59
+ suite = Suite(name="suite_name")
60
+ suite.add_experiment(experiment)
61
+ suite.add_experiment(experiment2)
62
+ suite.run(wait_until_done=False)
63
+ # verify there is 1 job in history
64
+ result = self.runner.invoke(container_cli.container, ['history'])
65
+ self.assertEqual(result.exit_code, 0)
66
+ self.assertEqual('There are 2 Experiment cache in history.', mock_console.call_args_list[0].args[0])
67
+ # remove experiment folder
68
+ exp_folder = self.platform.get_directory_by_id(experiment.id, ItemType.EXPERIMENT)
69
+ shutil.rmtree(exp_folder, ignore_errors=False)
70
+ result = self.runner.invoke(container_cli.container, ['history'])
71
+ self.assertEqual(result.exit_code, 0)
72
+ self.assertEqual('There are 2 Experiment cache in history.', mock_console.call_args_list[0].args[0])
73
+ # call sync-history
74
+ result = self.runner.invoke(container_cli.container, ['sync-history'])
75
+ self.assertEqual(result.exit_code, 0)
76
+ with patch('rich.console.Console.print') as mock_console1:
77
+ result = self.runner.invoke(container_cli.container, ['history'])
78
+ self.assertEqual(result.exit_code, 0)
79
+ self.assertEqual('There are 1 Experiment cache in history.', mock_console1.call_args_list[0].args[0])
80
+
81
+ # clean up container
82
+ result = self.runner.invoke(container_cli.container, ['stop-container', self.platform.container_id], '--remove')
83
+ self.assertEqual(result.exit_code, 0)
84
+
85
+ def test_sync_history_help(self):
86
+ result = self.runner.invoke(container_cli.container, ['sync-history', "--help"])
87
+ expected_help = ('Usage: container sync-history [OPTIONS]\n'
88
+ '\n'
89
+ ' Sync the file system with job history.\n'
90
+ '\n'
91
+ 'Options:\n'
92
+ ' --help Show this message and exit.\n')
93
+ self.assertEqual(result.exit_code, 0)
94
+ self.assertEqual(result.output, expected_help)
95
+
96
+
97
+ if __name__ == '__main__':
98
+ unittest.main()
@@ -0,0 +1,28 @@
1
+ import os
2
+ import sys
3
+ from unittest.mock import patch
4
+ import pytest
5
+ import idmtools_platform_container.cli.container as container_cli
6
+ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
7
+ from test_base import TestContainerPlatformCliBase
8
+
9
+
10
+ @pytest.mark.serial
11
+ @pytest.mark.cli
12
+ class TestContainerPlatformVerifyDockerCli(TestContainerPlatformCliBase):
13
+
14
+ @patch('rich.console.Console.print')
15
+ def test_verify_docker(self, mock_console):
16
+ result = self.runner.invoke(container_cli.container, ['verify-docker'])
17
+ self.assertIn('Docker version ', mock_console.call_args_list[0][0][0])
18
+
19
+ def test_verify_docker_help(self):
20
+ result = self.runner.invoke(container_cli.container, ['verify-docker', "--help"])
21
+ expected_help = ('Usage: container verify-docker [OPTIONS]\n'
22
+ '\n'
23
+ ' Verify the Docker environment.\n'
24
+ '\n'
25
+ 'Options:\n'
26
+ ' --help Show this message and exit.\n')
27
+ self.assertEqual(result.exit_code, 0)
28
+ self.assertEqual(result.output, expected_help)
@@ -0,0 +1,28 @@
1
+ import os
2
+ import sys
3
+ from unittest.mock import patch
4
+ import pytest
5
+ import idmtools_platform_container.cli.container as container_cli
6
+ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
7
+ from test_base import TestContainerPlatformCliBase
8
+
9
+
10
+ @pytest.mark.serial
11
+ @pytest.mark.cli
12
+ class TestContainerPlatformVolumeCli(TestContainerPlatformCliBase):
13
+
14
+ @patch('rich.console.Console.print')
15
+ def test_volume(self, mock_console):
16
+ result = self.runner.invoke(container_cli.container, ['volume'])
17
+ self.assertIn('Job history volume: ', mock_console.call_args_list[0][0][0])
18
+
19
+ def test_volume_help(self):
20
+ result = self.runner.invoke(container_cli.container, ['volume', "--help"])
21
+ expected_help = ('Usage: container volume [OPTIONS]\n'
22
+ '\n'
23
+ ' Check the history volume.\n'
24
+ '\n'
25
+ 'Options:\n'
26
+ ' --help Show this message and exit.\n')
27
+ self.assertEqual(result.exit_code, 0)
28
+ self.assertEqual(result.output, expected_help)
@@ -1,41 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: idmtools-platform-container
3
- Version: 0.0.0.dev0
4
- Summary: Placeholder package for idmtools-platform-container - reserved for future use
5
- Author-email: IDM <idmtools@idmod.org>
6
- License: Proprietary
7
- Project-URL: Homepage, https://github.com/InstituteforDiseaseModeling/idmtools
8
- Project-URL: Bug Tracker, https://github.com/InstituteforDiseaseModeling/idmtools/issues
9
- Keywords: placeholder,reserved,idmtools
10
- Classifier: Development Status :: 1 - Planning
11
- Classifier: Intended Audience :: Developers
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.8
14
- Classifier: Programming Language :: Python :: 3.9
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Requires-Python: >=3.8
19
- Description-Content-Type: text/markdown
20
-
21
- # idmtools-platform-container
22
-
23
- **PLACEHOLDER PACKAGE - NOT FOR USE**
24
-
25
- This package is a placeholder to reserve the name `idmtools-platform-container` on PyPI.
26
-
27
- The actual package implementation will be released in the future.
28
-
29
- ## Purpose
30
-
31
- This placeholder ensures the package name is reserved and prevents name squatting.
32
-
33
- ## Status
34
-
35
- This is version 0.0.0.dev0 - a minimal placeholder release.
36
-
37
- ## Future Release
38
-
39
- The full implementation of idmtools-platform-container will be published when ready.
40
-
41
- For more information, visit: https://github.com/InstituteforDiseaseModeling/idmtools
@@ -1,5 +0,0 @@
1
- idmtools_platform_container/__init__.py,sha256=LVLYa4KrrzCoWwooke1ODplthaFW0PBelmNgRwqMxLc,198
2
- idmtools_platform_container-0.0.0.dev0.dist-info/METADATA,sha256=QpPigLXQ4mhXY0MMPUp2FcQu2ySmOM7OxcgR9Iq-1ts,1513
3
- idmtools_platform_container-0.0.0.dev0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
4
- idmtools_platform_container-0.0.0.dev0.dist-info/top_level.txt,sha256=4h1Pm1rUQ4kvj0DdwPyfRbr0CGoCJjoIJwejLy0UyFE,28
5
- idmtools_platform_container-0.0.0.dev0.dist-info/RECORD,,