nextmv 0.23.0__py3-none-any.whl → 0.24.0__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.
nextmv/output.py CHANGED
@@ -13,6 +13,7 @@ from typing import Any, Optional, Union
13
13
  from pydantic import AliasChoices, Field
14
14
 
15
15
  from nextmv.base_model import BaseModel
16
+ from nextmv.deprecated import deprecated
16
17
  from nextmv.logger import reset_stdout
17
18
  from nextmv.options import Options
18
19
 
@@ -162,9 +163,9 @@ class Statistics(BaseModel):
162
163
  class OutputFormat(str, Enum):
163
164
  """Format of an `Input`."""
164
165
 
165
- JSON = "JSON"
166
+ JSON = "json"
166
167
  """JSON format, utf-8 encoded."""
167
- CSV_ARCHIVE = "CSV_ARCHIVE"
168
+ CSV_ARCHIVE = "csv-archive"
168
169
  """CSV archive format: multiple CSV files."""
169
170
 
170
171
 
@@ -333,11 +334,10 @@ class Output:
333
334
  """
334
335
 
335
336
  output_dict = {
336
- "options": self.options.to_dict() if self.options is not None else None,
337
- "output_format": self.output_format,
338
- "solution": self.solution,
339
- "statistics": self.statistics.to_dict() if self.statistics is not None else None,
340
- "assets": [asset.to_dict() for asset in self.assets] if self.assets is not None else None,
337
+ "options": self.options.to_dict() if self.options is not None else {},
338
+ "solution": self.solution if self.solution is not None else {},
339
+ "statistics": self.statistics.to_dict() if self.statistics is not None else {},
340
+ "assets": [asset.to_dict() for asset in self.assets] if self.assets is not None else [],
341
341
  }
342
342
 
343
343
  if self.output_format == OutputFormat.CSV_ARCHIVE:
@@ -589,6 +589,10 @@ def write_local(
589
589
  skip_stdout_reset: bool = False,
590
590
  ) -> None:
591
591
  """
592
+ DEPRECATION WARNING
593
+ ----------
594
+ `write_local` is deprecated, use `write` instead.
595
+
592
596
  This is a convenience function for instantiating a `LocalOutputWriter` and
593
597
  calling its `write` method.
594
598
 
@@ -623,10 +627,63 @@ def write_local(
623
627
  If the `Output.output_format` is not supported.
624
628
  """
625
629
 
630
+ deprecated(
631
+ name="write_local",
632
+ reason="`write_local` is deprecated, use `write` instead.",
633
+ )
634
+
626
635
  writer = LocalOutputWriter()
627
636
  writer.write(output, path, skip_stdout_reset)
628
637
 
629
638
 
639
+ _LOCAL_OUTPUT_WRITER = LocalOutputWriter()
640
+
641
+
642
+ def write(
643
+ output: Union[Output, dict[str, Any]],
644
+ path: Optional[str] = None,
645
+ skip_stdout_reset: bool = False,
646
+ writer: Optional[OutputWriter] = _LOCAL_OUTPUT_WRITER,
647
+ ) -> None:
648
+ """
649
+ This is a convenience function for writing an `Output`, i.e.: write the
650
+ output to the specified destination. The `writer` is used to call the
651
+ `.write` method. Note that the default writes is the `LocalOutputWriter`.
652
+
653
+ Consider the following for the `path` parameter, depending on the
654
+ `Output.output_format`:
655
+
656
+ - `OutputFormat.JSON`: the `path` is the file where the JSON data will
657
+ be written. If empty or `None`, the data will be written to stdout.
658
+ - `OutputFormat.CSV_ARCHIVE`: the `path` is the directory where the CSV
659
+ files will be written. If empty or `None`, the data will be written
660
+ to a directory named `output` under the current working directory.
661
+ The `Output.options` and `Output.statistics` will be written to
662
+ stdout.
663
+
664
+ This function detects if stdout was redirected and resets it to avoid
665
+ unexpected behavior. If you want to skip this behavior, set the
666
+ `skip_stdout_reset` parameter to `True`.
667
+
668
+ Parameters
669
+ ----------
670
+ output : Output, dict[str, Any]
671
+ Output data to write.
672
+ path : str
673
+ Path to write the output data to.
674
+ skip_stdout_reset : bool, optional
675
+ Skip resetting stdout before writing the output data. Default is
676
+ `False`.
677
+
678
+ Raises
679
+ ------
680
+ ValueError
681
+ If the `Output.output_format` is not supported.
682
+ """
683
+
684
+ writer.write(output, path, skip_stdout_reset)
685
+
686
+
630
687
  def _custom_serial(obj: Any):
631
688
  """JSON serializer for objects not serializable by default one."""
632
689
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nextmv
3
- Version: 0.23.0
3
+ Version: 0.24.0
4
4
  Summary: The all-purpose Python SDK for Nextmv
5
5
  Project-URL: Homepage, https://www.nextmv.io
6
6
  Project-URL: Documentation, https://www.nextmv.io/docs/python-sdks/nextmv/installation
@@ -0,0 +1,30 @@
1
+ nextmv/__about__.py,sha256=fD27wZZANNFf0FJ1iOoxuLS18yRdvKwwSYfjMUoav6A,24
2
+ nextmv/__entrypoint__.py,sha256=5K058PICm5sx4sNMqx56auMh9yWgdIESVLzfvyIXdjs,1158
3
+ nextmv/__init__.py,sha256=QN5e_BFkIdBkR8DiGr9T06N6mXtowT84eRUJj3_Vfrg,1459
4
+ nextmv/base_model.py,sha256=mdaBe-epNK1cFgP4TxbOtn3So4pCi1vMTOrIBkCBp7A,1050
5
+ nextmv/deprecated.py,sha256=ctE39pmJEfoicR-w0EdT7FPtd0cWmP3GKth-FsNn_Ks,406
6
+ nextmv/input.py,sha256=tppXHiJM_EzR9Z1yJPc37joBvgC0RmiAFo0Ab1X5nPA,15480
7
+ nextmv/logger.py,sha256=5qQ7E3Aaw3zzkIeiUuwYGzTcB7VhVqIzNZm5PHmdpUI,852
8
+ nextmv/model.py,sha256=rwBdgmKSEp1DPv43zF0azj3QnbHO6O6wKs0PIGvVS40,9861
9
+ nextmv/options.py,sha256=IPqAIUjoKMWmoPx_e5zDcnxu7S2HVxw-SLjjUduVvZM,25302
10
+ nextmv/output.py,sha256=xag6SoNkd3oyKBgQCbvx6jsYLu4pzHPuLEAEtbCDolI,21984
11
+ nextmv/cloud/__init__.py,sha256=O34rjrgClnIwXDE63PK4iq5ESuGQ86dJ6FPSrcUnmk0,3680
12
+ nextmv/cloud/acceptance_test.py,sha256=NtqGhj-UYibxGBbU2kfjr-lYcngojb_5VMvK2WZwibI,6620
13
+ nextmv/cloud/account.py,sha256=mZUGzV-uMGBA5BC_FPtsiCMFuz5jxEZ3O1BbELZIm18,1841
14
+ nextmv/cloud/application.py,sha256=tx_VgtW34cpYdOCdvWh6J5z6KpEEeU22nPdYvtRyuKI,79346
15
+ nextmv/cloud/batch_experiment.py,sha256=xuItiW0hhaDt78BWSz7bcw8cbI8joCkw5KH2Gj5JRbQ,3734
16
+ nextmv/cloud/client.py,sha256=JUE3vD767_FFICl1vov5Mxmircci03TBL3KmT1BOZY4,9096
17
+ nextmv/cloud/input_set.py,sha256=HTLA2acJridZbBCAVJNom8ldNo2Rfy40YQ8Coyz3bdo,1482
18
+ nextmv/cloud/instance.py,sha256=UfyfZXfL1ugCGAB6zwZJIAi8qxI1JCUGsluwaGdjfN4,1223
19
+ nextmv/cloud/manifest.py,sha256=lB3rwFmIKNAncaA00DelT4tDkMkIUCWEY4QJKJsx_-U,12116
20
+ nextmv/cloud/package.py,sha256=Y3RethLiXXW7Y6_QBJDJdd7mFNaYaSBMyasIeGLav8o,12287
21
+ nextmv/cloud/run.py,sha256=yeuaY8rAxTAhhKY0zTGQA3sKUkSiJg487QZIxPppm40,9604
22
+ nextmv/cloud/safe.py,sha256=IUQUOlx4ulIIyP2-Fx3-gNBm9nyWOgZgaOAlRrzqaZE,2515
23
+ nextmv/cloud/scenario.py,sha256=9gbdnQuvmerPUBCcJ-5QbLCwgbsIfBwKXE8c5359S8E,8120
24
+ nextmv/cloud/secrets.py,sha256=kqlN4ceww_L4kVTrAU8BZykRzXINO3zhMT_BLYea6tk,1764
25
+ nextmv/cloud/status.py,sha256=C-ax8cLw0jPeh7CPsJkCa0s4ImRyFI4NDJJxI0_1sr4,602
26
+ nextmv/cloud/version.py,sha256=sjVRNRtohHA97j6IuyM33_DSSsXYkZPusYgpb6hlcrc,1244
27
+ nextmv-0.24.0.dist-info/METADATA,sha256=i51XfzKArsSXtHLUce4KczcnWp5h5Uqq7_Iezk4Xsug,14557
28
+ nextmv-0.24.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
29
+ nextmv-0.24.0.dist-info/licenses/LICENSE,sha256=ZIbK-sSWA-OZprjNbmJAglYRtl5_K4l9UwAV3PGJAPc,11349
30
+ nextmv-0.24.0.dist-info/RECORD,,
@@ -1,27 +0,0 @@
1
- nextmv/__about__.py,sha256=SaoMA-zT-KKas7BJjyDi5vRFQ0KVW0fwwmJqCzguwBY,24
2
- nextmv/__entrypoint__.py,sha256=o6xYGBBUgCY_htteW-qNJfp-S3Th8dzS4RreJcDCnzM,1333
3
- nextmv/__init__.py,sha256=rz9oP7JGyFQJdUtYX4j9xx4Gv4LMGfNvXoEID5qUqig,1354
4
- nextmv/base_model.py,sha256=mdaBe-epNK1cFgP4TxbOtn3So4pCi1vMTOrIBkCBp7A,1050
5
- nextmv/input.py,sha256=tYjiD9KM37Phqzm4faO4QLem8IXnU6HS160c1E-Yhc8,12732
6
- nextmv/logger.py,sha256=5qQ7E3Aaw3zzkIeiUuwYGzTcB7VhVqIzNZm5PHmdpUI,852
7
- nextmv/model.py,sha256=rwBdgmKSEp1DPv43zF0azj3QnbHO6O6wKs0PIGvVS40,9861
8
- nextmv/options.py,sha256=uLMGNt8MoBmtrcZSuinDZ7z8yq58bzHKohBRqC80r_s,18225
9
- nextmv/output.py,sha256=cxw7Z0dTj5u42w2MQLOz2gesj046tvYFSWmhSZtRSXU,20082
10
- nextmv/cloud/__init__.py,sha256=IjvO3xYvrU7nw2VDpvb2UCXV80kRYMSx9IRT6IUu68w,3349
11
- nextmv/cloud/acceptance_test.py,sha256=NtqGhj-UYibxGBbU2kfjr-lYcngojb_5VMvK2WZwibI,6620
12
- nextmv/cloud/account.py,sha256=mZUGzV-uMGBA5BC_FPtsiCMFuz5jxEZ3O1BbELZIm18,1841
13
- nextmv/cloud/application.py,sha256=XZvR0e2sx3HPLp6nhZEbwx7xytDSFRgDoyFDkIrGSWs,62362
14
- nextmv/cloud/batch_experiment.py,sha256=UxrMNAm2c7-RZ9TWRhZBtiVyEeUG1pjsLNhYkoT5Jog,2236
15
- nextmv/cloud/client.py,sha256=E4C8wOGOdgyMf-DCDt4YfI7ib8HwmUhAtKMdrSBJc2M,9004
16
- nextmv/cloud/input_set.py,sha256=ovkP17-jYs0yWrbqTM6Nl5ubWQabD_UrDqAHNo8aE2s,672
17
- nextmv/cloud/instance.py,sha256=UfyfZXfL1ugCGAB6zwZJIAi8qxI1JCUGsluwaGdjfN4,1223
18
- nextmv/cloud/manifest.py,sha256=Fdjw4c14_ph20ASOzBs2mLslyLs1jGSxWThipGFp8rk,7458
19
- nextmv/cloud/package.py,sha256=Y3RethLiXXW7Y6_QBJDJdd7mFNaYaSBMyasIeGLav8o,12287
20
- nextmv/cloud/run.py,sha256=NHuEz9qBhXKFRygSNeSXVvX4vPSsmM-KfJjh6W473XI,9567
21
- nextmv/cloud/secrets.py,sha256=kqlN4ceww_L4kVTrAU8BZykRzXINO3zhMT_BLYea6tk,1764
22
- nextmv/cloud/status.py,sha256=C-ax8cLw0jPeh7CPsJkCa0s4ImRyFI4NDJJxI0_1sr4,602
23
- nextmv/cloud/version.py,sha256=sjVRNRtohHA97j6IuyM33_DSSsXYkZPusYgpb6hlcrc,1244
24
- nextmv-0.23.0.dist-info/METADATA,sha256=R5bHWU5ED-4CqVuOOWEWn5SByiMpiUS1AJpaoYXpRr0,14557
25
- nextmv-0.23.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
- nextmv-0.23.0.dist-info/licenses/LICENSE,sha256=ZIbK-sSWA-OZprjNbmJAglYRtl5_K4l9UwAV3PGJAPc,11349
27
- nextmv-0.23.0.dist-info/RECORD,,