-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.html
416 lines (380 loc) · 35.5 KB
/
utils.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Utils — Curifactory documentation</title><link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/theme_overrides.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="Store" href="store.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home">
Curifactory
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption"><span class="caption-text">Usage</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="getting_started.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="components.html">Components</a></li>
<li class="toctree-l1"><a class="reference internal" href="parameters.html">Parameter files and parameter sets</a></li>
<li class="toctree-l1"><a class="reference internal" href="cache.html">Cache</a></li>
<li class="toctree-l1"><a class="reference internal" href="hashing_mechanics.html">Hashing Mechanics</a></li>
<li class="toctree-l1"><a class="reference internal" href="experiment_graph.html">Experiment Graph (DAG)</a></li>
<li class="toctree-l1"><a class="reference internal" href="reports.html">Reports</a></li>
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration and directory structure</a></li>
<li class="toctree-l1"><a class="reference internal" href="cli_guide.html">CLI Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="example.html">Example Experiment</a></li>
<li class="toctree-l1"><a class="reference internal" href="tips.html">Tips and tricks</a></li>
<li class="toctree-l1"><a class="reference internal" href="cookbook.html">Curifactory Cookbook</a></li>
<li class="toctree-l1"><a class="reference internal" href="migration.html">Migration Guide</a></li>
</ul>
<p class="caption"><span class="caption-text">API</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="args.html">Args</a></li>
<li class="toctree-l1"><a class="reference internal" href="caching.html">Caching</a></li>
<li class="toctree-l1"><a class="reference internal" href="dag.html">DAG</a></li>
<li class="toctree-l1"><a class="reference internal" href="docker.html">Docker</a></li>
<li class="toctree-l1"><a class="reference internal" href="experiment.html">Experiment</a></li>
<li class="toctree-l1"><a class="reference internal" href="hashing.html">Hashing</a></li>
<li class="toctree-l1"><a class="reference internal" href="manager.html">Manager</a></li>
<li class="toctree-l1"><a class="reference internal" href="params.html">Params</a></li>
<li class="toctree-l1"><a class="reference internal" href="procedure.html">Procedure</a></li>
<li class="toctree-l1"><a class="reference internal" href="project.html">Project</a></li>
<li class="toctree-l1"><a class="reference internal" href="record.html">Record</a></li>
<li class="toctree-l1"><a class="reference internal" href="reporting.html">Reporting</a></li>
<li class="toctree-l1"><a class="reference internal" href="staging.html">Staging</a></li>
<li class="toctree-l1"><a class="reference internal" href="store.html">Store</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Utils</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Curifactory</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Utils</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/utils.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="module-curifactory.utils">
<span id="utils"></span><h1>Utils<a class="headerlink" href="#module-curifactory.utils" title="Permalink to this headline"></a></h1>
<p>Helper and utility functions for the library.</p>
<p><strong>Data:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#curifactory.utils.CONFIGURATION_FILE" title="curifactory.utils.CONFIGURATION_FILE"><code class="xref py py-obj docutils literal notranslate"><span class="pre">CONFIGURATION_FILE</span></code></a></p></td>
<td><p>The expected configuration filename.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#curifactory.utils.EDITORS" title="curifactory.utils.EDITORS"><code class="xref py py-obj docutils literal notranslate"><span class="pre">EDITORS</span></code></a></p></td>
<td><p>The list of possible editor exec names to test for getting a valid text editor.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#curifactory.utils.TIMESTAMP_FORMAT" title="curifactory.utils.TIMESTAMP_FORMAT"><code class="xref py py-obj docutils literal notranslate"><span class="pre">TIMESTAMP_FORMAT</span></code></a></p></td>
<td><p>The datetime format string used for timestamps in experiment run reference names.</p></td>
</tr>
</tbody>
</table>
<p><strong>Classes:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#curifactory.utils.PrefixedLogFactory" title="curifactory.utils.PrefixedLogFactory"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PrefixedLogFactory</span></code></a>(original_factory, prefix)</p></td>
<td><p>Note that we have to use this to prevent weird recursion issues.</p></td>
</tr>
</tbody>
</table>
<p><strong>Functions:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#curifactory.utils.check_git_dirty_workingdir" title="curifactory.utils.check_git_dirty_workingdir"><code class="xref py py-obj docutils literal notranslate"><span class="pre">check_git_dirty_workingdir</span></code></a>()</p></td>
<td><p>Checks if git working directory is dirty or not.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#curifactory.utils.get_command_output" title="curifactory.utils.get_command_output"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_command_output</span></code></a>(cmd[, silent])</p></td>
<td><p>Runs the command passed and returns the full string output of the command (minus the final newline).</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#curifactory.utils.get_conda_env" title="curifactory.utils.get_conda_env"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_conda_env</span></code></a>()</p></td>
<td><p>Returns printed output from running <code class="docutils literal notranslate"><span class="pre">conda</span> <span class="pre">env</span> <span class="pre">export</span> <span class="pre">--from-history</span></code> command.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#curifactory.utils.get_conda_list" title="curifactory.utils.get_conda_list"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_conda_list</span></code></a>()</p></td>
<td><p>Returns printed output from running <code class="docutils literal notranslate"><span class="pre">conda</span> <span class="pre">env</span> <span class="pre">export</span> <span class="pre">--from-history</span></code> command.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#curifactory.utils.get_configuration" title="curifactory.utils.get_configuration"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_configuration</span></code></a>()</p></td>
<td><p>Load the configuration file if available, with defaults for any keys not found.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#curifactory.utils.get_current_commit" title="curifactory.utils.get_current_commit"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_current_commit</span></code></a>()</p></td>
<td><p>Returns printed output from running <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">rev-parse</span> <span class="pre">HEAD</span></code> command.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#curifactory.utils.get_editor" title="curifactory.utils.get_editor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_editor</span></code></a>()</p></td>
<td><p>Returns a text editor to use for richer text entry, such as in providing experiment notes.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#curifactory.utils.get_os" title="curifactory.utils.get_os"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_os</span></code></a>()</p></td>
<td><p>Get the current OS name and version.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#curifactory.utils.get_pip_freeze" title="curifactory.utils.get_pip_freeze"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_pip_freeze</span></code></a>()</p></td>
<td><p>Returns printed output from running <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">freeze</span></code> command.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#curifactory.utils.get_py_opening_comment" title="curifactory.utils.get_py_opening_comment"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_py_opening_comment</span></code></a>(lines)</p></td>
<td><p>Parse the passed lines of a python script file for a top of file docstring.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#curifactory.utils.human_readable_mem_usage" title="curifactory.utils.human_readable_mem_usage"><code class="xref py py-obj docutils literal notranslate"><span class="pre">human_readable_mem_usage</span></code></a>(byte_count)</p></td>
<td><p>Takes the given byte count and returns a nicely formatted string that includes the suffix (K/M/GB).</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#curifactory.utils.human_readable_time" title="curifactory.utils.human_readable_time"><code class="xref py py-obj docutils literal notranslate"><span class="pre">human_readable_time</span></code></a>(seconds)</p></td>
<td><p>Takes the given time in seconds and returns a nicely formatted string that includes the suffix.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#curifactory.utils.init_logging" title="curifactory.utils.init_logging"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_logging</span></code></a>([log_path, level, log_errors, …])</p></td>
<td><p>Sets up logging configuration, including the associated file output.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#curifactory.utils.preview_object" title="curifactory.utils.preview_object"><code class="xref py py-obj docutils literal notranslate"><span class="pre">preview_object</span></code></a>(object)</p></td>
<td><p>Get a small string representation of an object that fits nicely in a single line and includes shape information if relevant.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#curifactory.utils.run_command" title="curifactory.utils.run_command"><code class="xref py py-obj docutils literal notranslate"><span class="pre">run_command</span></code></a>(cmd)</p></td>
<td><p>Prints output from running a command as it occurs.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#curifactory.utils.set_logging_prefix" title="curifactory.utils.set_logging_prefix"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_logging_prefix</span></code></a>(prefix)</p></td>
<td><p>Set the prefix content of the logger, which is incorporated in the log formatter.</p></td>
</tr>
</tbody>
</table>
<dl class="py data">
<dt id="curifactory.utils.CONFIGURATION_FILE">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">CONFIGURATION_FILE</span></code><em class="property"> <span class="pre">=</span> <span class="pre">'curifactory_config.json'</span></em><a class="headerlink" href="#curifactory.utils.CONFIGURATION_FILE" title="Permalink to this definition"></a></dt>
<dd><p>The expected configuration filename.</p>
</dd></dl>
<dl class="py data">
<dt id="curifactory.utils.EDITORS">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">EDITORS</span></code><em class="property"> <span class="pre">=</span> <span class="pre">['vim',</span> <span class="pre">'nvim',</span> <span class="pre">'emacs',</span> <span class="pre">'nano',</span> <span class="pre">'vi']</span></em><a class="headerlink" href="#curifactory.utils.EDITORS" title="Permalink to this definition"></a></dt>
<dd><p>The list of possible editor exec names to test for getting a valid text editor.</p>
</dd></dl>
<dl class="py class">
<dt id="curifactory.utils.PrefixedLogFactory">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">PrefixedLogFactory</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">original_factory</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prefix</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#curifactory.utils.PrefixedLogFactory" title="Permalink to this definition"></a></dt>
<dd><p>Note that we have to use this to prevent weird recursion issues.</p>
<p>My understanding is that since logging is in the global context, after many many tests,
the old_factory keeps getting set to the previous new_factory, and you end up with a massive
function chain. Using this class approach above, we can check if we’ve already set the
factory to an instance of this class, and just update the prefix on it.</p>
<p><a class="reference external" href="https://stackoverflow.com/questions/59585861/using-logrecordfactory-in-python-to-add-custom-fields-for-logging">https://stackoverflow.com/questions/59585861/using-logrecordfactory-in-python-to-add-custom-fields-for-logging</a></p>
</dd></dl>
<dl class="py data">
<dt id="curifactory.utils.TIMESTAMP_FORMAT">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">TIMESTAMP_FORMAT</span></code><em class="property"> <span class="pre">=</span> <span class="pre">'%Y-%m-%d-T%H%M%S'</span></em><a class="headerlink" href="#curifactory.utils.TIMESTAMP_FORMAT" title="Permalink to this definition"></a></dt>
<dd><p>The datetime format string used for timestamps in experiment run reference names.</p>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.check_git_dirty_workingdir">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">check_git_dirty_workingdir</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span> → <span class="pre">bool</span><a class="headerlink" href="#curifactory.utils.check_git_dirty_workingdir" title="Permalink to this definition"></a></dt>
<dd><p>Checks if git working directory is dirty or not. This is used to indicate
potential reproducibility problems in the report and console output.</p>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.get_command_output">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">get_command_output</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cmd</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">list</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">silent</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">bool</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span> → <span class="pre">str</span><a class="headerlink" href="#curifactory.utils.get_command_output" title="Permalink to this definition"></a></dt>
<dd><p>Runs the command passed and returns the full string output of the command
(minus the final newline).</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>cmd</strong> – Either a string command or array of strings, as one would pass to
<code class="docutils literal notranslate"><span class="pre">subprocess.run()</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.get_conda_env">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">get_conda_env</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span> → <span class="pre">str</span><a class="headerlink" href="#curifactory.utils.get_conda_env" title="Permalink to this definition"></a></dt>
<dd><p>Returns printed output from running <code class="docutils literal notranslate"><span class="pre">conda</span> <span class="pre">env</span> <span class="pre">export</span> <span class="pre">--from-history</span></code> command.</p>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.get_conda_list">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">get_conda_list</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span> → <span class="pre">str</span><a class="headerlink" href="#curifactory.utils.get_conda_list" title="Permalink to this definition"></a></dt>
<dd><p>Returns printed output from running <code class="docutils literal notranslate"><span class="pre">conda</span> <span class="pre">env</span> <span class="pre">export</span> <span class="pre">--from-history</span></code> command.</p>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.get_configuration">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">get_configuration</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span> → <span class="pre">dict</span><a class="headerlink" href="#curifactory.utils.get_configuration" title="Permalink to this definition"></a></dt>
<dd><p>Load the configuration file if available, with defaults for any
keys not found. The config file should be “curifactory_config.json”
in the project root.</p>
<p>The defaults are:</p>
<div class="highlight-json notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
<span class="w"> </span><span class="nt">"experiments_module_name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"experiments"</span><span class="p">,</span>
<span class="w"> </span><span class="nt">"params_module_name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"params"</span><span class="p">,</span>
<span class="w"> </span><span class="nt">"manager_cache_path"</span><span class="p">:</span><span class="w"> </span><span class="s2">"data/"</span><span class="p">,</span>
<span class="w"> </span><span class="nt">"cache_path"</span><span class="p">:</span><span class="w"> </span><span class="s2">"data/cache"</span><span class="p">,</span>
<span class="w"> </span><span class="nt">"runs_path"</span><span class="p">:</span><span class="w"> </span><span class="s2">"data/runs"</span><span class="p">,</span>
<span class="w"> </span><span class="nt">"logs_path"</span><span class="p">:</span><span class="w"> </span><span class="s2">"logs/"</span><span class="p">,</span>
<span class="w"> </span><span class="nt">"notebooks_path"</span><span class="p">:</span><span class="w"> </span><span class="s2">"notebooks/"</span><span class="p">,</span>
<span class="w"> </span><span class="nt">"reports_path"</span><span class="p">:</span><span class="w"> </span><span class="s2">"reports/"</span><span class="p">,</span>
<span class="w"> </span><span class="nt">"report_css_path"</span><span class="p">:</span><span class="w"> </span><span class="s2">"reports/style.css"</span><span class="p">,</span>
<span class="p">}</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>the dictionary of configuration keys/values.</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.get_current_commit">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">get_current_commit</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span> → <span class="pre">str</span><a class="headerlink" href="#curifactory.utils.get_current_commit" title="Permalink to this definition"></a></dt>
<dd><p>Returns printed output from running <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">rev-parse</span> <span class="pre">HEAD</span></code> command.</p>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.get_editor">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">get_editor</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span> → <span class="pre">str</span><a class="headerlink" href="#curifactory.utils.get_editor" title="Permalink to this definition"></a></dt>
<dd><p>Returns a text editor to use for richer text entry, such as in providing experiment notes.</p>
<p>e.g. <code class="docutils literal notranslate"><span class="pre">"vim"</span></code></p>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.get_os">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">get_os</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span> → <span class="pre">str</span><a class="headerlink" href="#curifactory.utils.get_os" title="Permalink to this definition"></a></dt>
<dd><p>Get the current OS name and version.</p>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.get_pip_freeze">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">get_pip_freeze</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span> → <span class="pre">str</span><a class="headerlink" href="#curifactory.utils.get_pip_freeze" title="Permalink to this definition"></a></dt>
<dd><p>Returns printed output from running <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">freeze</span></code> command.</p>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.get_py_opening_comment">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">get_py_opening_comment</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">lines</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">list</span></span></em><span class="sig-paren">)</span> → <span class="pre">str</span><a class="headerlink" href="#curifactory.utils.get_py_opening_comment" title="Permalink to this definition"></a></dt>
<dd><p>Parse the passed lines of a python script file for a top of file docstring.
This is used to get parameter and experiment file descriptions, so be sure to
always comment your code!</p>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.human_readable_mem_usage">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">human_readable_mem_usage</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">byte_count</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> → <span class="pre">str</span><a class="headerlink" href="#curifactory.utils.human_readable_mem_usage" title="Permalink to this definition"></a></dt>
<dd><p>Takes the given byte count and returns a nicely formatted string that includes the suffix (K/M/GB).</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>byte_count</strong> (<em>int</em>) – The number of bytes to convert into KB/MB/GB.</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.human_readable_time">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">human_readable_time</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">seconds</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span></em><span class="sig-paren">)</span> → <span class="pre">str</span><a class="headerlink" href="#curifactory.utils.human_readable_time" title="Permalink to this definition"></a></dt>
<dd><p>Takes the given time in seconds and returns a nicely formatted string that includes the suffix.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>seconds</strong> (<em>float</em>) – The time in seconds to convert.</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.init_logging">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">init_logging</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">log_path</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">level</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">20</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">log_errors</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">bool</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_process</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">bool</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">no_color</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">bool</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">quiet</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">bool</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">plain</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">bool</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">disable_non_cf_loggers</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">bool</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#curifactory.utils.init_logging" title="Permalink to this definition"></a></dt>
<dd><p>Sets up logging configuration, including the associated file output.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>log_path</strong> (<em>str</em>) – Folder to store output logs in. If <code class="docutils literal notranslate"><span class="pre">None</span></code>, only log
to console.</p></li>
<li><p><strong>level</strong> – The logging level to output.</p></li>
<li><p><strong>log_errors</strong> (<em>bool</em>) – Whether to include error messages in the log output or not.</p></li>
<li><p><strong>include_process</strong> (<em>bool</em>) – Whether to include the PID prefix value in the logger.
This is mostly only used for when the <code class="docutils literal notranslate"><span class="pre">--parallel</span></code> flag is used, to
help track which log message is from which process.</p></li>
<li><p><strong>no_color</strong> (<em>bool</em>) – Suppress colors in console output.</p></li>
<li><p><strong>quiet</strong> (<em>bool</em>) – Suppress all console log output.</p></li>
<li><p><strong>plain</strong> (<em>bool</em>) – Output plain text log rather than rich output.</p></li>
<li><p><strong>disable_non_cf_loggers</strong> (<em>bool</em>) – Hide loggers from other libraries. This is true
by default because some libraries can generate a lot of noise.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.preview_object">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">preview_object</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">object</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">any</span></span></em><span class="sig-paren">)</span> → <span class="pre">str</span><a class="headerlink" href="#curifactory.utils.preview_object" title="Permalink to this definition"></a></dt>
<dd><p>Get a small string representation of an object that fits nicely
in a single line and includes shape information if relevant.</p>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.run_command">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">run_command</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cmd</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">list</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#curifactory.utils.run_command" title="Permalink to this definition"></a></dt>
<dd><p>Prints output from running a command as it occurs.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>cmd</strong> – Either a string command or array of strings, as one would pass to
<code class="docutils literal notranslate"><span class="pre">subprocess.run()</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="curifactory.utils.set_logging_prefix">
<code class="sig-prename descclassname"><span class="pre">curifactory.utils.</span></code><code class="sig-name descname"><span class="pre">set_logging_prefix</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prefix</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#curifactory.utils.set_logging_prefix" title="Permalink to this definition"></a></dt>
<dd><p>Set the prefix content of the logger, which is incorporated in the log formatter. Currently
this is just used to include pid number when running in parallel.</p>
</dd></dl>
</div>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="store.html" class="btn btn-neutral float-left" title="Store" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>© Copyright 2022, UT Battelle, LLC.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>