nextmv 0.26.1__tar.gz → 0.26.2__tar.gz
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.
- {nextmv-0.26.1 → nextmv-0.26.2}/PKG-INFO +1 -1
- nextmv-0.26.2/nextmv/__about__.py +1 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/output.py +21 -2
- nextmv-0.26.2/tests/cloud/test_run.py +18 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/test_output.py +21 -0
- nextmv-0.26.1/nextmv/__about__.py +0 -1
- {nextmv-0.26.1 → nextmv-0.26.2}/.gitignore +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/LICENSE +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/README.md +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/__entrypoint__.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/__init__.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/base_model.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/__init__.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/acceptance_test.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/account.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/application.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/batch_experiment.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/client.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/input_set.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/instance.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/manifest.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/package.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/run.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/safe.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/scenario.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/secrets.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/status.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/cloud/version.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/deprecated.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/input.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/logger.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/model.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/nextmv/options.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/pyproject.toml +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/requirements.txt +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/__init__.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/cloud/__init__.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/cloud/app.yaml +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/cloud/test_application.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/cloud/test_client.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/cloud/test_manifest.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/cloud/test_package.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/cloud/test_safe_name_id.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/cloud/test_scenario.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/scripts/__init__.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/scripts/options1.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/scripts/options2.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/scripts/options3.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/scripts/options4.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/scripts/options5.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/scripts/options6.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/scripts/options7.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/scripts/options_deprecated.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/test_base_model.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/test_entrypoint/__init__.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/test_entrypoint/test_entrypoint.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/test_input.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/test_logger.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/test_model.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/test_options.py +0 -0
- {nextmv-0.26.1 → nextmv-0.26.2}/tests/test_version.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "v0.26.2"
|
|
@@ -292,6 +292,10 @@ class Output:
|
|
|
292
292
|
"""Optional configuration for writing CSV files, to be used when the
|
|
293
293
|
`output_format` is OutputFormat.CSV_ARCHIVE. These configurations are
|
|
294
294
|
passed as kwargs to the `DictWriter` class from the `csv` module."""
|
|
295
|
+
json_configurations: Optional[dict[str, Any]] = None
|
|
296
|
+
"""Optional configuration for writing JSON files, to be used when the
|
|
297
|
+
`output_format` is OutputFormat.JSON. These configurations are passed as
|
|
298
|
+
kwargs to the `json.dumps` function."""
|
|
295
299
|
assets: Optional[list[Asset]] = None
|
|
296
300
|
"""Optional list of assets to be included in the output."""
|
|
297
301
|
|
|
@@ -342,6 +346,8 @@ class Output:
|
|
|
342
346
|
|
|
343
347
|
if self.output_format == OutputFormat.CSV_ARCHIVE:
|
|
344
348
|
output_dict["csv_configurations"] = self.csv_configurations
|
|
349
|
+
elif self.output_format == OutputFormat.JSON:
|
|
350
|
+
output_dict["json_configurations"] = self.json_configurations
|
|
345
351
|
|
|
346
352
|
return output_dict
|
|
347
353
|
|
|
@@ -383,10 +389,23 @@ class LocalOutputWriter(OutputWriter):
|
|
|
383
389
|
"assets": assets,
|
|
384
390
|
}
|
|
385
391
|
|
|
392
|
+
json_configurations = {}
|
|
393
|
+
if hasattr(output, "json_configurations") and output.json_configurations is not None:
|
|
394
|
+
json_configurations = output.json_configurations
|
|
395
|
+
|
|
396
|
+
indent, custom_serial = 2, _custom_serial
|
|
397
|
+
if "indent" in json_configurations:
|
|
398
|
+
indent = json_configurations["indent"]
|
|
399
|
+
del json_configurations["indent"]
|
|
400
|
+
if "default" in json_configurations:
|
|
401
|
+
custom_serial = json_configurations["default"]
|
|
402
|
+
del json_configurations["default"]
|
|
403
|
+
|
|
386
404
|
serialized = json.dumps(
|
|
387
405
|
final_output,
|
|
388
|
-
indent=
|
|
389
|
-
default=
|
|
406
|
+
indent=indent,
|
|
407
|
+
default=custom_serial,
|
|
408
|
+
**json_configurations,
|
|
390
409
|
)
|
|
391
410
|
|
|
392
411
|
if path is None or path == "":
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
import time
|
|
3
|
+
import unittest
|
|
4
|
+
|
|
5
|
+
from nextmv.cloud.run import run_duration
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TestRunDuration(unittest.TestCase):
|
|
9
|
+
def test_run_duration_convenience_func(self):
|
|
10
|
+
before_t, before_dt = time.time(), datetime.datetime.now()
|
|
11
|
+
diff = 0.25
|
|
12
|
+
after_t, after_dt = before_t + diff, before_dt + datetime.timedelta(seconds=diff)
|
|
13
|
+
duration_t = run_duration(before_t, after_t)
|
|
14
|
+
duration_dt = run_duration(before_dt, after_dt)
|
|
15
|
+
self.assertAlmostEqual(duration_t, 250.0, delta=1.0)
|
|
16
|
+
self.assertAlmostEqual(duration_dt, 250.0, delta=1.0)
|
|
17
|
+
self.assertIsInstance(duration_t, int)
|
|
18
|
+
self.assertIsInstance(duration_dt, int)
|
|
@@ -73,6 +73,27 @@ class TestOutput(unittest.TestCase):
|
|
|
73
73
|
|
|
74
74
|
self.assertDictEqual(got, expected)
|
|
75
75
|
|
|
76
|
+
def test_local_writer_json_stdout_with_configurations(self):
|
|
77
|
+
output = nextmv.Output(
|
|
78
|
+
output_format=nextmv.OutputFormat.JSON,
|
|
79
|
+
solution={"empanadas": "are_life"},
|
|
80
|
+
statistics={"foo": "bar"},
|
|
81
|
+
json_configurations={
|
|
82
|
+
"indent": None,
|
|
83
|
+
"separators": (",", ":"),
|
|
84
|
+
"sort_keys": True,
|
|
85
|
+
},
|
|
86
|
+
)
|
|
87
|
+
output_writer = nextmv.LocalOutputWriter()
|
|
88
|
+
|
|
89
|
+
with patch("sys.stdout", new=StringIO()) as mock_stdout:
|
|
90
|
+
output_writer.write(output, skip_stdout_reset=True)
|
|
91
|
+
|
|
92
|
+
self.assertEqual(
|
|
93
|
+
mock_stdout.getvalue(),
|
|
94
|
+
'{"assets":[],"options":{},"solution":{"empanadas":"are_life"},"statistics":{"foo":"bar"}}\n',
|
|
95
|
+
)
|
|
96
|
+
|
|
76
97
|
def test_local_writer_json_stdout_with_options(self):
|
|
77
98
|
options = nextmv.Options()
|
|
78
99
|
options.duration = 5
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "v0.26.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|