idmtools-cli 0.0.0.dev0__py3-none-any.whl → 0.0.3__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.
@@ -0,0 +1,135 @@
1
+ """Defines utilities for display formatting on multiple platforms."""
2
+ from __future__ import absolute_import
3
+ from typing import Optional
4
+ from .formatters import max_width, min_width
5
+ import sys
6
+
7
+ NEWLINES = ('\n', '\r', '\r\n')
8
+
9
+
10
+ def _find_unix_console_width() -> Optional[int]:
11
+ """
12
+ Find the width of a Unix console where possible.
13
+
14
+ Returns:
15
+ Width
16
+ """
17
+ import termios
18
+ import fcntl
19
+ import struct
20
+
21
+ # fcntl.ioctl will fail if stdout is not a tty
22
+ if not sys.stdout.isatty():
23
+ return None
24
+
25
+ s = struct.pack("HHHH", 0, 0, 0, 0)
26
+ fd_stdout = sys.stdout.fileno()
27
+ size = fcntl.ioctl(fd_stdout, termios.TIOCGWINSZ, s)
28
+ height, width = struct.unpack("HHHH", size)[:2]
29
+ return width
30
+
31
+
32
+ def _find_windows_console_width() -> int:
33
+ """
34
+ Find the windows console width.
35
+
36
+ Returns:
37
+ Returns width of Windows Console
38
+ """
39
+ from ctypes import windll, create_string_buffer
40
+ stdin, stdout, stderr = -10, -11, -12 # noqa: F841
41
+
42
+ h = windll.kernel32.GetStdHandle(stderr)
43
+ csbi = create_string_buffer(22)
44
+ res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)
45
+
46
+ if res:
47
+ import struct
48
+ (bufx, bufy, curx, cury, wattr,
49
+ left, top, right, bottom,
50
+ maxx, maxy) = struct.unpack("hhhhHhhhhhh", csbi.raw)
51
+ sizex = right - left + 1
52
+ return sizex
53
+
54
+
55
+ def console_width(kwargs: dict) -> int:
56
+ """
57
+ Determine Console Width.
58
+
59
+ Args:
60
+ kwargs: Optional args. Currently Width is supported
61
+
62
+ Returns:
63
+ Console Width
64
+ """
65
+ if sys.platform.startswith('win'):
66
+ cons_width = _find_windows_console_width()
67
+ else:
68
+ cons_width = _find_unix_console_width()
69
+
70
+ _width = kwargs.get('width', None)
71
+ if _width:
72
+ cons_width = _width
73
+ else:
74
+ if not cons_width:
75
+ cons_width = 80
76
+
77
+ return cons_width
78
+
79
+
80
+ def columns(*cols, **kwargs) -> str:
81
+ """
82
+ Format click output in columns.
83
+
84
+ Args:
85
+ *cols: Colums in tuples
86
+ **kwargs: Optional arguments
87
+
88
+ Examples:
89
+ > click.echo(columns((a, 20), (b, 20), (b, None)))
90
+
91
+ Returns:
92
+ Column formatted strings
93
+ """
94
+ cwidth = console_width(kwargs)
95
+
96
+ _big_col = None
97
+ _total_cols = 0
98
+
99
+ cols = [list(c) for c in cols]
100
+
101
+ for i, (string, width) in enumerate(cols):
102
+
103
+ if width is not None:
104
+ _total_cols += (width + 1)
105
+ cols[i][0] = max_width(string, width).split('\n')
106
+ else:
107
+ _big_col = i
108
+
109
+ if _big_col:
110
+ cols[_big_col][1] = (cwidth - _total_cols) - len(cols)
111
+ cols[_big_col][0] = max_width(cols[_big_col][0], cols[_big_col][1]).split('\n')
112
+
113
+ height = len(max([c[0] for c in cols], key=len))
114
+
115
+ for i, (strings, width) in enumerate(cols):
116
+
117
+ for _ in range(height - len(strings)):
118
+ cols[i][0].append('')
119
+
120
+ for j, string in enumerate(strings):
121
+ cols[i][0][j] = min_width(string, width)
122
+
123
+ stack = [c[0] for c in cols]
124
+ _out = []
125
+
126
+ for i in range(height):
127
+ _row = ''
128
+
129
+ for col in stack:
130
+ _row += col[i]
131
+ _row += ' '
132
+
133
+ _out.append(_row)
134
+
135
+ return '\n'.join(_out)
@@ -0,0 +1,105 @@
1
+ """Utility functions around formatting output for cli."""
2
+ from __future__ import absolute_import
3
+ import re
4
+ from .utils import tsplit, schunk
5
+
6
+ NEWLINES = ('\n', '\r', '\r\n')
7
+
8
+
9
+ def clean(s: str):
10
+ """
11
+ Clean string so that all special formatting is stripped.
12
+
13
+ Args:
14
+ s: str
15
+
16
+ Returns:
17
+ Cleaned string
18
+ """
19
+ strip = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]')
20
+ txt = strip.sub('', s)
21
+
22
+ return txt
23
+
24
+
25
+ def min_width(string, cols: int, padding=' '):
26
+ """
27
+ Returns given string with right padding.
28
+
29
+ Args:
30
+ string: string to be formatted
31
+ cols: min width the text to be formatted
32
+ padding: Padding
33
+
34
+ Returns:
35
+ String formatted with min width
36
+ """
37
+ stack = tsplit(str(string), NEWLINES)
38
+
39
+ for i, substring in enumerate(stack):
40
+ _sub = clean(substring).ljust((cols + 0), padding)
41
+ stack[i] = _sub
42
+
43
+ return '\n'.join(stack)
44
+
45
+
46
+ def max_width(string: str, cols: int, separator='\n'):
47
+ """
48
+ Returns a freshly formatted string.
49
+
50
+ Args:
51
+ string: string to be formatted
52
+ cols: max width the text to be formatted
53
+ separator: separator to break rows
54
+
55
+ Returns:
56
+ String formatted with max width
57
+ """
58
+ stack = tsplit(string, NEWLINES)
59
+
60
+ for i, substring in enumerate(stack):
61
+ stack[i] = substring.split()
62
+
63
+ _stack = []
64
+
65
+ for row in stack:
66
+ _row = ['', ]
67
+ _row_i = 0
68
+
69
+ for word in row:
70
+ if (len(_row[_row_i]) + len(word)) <= cols:
71
+ _row[_row_i] += word
72
+ _row[_row_i] += ' '
73
+
74
+ elif len(word) > cols:
75
+
76
+ # ensure empty row
77
+ if len(_row[_row_i]):
78
+ _row[_row_i] = _row[_row_i].rstrip()
79
+ _row.append('')
80
+ _row_i += 1
81
+
82
+ chunks = schunk(word, cols)
83
+ for i, chunk in enumerate(chunks):
84
+ if i + 1 != len(chunks):
85
+ _row[_row_i] += chunk
86
+ _row[_row_i] = _row[_row_i].rstrip()
87
+ _row.append('')
88
+ _row_i += 1
89
+ else:
90
+ _row[_row_i] += chunk
91
+ _row[_row_i] += ' '
92
+ else:
93
+ _row[_row_i] = _row[_row_i].rstrip()
94
+ _row.append('')
95
+ _row_i += 1
96
+ _row[_row_i] += word
97
+ _row[_row_i] += ' '
98
+ else:
99
+ _row[_row_i] = _row[_row_i].rstrip()
100
+
101
+ _row = map(str, _row)
102
+ _stack.append(separator.join(_row))
103
+
104
+ _s = '\n'.join(_stack)
105
+ return _s
@@ -0,0 +1,63 @@
1
+ """Misc util functions for cli."""
2
+ from __future__ import absolute_import
3
+ from __future__ import with_statement
4
+
5
+ import errno
6
+ import os.path
7
+ from os import makedirs
8
+ from glob import glob
9
+
10
+ try:
11
+ basestring
12
+ except NameError:
13
+ basestring = str
14
+
15
+
16
+ def expand_path(path):
17
+ """Expands directories and globs in given path."""
18
+ paths = []
19
+ path = os.path.expanduser(path)
20
+ path = os.path.expandvars(path)
21
+
22
+ if os.path.isdir(path):
23
+
24
+ for (dir, _dirs, files) in os.walk(path):
25
+ for file in files:
26
+ paths.append(os.path.join(dir, file))
27
+ else:
28
+ paths.extend(glob(path))
29
+
30
+ return paths
31
+
32
+
33
+ def is_collection(obj):
34
+ """Tests if an object is a collection. Strings don't count."""
35
+ if isinstance(obj, basestring):
36
+ return False
37
+
38
+ return hasattr(obj, '__getitem__')
39
+
40
+
41
+ def mkdir_p(path):
42
+ """Emulates `mkdir -p` behavior."""
43
+ try:
44
+ makedirs(path)
45
+ except OSError as exc: # Python >2.5
46
+ if exc.errno != errno.EEXIST:
47
+ raise
48
+
49
+
50
+ def tsplit(string, delimiters):
51
+ """Behaves str.split but supports tuples of delimiters."""
52
+ delimiters = tuple(delimiters)
53
+ if len(delimiters) < 1:
54
+ return [string, ]
55
+ final_delimiter = delimiters[0]
56
+ for i in delimiters[1:]:
57
+ string = string.replace(i, final_delimiter)
58
+ return string.split(final_delimiter)
59
+
60
+
61
+ def schunk(string, size):
62
+ """Splits string into n sized chunks."""
63
+ return [string[i:i + size] for i in range(0, len(string), size)]
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.4
2
+ Name: idmtools_cli
3
+ Version: 0.0.3
4
+ Summary: CLI for IDM-Tools
5
+ Author-email: Sharon Chen <schen@idmod.org>, Clinton Collins <ccollins@idmod.org>, Zhaowei Du <zdu@idmod.org>, Mary Fisher <mfisher@idmod.org>, Clark Kirkman IV <ckirkman@idmod.org>, Benoit Raybaud <braybaud@idmod.org>
6
+ Project-URL: Homepage, https://github.com/InstituteforDiseaseModeling/idmtools
7
+ Keywords: modeling,IDM,cli
8
+ Classifier: Programming Language :: Python :: 3.8
9
+ Classifier: Programming Language :: Python :: 3.9
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE.TXT
16
+ Requires-Dist: click~=8.1.7
17
+ Requires-Dist: click-plugins
18
+ Requires-Dist: colorama~=0.4.6
19
+ Requires-Dist: cookiecutter~=2.6.0
20
+ Requires-Dist: idmtools<1.0.0,>=0.0.0
21
+ Requires-Dist: tabulate<0.10,>=0.8.9
22
+ Requires-Dist: pyperclip~=1.8
23
+ Requires-Dist: yaspin<3.1.0,>=1.2.0
24
+ Provides-Extra: test
25
+ Requires-Dist: idmtools[test]; extra == "test"
26
+ Dynamic: license-file
27
+
28
+ ![Staging: idmtools-cli](https://github.com/InstituteforDiseaseModeling/idmtools/workflows/Staging:%20idmtools-cli/badge.svg?branch=dev)
29
+
30
+ # idmtools-cli
31
+
32
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
33
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
34
+ **Table of Contents**
35
+
36
+ - [Installing](#installing)
37
+ - [Development tips](#development-tips)
38
+ - [Using the CLI](#using-the-cli)
39
+ - [Version command](#version-command)
40
+ - [Experiment commands for Local Platform](#experiment-commands-for-local-platform)
41
+ - [Status](#status)
42
+ - [Delete](#delete)
43
+ - [Simulation commands for Local Platform](#simulation-commands-for-local-platform)
44
+ - [Status](#status-1)
45
+ - [GitRepo commands](#gitrepo-commands)
46
+ - [View](#view)
47
+ - [Repos](#repos)
48
+ - [Releases](#releases)
49
+ - [Peep](#peep)
50
+ - [Download](#download)
51
+
52
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
53
+
54
+ ## Installing
55
+
56
+ ```bash
57
+ pip install idmtools-cli --index-url=https://packages.idmod.org/api/pypi/pypi-production/simple
58
+ ```
59
+
60
+ # Development tips
61
+
62
+ There is a Makefile file available for most common development tasks. Here is a list of commands
63
+ ```bash
64
+ clean - Clean up temproary files
65
+ lint - Lint package and tests
66
+ test - Run All tests
67
+ coverage - Run tests and generate coverage report that is shown in browser
68
+ ```
69
+ On Windows, you can use `pymake` instead of `make`
70
+
71
+ # Using the CLI
72
+
73
+ The CLI requires the workers service to already be running.
74
+ `idmtools`
75
+
76
+ ## Version command
77
+
78
+ To determine version of idmtools and related plugins, use the version cli command.
79
+
80
+
81
+ ```
82
+ > idmtools version
83
+ ```
84
+
85
+ Example output
86
+ ```bash
87
+ emodpy Version: 1.3.0
88
+ Plugins:
89
+ EMODTask
90
+ idmtools Version: 1.4.0+nightly.0
91
+ Plugins:
92
+ CommandTask
93
+ idmtools-cli Version: 1.4.0+nightly.0
94
+ idmtools-models Version: 1.4.0+nightly.0
95
+ Plugins:
96
+ JSONConfiguredPythonTask
97
+ JSONConfiguredRTask
98
+ JSONConfiguredTask
99
+ PythonTask
100
+ RTask
101
+ ScriptWrapperTask
102
+ TemplatedScriptTask
103
+ idmtools-platform-comps Version: 1.4.0+nightly.0
104
+ Plugins:
105
+ COMPSPlatform
106
+ SSMTPlatform
107
+ idmtools-platform-slurm Version: 1.0.0+nightly
108
+ Plugins:
109
+ SlurmPlatform
110
+ ```
111
+
112
+
113
+ ## Experiment commands for Local Platform
114
+
115
+ ### Status
116
+
117
+ You can check the status of experiments use the follow command. It will also summarize the simulations under
118
+ the experiment as a progress bar with green section for completed tasks, yellow for in progress, red for failed, and
119
+ white for queued.
120
+
121
+ ```
122
+ > idmtools experiment --platform Local status --help
123
+ ```
124
+
125
+
126
+ In addition, we used in conjunction with a console that supports auto-highlighting of hyperlinks, you will be able to
127
+ easily open up the asset directories by clicking on the data path URLs.
128
+
129
+ You can also perform filtering on the experiments
130
+ ```bash
131
+ > idmtools experiment --platform Local status --tag type PythonExperiment
132
+ > idmtools experiment --platform Local status --id 8EHU147Z
133
+ ```
134
+
135
+ ### Delete
136
+
137
+ You can delete experiments and their child simulations using the following command. Optionally you can also delete
138
+ the associated data directories as well by using the *--data* option.
139
+
140
+ ```
141
+ >idmtools experiment --platform Local delete <experiment_id>
142
+ ```
143
+
144
+ ## Simulation commands for Local Platform
145
+
146
+ ## Status
147
+
148
+ You can check the status of simulations use the follow command.
149
+
150
+ ```
151
+ >idmtools simulation --platform Local status
152
+ ```
153
+
154
+ You can also filter by a either id, experiment id, status, and tags or any combination of the aforementioned
155
+
156
+ ```bash
157
+ > idmtools simulation --platform Local status --experiment-id EFX6JXBV
158
+ > idmtools simulation --platform Local status --id XDT0VMVV
159
+ > idmtools simulation --platform Local status --tag a 5 --tag b
160
+ > idmtools simulation --platform Local status --experiment-id --status failed
161
+ ```
162
+
163
+
164
+ ## GitRepo commands
165
+
166
+ ### View
167
+
168
+ You can check idmtools available examples. You can use --raw to determine to display in detailed or simplified format
169
+
170
+ ```
171
+ > idmtools gitrepo view
172
+ ```
173
+
174
+ ### Repos
175
+
176
+ You can list all public repos for a GitHub owner. You can use --owner to specify an owner and --page for pagination
177
+ --owner default to 'institutefordiseasemodeling'
178
+ --page default to 1
179
+
180
+ ```
181
+ > idmtools gitrepo repos
182
+ ```
183
+
184
+ ### Releases
185
+
186
+ You can list all releases of a repo by providing --owner and --repo
187
+ --owner default to 'institutefordiseasemodeling' and --repo default to 'idmtools'
188
+
189
+ ```
190
+ > idmtools gitrepo releasess
191
+ ```
192
+
193
+ ### Peep
194
+
195
+ You can list all current files/dirs of a repo folder by providing --url
196
+
197
+ ```
198
+ > idmtools gitrepo peep
199
+ ```
200
+
201
+ ### Download
202
+
203
+ You can download files from a public repo to a specified local folder (default to current folder). By default, it will
204
+ download idmtools examples. You can also download any files from any public repo by using --url (multiple is supported)
205
+
206
+ ```
207
+ > idmtools gitrepo download
208
+ ```
@@ -0,0 +1,22 @@
1
+ idmtools_cli/__init__.py,sha256=sEBWyulZ-E6ZW9tckw0upjv2CXr54scjCD-G7_sGSGA,404
2
+ idmtools_cli/iplatform_cli.py,sha256=tNWPKXFvNvUUcTrTW7fOq9fnWa_CAo--wnq7G5SpiSs,4203
3
+ idmtools_cli/main.py,sha256=8FzGi8ql1VzlZ-z_2Y6Smrn-u-qEMoDzqjtx_9m4AEg,1428
4
+ idmtools_cli/cli/__init__.py,sha256=W27dJyYV-UFQiUpLLHOd-akBiOCFn94wspdblnJm-4E,25
5
+ idmtools_cli/cli/common_project_templates.json,sha256=9eattYzi8VE2YjHnxz6l24jgUfvk01OvzyHWG5AVeO8,1236
6
+ idmtools_cli/cli/config_file.py,sha256=R8nX7Ig1ic7eoVDfm1-tLUrGhQVrmZAPdLYoWfhkJmE,6876
7
+ idmtools_cli/cli/entrypoint.py,sha256=SMk8c8fOEUgBAzH1-Ry9wMu9LlNVsuL86NTwAlLKzCw,1624
8
+ idmtools_cli/cli/gitrepo.py,sha256=4j8XRxf4nVs3zjYMSYNjWSkXXmf5W9yXAMzIwKeJ-DE,11883
9
+ idmtools_cli/cli/init.py,sha256=U-MdurqF0pI60joet7TfCeTUyAiJL6hrw0OqHVVUZC4,3294
10
+ idmtools_cli/cli/package.py,sha256=ULzhssPxfRjYUcDFwFF6iX5T8hU8jA4luvEidAvupnw,3758
11
+ idmtools_cli/cli/system_info.py,sha256=DZ7a4qeOO1xV1JmdNf8iiTQN47g7YIfl0iZQ3XjqPyw,6574
12
+ idmtools_cli/cli/utils.py,sha256=c-SUl-XBFUu-jDDdOqMtJLOaIubAKSVPBfUqlN3gPTY,1619
13
+ idmtools_cli/utils/__init__.py,sha256=bDPP5rNgKsS-pNIr8PTNxcNC4yEtDiBm5WqikdkJBgY,28
14
+ idmtools_cli/utils/cols.py,sha256=S1iB5XVCKNjbTG32WKbq0nxAtw7uQI_kVEc3hF3d1m4,3181
15
+ idmtools_cli/utils/formatters.py,sha256=8PWs23BoquAuNrp4CKooL7IcnvB4LQIqFPtDc52U-D4,2643
16
+ idmtools_cli/utils/utils.py,sha256=fGN8-J1ucsah37ej7A691isNHooqm_1wJ-RY1bXuT0o,1507
17
+ idmtools_cli-0.0.3.dist-info/licenses/LICENSE.TXT,sha256=l9S8Ydr_LcejxKoqK8191ZAOsmVX-nJLSPoLKZDUgcg,197
18
+ idmtools_cli-0.0.3.dist-info/METADATA,sha256=GoVv_QxHbw0AfmDgUGMntPNnMRv0I27DUAwJjFA4dSc,6333
19
+ idmtools_cli-0.0.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
20
+ idmtools_cli-0.0.3.dist-info/entry_points.txt,sha256=gBZCfX9EkfkYtAoN8-bmXmaRNB6_ZQO9xb9_NcPQ0c0,52
21
+ idmtools_cli-0.0.3.dist-info/top_level.txt,sha256=x73U8RzbjKObflWrJtj_wQxw0rkmUv3BgNuQHt1wyAE,13
22
+ idmtools_cli-0.0.3.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ idmtools = idmtools_cli.main:main
@@ -0,0 +1,3 @@
1
+ idmtools is licensed under the Creative Commons Attribution-Noncommercial-ShareAlike 4.0 License.
2
+
3
+ To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
@@ -1,41 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: idmtools-cli
3
- Version: 0.0.0.dev0
4
- Summary: Placeholder package for idmtools-cli - 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-cli
22
-
23
- **PLACEHOLDER PACKAGE - NOT FOR USE**
24
-
25
- This package is a placeholder to reserve the name `idmtools-cli` 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-cli will be published when ready.
40
-
41
- For more information, visit: https://github.com/InstituteforDiseaseModeling/idmtools
@@ -1,5 +0,0 @@
1
- idmtools_cli/__init__.py,sha256=oC5LxDoe7FrQgNwAtQoenj9Ne-g6RXWsNDXtbwCRo1U,183
2
- idmtools_cli-0.0.0.dev0.dist-info/METADATA,sha256=9qqO8VWY7W4fY4ZKhEBqYSF8AdlShoZb6fPdO7HdiDU,1438
3
- idmtools_cli-0.0.0.dev0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
4
- idmtools_cli-0.0.0.dev0.dist-info/top_level.txt,sha256=x73U8RzbjKObflWrJtj_wQxw0rkmUv3BgNuQHt1wyAE,13
5
- idmtools_cli-0.0.0.dev0.dist-info/RECORD,,