Manifest Module¶
This section documents the manifest components of the Nextmv Python SDK.
manifest
¶
Module with the logic for handling an app manifest.
This module provides classes and functions for managing Nextmv app manifests. Manifest files (app.yaml) define how an application is built, run, and deployed on the Nextmv platform.
| CLASS | DESCRIPTION |
|---|---|
ManifestType |
Enum for application types based on programming language. |
ManifestRuntime |
Enum for runtime environments where apps run on Nextmv. |
ManifestPythonArch |
Enum for target architecture for bundling Python apps. |
ManifestBuild |
Class for build-specific attributes in the manifest. |
ManifestPythonModel |
Class for model-specific instructions for Python apps. |
ManifestPython |
Class for Python-specific instructions in the manifest. |
ControlType |
Enum for control types for options in the manifest UI. |
ManifestOptionType |
Enum for option types for options in the manifest. |
ManifestOptionUI |
Class for UI attributes of options in the manifest. |
ManifestOption |
Class representing an option for the decision model in the manifest. |
ManifestOptions |
Class containing a list of options for the decision model. |
ManifestValidation |
Class for validation rules for options in the manifest. |
ManifestContentMultiFileInput |
Class for multi-file content format input configuration. |
ManifestContentMultiFileOutput |
Class for multi-file content format output configuration. |
ManifestContentMultiFile |
Class for multi-file content format configuration. |
ManifestContent |
Class for content configuration specifying how app input/output is handled. |
ManifestConfiguration |
Class for configuration settings for the decision model. |
ManifestExecution |
Class for execution configuration for the decision model. |
ModelConfiguration |
Dataclass for configuration settings for Nextmv models. |
Manifest |
Main class representing an app manifest for Nextmv. |
| FUNCTION | DESCRIPTION |
|---|---|
default_python_manifest |
Creates a default Python manifest as a starting point for applications. |
find_files |
Find all files matching the given filters in the given directory. |
initialize_manifest |
Initialize a manifest file of a given type in a specified directory. |
resolve_manifest |
Resolve a manifest file from a specified path, returning a |
Constants
MANIFEST_FILE_NAME Name of the app manifest file.
ControlType
¶
Bases: str, Enum
Control types for options in the manifest UI.
You can import the ControlType class directly from nextmv:
This enum defines the valid control types for options in the Nextmv Cloud UI.
| ATTRIBUTE | DESCRIPTION |
|---|---|
INPUT |
An input field for string or numeric values.
TYPE:
|
SELECT |
A dropdown select for a fixed set of values.
TYPE:
|
MULTISELECT |
A multi-select dropdown for choosing multiple values from a fixed set.
TYPE:
|
SLIDER |
A slider control for numeric values within a range.
TYPE:
|
TOGGLE |
A toggle switch for boolean values.
TYPE:
|
Examples:
>>> from nextmv import ControlType
>>> ControlType.INPUT
'input'
>>> ControlType.SELECT
'select'
>>> ControlType.MULTISELECT
'multiselect'
>>> ControlType.SLIDER
'slider'
>>> ControlType.TOGGLE
'toggle'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestOptionUIcontrol_type
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestOptionUI
INPUT
class-attribute
instance-attribute
¶
An input field for string or numeric values.
MULTISELECT
class-attribute
instance-attribute
¶
A multi-select dropdown for choosing multiple values from a fixed set.
SELECT
class-attribute
instance-attribute
¶
A dropdown select for a fixed set of values.
SLIDER
class-attribute
instance-attribute
¶
A slider control for numeric values within a range.
MANIFEST_FILE_NAME
module-attribute
¶
Manifest
¶
Bases: BaseModel
Represents an app manifest (app.yaml) for Nextmv Cloud.
You can import the Manifest class directly from nextmv:
An application that runs on the Nextmv Platform must contain a file named
app.yaml which is known as the app manifest. This file is used to specify
the execution environment for the app.
This class represents the app manifest and allows you to load it from a file or create it programmatically.
| PARAMETER | DESCRIPTION |
|---|---|
|
The files to include (or exclude) in the app. This is mandatory.
TYPE:
|
|
The runtime to use for the app, it provides the environment in which the app runs. This is mandatory.
TYPE:
|
|
Type of application, based on the programming language. This is mandatory.
TYPE:
|
|
Build-specific attributes. The
TYPE:
|
|
A command to run before the app is pushed to the Nextmv Cloud.
This command can be used to compile a binary, run tests or similar tasks.
One difference with what is specified under build, is that the command
will be executed via the shell (i.e.,
TYPE:
|
|
Only for Python apps. Contains further Python-specific attributes.
TYPE:
|
|
A list of options for the decision model. An option is a parameter that configures the decision model.
TYPE:
|
|
Optional entrypoint for the decision model. When not specified, the
following default entrypoints are used, according to the
TYPE:
|
Examples:
>>> from nextmv import Manifest, ManifestRuntime, ManifestType
>>> manifest = Manifest(
... files=["main.py", "model_logic/"],
... runtime=ManifestRuntime.PYTHON,
... type=ManifestType.PYTHON,
... )
>>> manifest.files
['main.py', 'model_logic/']
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifest
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestresolve_manifest
build
class-attribute
instance-attribute
¶
build: ManifestBuild | None = None
Build-specific attributes.
The build.command to run to build the app. This command will be executed
without a shell, i.e., directly. The command must exit with a status of 0
to continue the push process of the app to Nextmv Cloud. This command is
executed prior to the pre-push command. The build.environment is used to
set environment variables when running the build command given as key-value
pairs.
configuration
class-attribute
instance-attribute
¶
configuration: ManifestConfiguration | None = None
Configuration for the decision model. A list of options for the decision model. An option is a parameter that configures the decision model.
confirm_mandatory_files
¶
confirm_mandatory_files(present_files: list[str]) -> None
Confirm that all mandatory files are present in the given list of files.
This method checks that all mandatory files for the manifest's type are present in the provided list of files. If a custom execution configuration with an entrypoint is provided, it checks for the presence of the custom entrypoint instead of the default mandatory files.
| PARAMETER | DESCRIPTION |
|---|---|
|
The list of files to check against the mandatory files.
TYPE:
|
Source code in nextmv/nextmv/manifest.py
execution
class-attribute
instance-attribute
¶
execution: ManifestExecution | None = None
Optional execution configuration for the decision model. Allows configuration of entrypoint and more.
extract_options
¶
extract_options(
should_parse: bool = True,
) -> Options | None
Convert the manifest options to a nextmv.Options object.
If the manifest does not have valid options defined in
.configuration.options.items, this method returns None.
Use the should_parse argument to decide if you want the options
parsed, or not. For more information on option parsing, please read the
docstrings on the .parse() method of the nextmv.Options object.
| PARAMETER | DESCRIPTION |
|---|---|
|
Whether to parse the options, or not. By default, options are parsed. When command-line arguments are parsed, the help menu is created, thus parsing Options more than once may result in unexpected behavior.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Optional[Options]
|
The options extracted from the manifest. If no options are found,
|
Examples:
>>> from nextmv import Manifest, ManifestConfiguration, ManifestOptions, ManifestOption
>>> manifest = Manifest(
... files=["main.py"],
... configuration=ManifestConfiguration(
... options=ManifestOptions(
... items=[
... ManifestOption(name="duration", option_type="string", default="10s")
... ]
... )
... )
... )
>>> sdk_options = manifest.extract_options()
>>> sdk_options.get_option("duration").default
'10s'
>>> empty_manifest = Manifest(files=["main.py"])
>>> empty_manifest.extract_options() is None
True
Source code in nextmv/nextmv/manifest.py
files
class-attribute
instance-attribute
¶
The files to include (or exclude) in the app. This is mandatory.
from_model_configuration
classmethod
¶
from_model_configuration(
model_configuration: ModelConfiguration,
) -> Manifest
Create a Python manifest from a nextmv.model.ModelConfiguration.
Note that the ModelConfiguration is almost always used in
conjunction with the nextmv.Model class. If you are not
implementing an instance of nextmv.Model, consider using the
from_options method instead to initialize the manifest with the
options of the model.
The resulting manifest will have:
filesset to["main.py", f"{model_configuration.name}/**"]runtimeset toManifestRuntime.PYTHONtypeset toManifestType.PYTHONpython.pip_requirementsset to the default requirements file name.python.model.nameset tomodel_configuration.name.python.model.optionspopulated frommodel_configuration.options.configuration.optionspopulated frommodel_configuration.options.
| PARAMETER | DESCRIPTION |
|---|---|
|
The model configuration.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Manifest
|
The Python manifest. |
Examples:
>>> from nextmv.model import ModelConfiguration
>>> from nextmv.options import Options, Option
>>> from nextmv import Manifest
>>> opts = Options(Option(name="vehicle_count", option_type=int, default=5))
>>> mc = ModelConfiguration(name="vehicle_router", options=opts)
>>> manifest = Manifest.from_model_configuration(mc)
>>> manifest.python.model.name
'vehicle_router'
>>> manifest.files
['main.py', 'vehicle_router/**']
>>> manifest.configuration.options.items[0].name
'vehicle_count'
Source code in nextmv/nextmv/manifest.py
1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 | |
from_options
classmethod
¶
from_options(
options: Options, validation: OptionsEnforcement = None
) -> Manifest
Create a basic Python manifest from nextmv.options.Options.
If you have more files than just a main.py, make sure you modify
the .files attribute of the resulting manifest. This method assumes
that requirements are specified in a requirements.txt file. You may
also specify a different requirements file once you instantiate the
manifest.
The resulting manifest will have:
- files set to ["main.py"]
- runtime set to ManifestRuntime.PYTHON
- type set to ManifestType.PYTHON
- python.pip_requirements set to "requirements.txt".
- configuration.options populated from the provided options.
| PARAMETER | DESCRIPTION |
|---|---|
|
The options to include in the manifest.
TYPE:
|
|
The validation rules for the options. This is used to set the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Manifest
|
The manifest with the given options. |
Examples:
>>> from nextmv.options import Options, Option
>>> from nextmv import Manifest
>>> opts = Options(
... Option(name="max_runtime", option_type=str, default="60s"),
... Option(name="use_heuristic", option_type=bool, default=True)
... )
>>> manifest = Manifest.from_options(opts)
>>> manifest.files
['main.py']
>>> manifest.python.pip_requirements
'requirements.txt'
>>> len(manifest.configuration.options.items)
2
>>> manifest.configuration.options.items[0].name
'max_runtime'
Source code in nextmv/nextmv/manifest.py
1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 | |
from_yaml
classmethod
¶
Load a manifest from a YAML file.
The YAML file is expected to be named app.yaml and located in the
specified directory.
| PARAMETER | DESCRIPTION |
|---|---|
|
Path to the directory containing the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Manifest
|
The loaded manifest. |
| RAISES | DESCRIPTION |
|---|---|
FileNotFoundError
|
If the |
YAMLError
|
If there is an error parsing the YAML file. |
Examples:
Assuming an app.yaml file exists in ./my_app_dir:
# ./my_app_dir/app.yaml
files:
- main.py
runtime: ghcr.io/nextmv-io/runtime/python:3.11
type: python
>>> from nextmv import Manifest
>>> # manifest = Manifest.from_yaml("./my_app_dir") # This would be run
>>> # assert manifest.type == "python"
>>> # If the `app.yaml` file is in the current directory:
>>> # manifest = Manifest.from_yaml() # This is equivalent to Manifest.from_yaml(".")
Source code in nextmv/nextmv/manifest.py
model_post_init
¶
Post-initialization validation to ensure required fields are properly initialized and to set default values for optional fields.
Source code in nextmv/nextmv/manifest.py
pre_push
class-attribute
instance-attribute
¶
pre_push: str | None = Field(
serialization_alias="pre-push",
validation_alias=AliasChoices("pre-push", "pre_push"),
default=None,
)
A command to run before the app is pushed to the Nextmv Cloud.
This command can be used to compile a binary, run tests or similar tasks.
One difference with what is specified under build, is that the command will
be executed via the shell (i.e., bash -c on Linux & macOS or cmd /c on
Windows). The command must exit with a status of 0 to continue the push
process. This command is executed just before the app gets bundled and
pushed (after the build command).
python
class-attribute
instance-attribute
¶
python: ManifestPython | None = None
Python-specific attributes. Only for Python apps. Contains further Python-specific attributes.
runtime
class-attribute
instance-attribute
¶
runtime: ManifestRuntime = PYTHON
The runtime to use for the app. It provides the environment in which the app runs. This is mandatory.
to_yaml
¶
to_yaml(dirpath: str = '.') -> None
Write the manifest to a YAML file.
The manifest will be written to a file named app.yaml in the
specified directory.
| PARAMETER | DESCRIPTION |
|---|---|
|
Path to the directory where the
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
IOError
|
If there is an error writing the file. |
YAMLError
|
If there is an error serializing the manifest to YAML. |
Examples:
>>> from nextmv import Manifest
>>> manifest = Manifest(files=["solver.py"], type="python")
>>> # manifest.to_yaml("./output_dir") # This would create ./output_dir/app.yaml
>>> # manifest.to_yaml() # This would create ./app.yaml
Source code in nextmv/nextmv/manifest.py
type
class-attribute
instance-attribute
¶
type: ManifestType = PYTHON
Type of application, based on the programming language. This is mandatory.
ManifestBuild
¶
Bases: BaseModel
Build-specific attributes.
You can import the ManifestBuild class directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
The command to run to build the app. This command will be executed without a shell, i.e., directly. The command must exit with a status of 0 to continue the push process of the app to Nextmv Cloud. This command is executed prior to the pre-push command.
TYPE:
|
|
Environment variables to set when running the build command given as key-value pairs.
TYPE:
|
Examples:
>>> from nextmv import ManifestBuild
>>> build_config = ManifestBuild(
... command="make build",
... environment={"DEBUG": "true"}
... )
>>> build_config.command
'make build'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestbuild
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifest
command
class-attribute
instance-attribute
¶
The command to run to build the app.
This command will be executed without a shell, i.e., directly. The command must exit with a status of 0 to continue the push process of the app to Nextmv Cloud. This command is executed prior to the pre-push command.
environment
class-attribute
instance-attribute
¶
Environment variables to set when running the build command.
Given as key-value pairs.
environment_to_dict
¶
Convert the environment variables to a dictionary.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, str]
|
The environment variables as a dictionary of string key-value pairs. Returns an empty dictionary if no environment variables are set. |
Examples:
>>> from nextmv import ManifestBuild
>>> build_config = ManifestBuild(environment={"COUNT": 1, "NAME": "test"})
>>> build_config.environment_to_dict()
{'COUNT': '1', 'NAME': 'test'}
>>> build_config_empty = ManifestBuild()
>>> build_config_empty.environment_to_dict()
{}
Source code in nextmv/nextmv/manifest.py
ManifestConfiguration
¶
Bases: BaseModel
Configuration for the decision model.
You can import the ManifestConfiguration class directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
Options for the decision model.
TYPE:
|
|
Content configuration for specifying how the app input/output is handled.
TYPE:
|
Examples:
>>> from nextmv import ManifestConfiguration, ManifestOptions, ManifestOption
>>> model_config = ManifestConfiguration(
... options=ManifestOptions(
... items=[ManifestOption(name="debug_mode", option_type="bool", default=False)]
... )
... )
>>> model_config.options.items[0].name
'debug_mode'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestconfiguration
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifest
content
class-attribute
instance-attribute
¶
content: ManifestContent | None = None
Content configuration for specifying how the app input/output is handled.
model_post_init
¶
Post-initialization validation to ensure content field is properly initialized.
options
class-attribute
instance-attribute
¶
options: ManifestOptions | None = None
Options for the decision model.
ManifestContent
¶
Bases: BaseModel
Content configuration for specifying how the app input/output is handled.
You can import the ManifestContent class directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
The format of the content. Must be one of "json", "multi-file", or "csv-archive".
TYPE:
|
|
Configuration for multi-file content format.
TYPE:
|
Examples:
>>> from nextmv import ManifestContent
>>> content_config = ManifestContent(
... format="multi-file",
... multi_file=ManifestContentMultiFile(
... input=ManifestContentMultiFileInput(path="data/input/"),
... output=ManifestContentMultiFileOutput(
... metrics="my-outputs/metrics.json",
... assets="my-outputs/assets.json",
... solutions="my-outputs/solutions/"
... )
... )
... )
>>> content_config.format
'multi-file'
>>> content_config.multi_file.input.path
'data/input/'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestConfigurationcontent
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestConfiguration
format
class-attribute
instance-attribute
¶
Warning
InputFormat is deprecated, but kept for backward compatibility. Use ContentFormat instead.
The format of the content. Can only be ContentFormat.JSON or
ContentFormat.MULTI_FILE.
model_post_init
¶
model_post_init(__context) -> None
Post-initialization validation to ensure format field contains valid values.
This method is automatically called by Pydantic after the model is initialized to validate that the format field contains one of the acceptable values.
| PARAMETER | DESCRIPTION |
|---|---|
|
Pydantic context (unused in this implementation).
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the format field contains an invalid value that is not one of the acceptable formats. |
Source code in nextmv/nextmv/manifest.py
multi_file
class-attribute
instance-attribute
¶
multi_file: ManifestContentMultiFile | None = Field(
serialization_alias="multi-file",
validation_alias=AliasChoices(
"multi-file", "multi_file"
),
default=None,
)
Configuration for multi-file content format.
ManifestContentMultiFile
¶
Bases: BaseModel
Configuration for multi-file content format.
You can import the ManifestContentMultiFile class directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
Configuration for multi-file content format input. |
|
Configuration for multi-file content format output. |
Examples:
>>> from nextmv import ManifestContentMultiFile, ManifestContentMultiFileInput, ManifestContentMultiFileOutput
>>> multi_file_config = ManifestContentMultiFile(
... input=ManifestContentMultiFileInput(path="data/input/"),
... output=ManifestContentMultiFileOutput(
... metrics="my-outputs/metrics.json",
... assets="my-outputs/assets.json",
... solutions="my-outputs/solutions/"
... )
... )
>>> multi_file_config.input.path
'data/input/'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestContentmulti_file
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestContent
input
class-attribute
instance-attribute
¶
input: ManifestContentMultiFileInput | None = None
Configuration for multi-file content format input.
model_post_init
¶
Source code in nextmv/nextmv/manifest.py
output
class-attribute
instance-attribute
¶
output: ManifestContentMultiFileOutput | None = None
Configuration for multi-file content format output.
ManifestContentMultiFileInput
¶
Bases: BaseModel
Configuration for multi-file content format input.
You can import the ManifestContentMultiFileInput class directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
The path to the input file or directory.
TYPE:
|
Examples:
>>> from nextmv import ManifestContentMultiFileInput
>>> input_config = ManifestContentMultiFileInput(path="data/input/")
>>> input_config.path
'data/input/'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestContentMultiFileinput
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestContentMultiFile
path
class-attribute
instance-attribute
¶
The path to the input file or directory. The default value is a directory
named inputs/.
ManifestContentMultiFileOutput
¶
Bases: BaseModel
Configuration for multi-file content format output.
You can import the ManifestContentMultiFileOutput class directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
Deprecated: Use
TYPE:
|
|
The path to the metrics file.
TYPE:
|
|
The path to the assets file.
TYPE:
|
|
The path to the solutions directory.
TYPE:
|
Examples:
>>> from nextmv import ManifestContentMultiFileOutput
>>> output_config = ManifestContentMultiFileOutput(
... metrics="my-outputs/metrics.json",
... assets="my-outputs/assets.json",
... solutions="my-outputs/solutions/"
... )
>>> output_config.metrics
'my-outputs/metrics.json'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestContentMultiFileoutput
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestContentMultiFile
assets
class-attribute
instance-attribute
¶
The path to the assets file.
metrics
class-attribute
instance-attribute
¶
The path to the metrics file.
solutions
class-attribute
instance-attribute
¶
The path to the solutions directory.
statistics
class-attribute
instance-attribute
¶
Deprecated: Use metrics instead. The path to the statistics file.
ManifestExecution
¶
Bases: BaseModel
Execution configuration for the decision model.
You can import the ManifestExecution class directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
The entrypoint for the decision model, e.g.:
TYPE:
|
|
The working directory to set when running the app, e.g.:
TYPE:
|
Examples:
>>> from nextmv import ManifestExecution
>>> exec_config = ManifestExecution(
... entrypoint="./app.py",
... cwd="./src/"
... )
>>> exec_config.entrypoint
'./app.py'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestexecution
ManifestOption
¶
Bases: BaseModel
An option for the decision model that is recorded in the manifest.
You can import the ManifestOption class directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
The name of the option.
TYPE:
|
|
The type of the option. This is a string representation of the
TYPE:
|
|
The default value of the option.
TYPE:
|
|
The description of the option.
TYPE:
|
|
Whether the option is required or not.
TYPE:
|
|
Whether the option is only used locally and should not be sent to Nextmv Cloud.
TYPE:
|
|
Optional additional attributes for the option. The Nextmv Cloud may
perform validation on these attributes. For example, the maximum
length of a string or the maximum value of an integer. These
additional attributes will be shown in the help message of the
TYPE:
|
|
Optional UI attributes for the option. This is a dictionary that can
contain additional information about how the option should be displayed
in the Nextmv Cloud UI. This is not used in the local
TYPE:
|
Examples:
>>> from nextmv import ManifestOption
>>> option = ManifestOption(
... name="solve.duration",
... option_type="string",
... default="30s",
... description="Maximum duration for the solver."
... )
>>> option.name
'solve.duration'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifest
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestOptions
additional_attributes
class-attribute
instance-attribute
¶
Optional additional attributes for the option.
default
class-attribute
instance-attribute
¶
The default value of the option
description
class-attribute
instance-attribute
¶
The description of the option
from_option
classmethod
¶
from_option(option: Option) -> ManifestOption
Create a ManifestOption from an Option.
| PARAMETER | DESCRIPTION |
|---|---|
|
The option to convert.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ManifestOption
|
The converted option. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the |
Examples:
>>> from nextmv.options import Option
>>> from nextmv import ManifestOption
>>> sdk_option = Option(name="max_stops", option_type=int, default=100)
>>> manifest_opt = ManifestOption.from_option(sdk_option)
>>> manifest_opt.name
'max_stops'
>>> manifest_opt.option_type
'int'
Source code in nextmv/nextmv/manifest.py
local_only
class-attribute
instance-attribute
¶
Whether the option is only used locally and should not be sent to Nextmv Cloud.
model_post_init
¶
Validations done after parsing the model.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If validation fails. A descriptive error message is provided in this case. |
Source code in nextmv/nextmv/manifest.py
option_type
class-attribute
instance-attribute
¶
option_type: ManifestOptionType = Field(
serialization_alias="option_type",
validation_alias=AliasChoices("type", "option_type"),
)
The type of the option (e.g., "string", "int", "bool", "float).
required
class-attribute
instance-attribute
¶
Whether the option is required or not
to_option
¶
Convert the ManifestOption to an Option.
| RETURNS | DESCRIPTION |
|---|---|
Option
|
The converted option. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the |
Examples:
>>> from nextmv import ManifestOption
>>> manifest_opt = ManifestOption(name="max_stops", option_type="int", default=100)
>>> sdk_option = manifest_opt.to_option()
>>> sdk_option.name
'max_stops'
>>> sdk_option.option_type
<class 'int'>
Source code in nextmv/nextmv/manifest.py
ui
class-attribute
instance-attribute
¶
ui: ManifestOptionUI | None = None
Optional UI attributes for the option.
ManifestOptionType
¶
Bases: str, Enum
Option types for options in the manifest.
You can import the ManifestOptionType class directly from nextmv:
This enum defines the valid option types for options in the manifest.
| ATTRIBUTE | DESCRIPTION |
|---|---|
STRING |
A string option type.
TYPE:
|
BOOL |
A boolean option type.
TYPE:
|
INT |
An integer option type.
TYPE:
|
FLOAT |
A float option type.
TYPE:
|
Examples:
>>> from nextmv import ManifestOptionType
>>> ManifestOptionType.STRING
'string'
>>> ManifestOptionType.BOOL
'bool'
>>> ManifestOptionType.INT
'int'
>>> ManifestOptionType.FLOAT
'float'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestOptionoption_type
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestOption
ManifestOptionUI
¶
Bases: BaseModel
UI attributes for an option in the manifest.
You can import the ManifestOptionUI class directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
The type of control to use for the option in the Nextmv Cloud UI. This
is useful for defining how the option should be presented in the Nextmv
Cloud UI. Current control types include "input", "select",
"multiselect", "slider", and "toggle". This attribute is not used in
the local
TYPE:
|
|
A list of team roles to which this option will be hidden in the UI. For
example, if you want to hide an option from the "operator" role, you can
pass Each roles is validated during API handling to ensure they are one of:
TYPE:
|
|
An optional display name for the option. This is useful for making the option more user-friendly in the UI.
TYPE:
|
Examples:
>>> from nextmv import ManifestOptionUI
>>> ui_config = ManifestOptionUI(control_type=ControlType.INPUT)
>>> ui_config.control_type
<ControlType.INPUT: 'input'>
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestOptionui
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestOption
control_type
class-attribute
instance-attribute
¶
control_type: ControlType | None = None
The type of control to use for the option in the Nextmv Cloud UI.
display_name
class-attribute
instance-attribute
¶
An optional display name for the option. This is useful for making the option more user-friendly in the UI.
hidden_from
class-attribute
instance-attribute
¶
A list of team roles for which this option will be hidden in the UI.
ManifestOptions
¶
Bases: BaseModel
Options for the decision model.
You can import the ManifestOptions class directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
If strict is set to
TYPE:
|
|
The actual list of options for the decision model. An option is a parameter that configures the decision model.
TYPE:
|
|
Optional validation rules for all options.
|
|
A list of strings that define how options are transformed into command
line arguments. Use
TYPE:
|
Examples:
>>> from nextmv import ManifestOptions, ManifestOption
>>> options_config = ManifestOptions(
... strict=True,
... validation=ManifestValidation(enforce="all"),
... items=[
... ManifestOption(name="timeout", option_type="int", default=60),
... ManifestOption(name="vehicle_capacity", option_type="float", default=100.0)
... ]
... )
>>> options_config.strict
True
>>> len(options_config.items)
2
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifest
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestConfiguration
format
class-attribute
instance-attribute
¶
A list of strings that define how options are transformed into command line arguments.
Use {{name}} to refer to the option name and {{value}} to refer to the option value.
For example, ["-{{name}}", "{{value}}"] will transform an option named max_vehicles
with a value of 10 into the command line argument -max_vehicles 10.
from_options
classmethod
¶
from_options(
options: Options,
validation: OptionsEnforcement = None,
format: list[str] | None = None,
) -> ManifestOptions
Create a ManifestOptions from a nextmv.Options.
| PARAMETER | DESCRIPTION |
|---|---|
|
The options to convert.
TYPE:
|
|
Optional validation rules for the options. If provided, it will be
used to set the
TYPE:
|
|
A list of strings that define how options are transformed into
command line arguments. Use For example,
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ManifestOptions
|
The converted options. |
Examples:
>>> from nextmv.options import Options, Option
>>> from nextmv import ManifestOptions
>>> sdk_options = Options(Option("max_vehicles", int, 5))
>>> manifest_options = ManifestOptions.from_options(sdk_options)
>>> manifest_options.items[0].name
'max_vehicles'
Source code in nextmv/nextmv/manifest.py
items
class-attribute
instance-attribute
¶
items: list[ManifestOption] | None = None
The actual list of options for the decision model.
An option is a parameter that configures the decision model.
strict
class-attribute
instance-attribute
¶
If strict is set to True, only the listed options will be allowed.
validation
class-attribute
instance-attribute
¶
validation: ManifestValidation | None = None
Optional validation rules for all options.
ManifestPython
¶
Bases: BaseModel
Python-specific instructions.
You can import the ManifestPython class directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
Path to a requirements.txt file containing (additional) Python
dependencies that will be bundled with the app. Alternatively, you can provide a
list of strings, each representing a package to install, e.g.,
TYPE:
|
|
Information about an encoded decision model as handled via mlflow. This information is used to load the decision model from the app bundle.
TYPE:
|
Examples:
>>> from nextmv import ManifestPython, ManifestPythonModel
>>> python_config = ManifestPython(
... pip_requirements="requirements.txt",
... model=ManifestPythonModel(name="my_model")
... )
>>> python_config.pip_requirements
'requirements.txt'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestpython
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifest
arch
class-attribute
instance-attribute
¶
arch: ManifestPythonArch | None = None
The architecture this model is meant to run on. One of "arm64" or "amd64". Uses "arm64" if not specified.
model
class-attribute
instance-attribute
¶
model: ManifestPythonModel | None = None
Information about an encoded decision model.
As handled via mlflow. This information is used to load the decision model from the app bundle.
model_post_init
¶
Convert version from float to string for convenience.
Source code in nextmv/nextmv/manifest.py
pip_requirements
class-attribute
instance-attribute
¶
pip_requirements: str | list[str] | None = Field(
serialization_alias="pip-requirements",
validation_alias=AliasChoices(
"pip-requirements", "pip_requirements"
),
default=None,
)
Path to a requirements.txt file or list of packages.
Contains (additional) Python dependencies that will be bundled with the app. Can be either a string path to a requirements.txt file or a list of package specifications.
version
class-attribute
instance-attribute
¶
The Python version this model is meant to run with. Uses "3.11" if not specified.
ManifestPythonArch
¶
Bases: str, Enum
Target architecture for bundling Python apps.
You can import the ManifestPythonArch class directly from nextmv:
| ATTRIBUTE | DESCRIPTION |
|---|---|
ARM64 |
ARM 64-bit architecture.
TYPE:
|
AMD64 |
AMD 64-bit architecture.
TYPE:
|
Examples:
>>> from nextmv import ManifestPythonArch
>>> arch = ManifestPythonArch.ARM64
>>> arch
<ManifestPythonArch.ARM64: 'arm64'>
>>> str(arch)
'arm64'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestPythonarch
ManifestPythonModel
¶
Bases: BaseModel
Model-specific instructions for a Python app.
You can import the ManifestPythonModel class directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
The name of the decision model.
TYPE:
|
|
Options for the decision model. This is a data representation of the
TYPE:
|
Examples:
>>> from nextmv import ManifestPythonModel
>>> python_model_config = ManifestPythonModel(
... name="routing_model",
... options=[{"name": "max_vehicles", "type": "int", "default": 10}]
... )
>>> python_model_config.name
'routing_model'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestPythonmodel
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestPython
options
class-attribute
instance-attribute
¶
Options for the decision model. This is a data representation of the
nextmv.Options class. It consists of a list of dicts. Each dict
represents the nextmv.Option class. It is used to be able to
reconstruct an Options object from data when loading a decision model.
ManifestRuntime
¶
Bases: str, Enum
Runtime (environment) where the app will be run on Nextmv Cloud.
You can import the ManifestRuntime class directly from nextmv:
This enum defines the supported runtime environments for applications that can be deployed on Nextmv Cloud.
| ATTRIBUTE | DESCRIPTION |
|---|---|
DEFAULT |
This runtime is used to run compiled applications such as Go binaries.
TYPE:
|
PYTHON |
This runtime is used as the basis for all other Python runtimes and Python applications.
TYPE:
|
JAVA |
This runtime is used to run Java applications.
TYPE:
|
PYOMO |
This runtime provisions Python packages to run Pyomo applications.
TYPE:
|
HEXALY |
This runtime provisions Python packages to run Hexaly applications.
TYPE:
|
Examples:
>>> from nextmv import ManifestRuntime
>>> runtime = ManifestRuntime.PYTHON
>>> runtime
<ManifestRuntime.PYTHON: 'ghcr.io/nextmv-io/runtime/python:3.11'>
>>> str(runtime)
'ghcr.io/nextmv-io/runtime/python:3.11'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestruntime
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifest
CUOPT
class-attribute
instance-attribute
¶
A runtime providing the NVIDIA cuOpt solver.
DEFAULT
class-attribute
instance-attribute
¶
A runtime used to run compiled applications such as Go binaries.
GAMSPY
class-attribute
instance-attribute
¶
A runtime provisioning the GAMS Python API and supported solvers.
JAVA
class-attribute
instance-attribute
¶
A runtime used to run Java applications.
PYOMO
class-attribute
instance-attribute
¶
A runtime provisioning Python packages to run Pyomo applications.
PYTHON
class-attribute
instance-attribute
¶
A runtime used to run standard Python applications.
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestruntime
ManifestType
¶
Bases: str, Enum
Type of application in the manifest, based on the programming language.
You can import the ManifestType class directly from nextmv:
This enum defines the supported programming languages for applications that can be deployed on Nextmv Cloud.
| ATTRIBUTE | DESCRIPTION |
|---|---|
PYTHON |
Python format, used for Python applications.
TYPE:
|
GO |
Go format, used for Go applications.
TYPE:
|
JAVA |
Java format, used for Java applications.
TYPE:
|
Examples:
>>> from nextmv import ManifestType
>>> manifest_type = ManifestType.PYTHON
>>> manifest_type
<ManifestType.PYTHON: 'python'>
>>> str(manifest_type)
'python'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifesttype
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifest
PYTHON
class-attribute
instance-attribute
¶
Python format
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifesttype
ManifestValidation
¶
Bases: BaseModel
Validation rules for options in the manifest.
You can import the ManifestValidation class directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
The enforcement level for the validation rules. This can be set to "none" or "all". If set to "none", no validation will be performed on the options prior to creating a run. If set to "all", all validation rules will be enforced on the options, and runs will not be created if any of the rules of the options are violated.
TYPE:
|
Examples:
>>> from nextmv import ManifestValidation
>>> validation = ManifestValidation(enforce="all")
>>> validation.enforce
'all'
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestOptionsvalidation
enforce
class-attribute
instance-attribute
¶
The enforcement level for the validation rules. This can be set to "none" or "all". If set to "none", no validation will be performed on the options prior to creating a run. If set to "all", all validation rules will be enforced on the options, and runs will not be created if any of the rules of the options are violated.
model_post_init
¶
Validate that enforce is one of the accepted values.
Source code in nextmv/nextmv/manifest.py
ModelConfiguration
dataclass
¶
ModelConfiguration(
name: str,
requirements: list[str] | None = None,
options: Options | None = None,
options_enforcement: OptionsEnforcement | None = None,
)
Configuration class for Nextmv models.
You can import the ModelConfiguration class directly from nextmv:
This class holds the configuration for a model, defining how a Python model is encoded and loaded for use in Nextmv Cloud.
| PARAMETER | DESCRIPTION |
|---|---|
|
A personalized name for the model. This is required.
TYPE:
|
|
A list of Python dependencies that the decision model requires, formatted as they would appear in a requirements.txt file.
TYPE:
|
|
Options that the decision model requires.
TYPE:
|
|
Enforcement of options for the model. This controls how options are handled when the model is run.
TYPE:
|
Examples:
>>> from nextmv import ModelConfiguration, Options
>>> config = ModelConfiguration(
... name="my_routing_model",
... requirements=["nextroute>=1.0.0"],
... options=Options({"max_time": 60}),
... options_enforcement=OptionsEnforcement(
strict=True,
validation_enforce=True
)
... )
-
nextmv
✏️ Modeling
Reference
Manifest Module
manifestManifestfrom_model_configuration
default_python_manifest
¶
default_python_manifest() -> Manifest
Creates a default Python manifest as a starting point for applications being executed on the Nextmv Platform.
You can import the default_python_manifest function directly from nextmv:
| RETURNS | DESCRIPTION |
|---|---|
Manifest
|
A default Python manifest with common settings. |
Source code in nextmv/nextmv/manifest.py
find_files
¶
Find all files matching the given filters in the given directory.
This function supports glob patterns with recursive matching, negation patterns (starting with '!'), and directory patterns (ending with '/'). It temporarily changes to the app directory to perform globbing, then returns to the original directory.
You can import the find_files function directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
The root directory to search for files.
TYPE:
|
|
List of glob patterns to match files. Patterns starting with '!' are treated as exclusions. Patterns ending with '/' are treated as directory wildcards (equivalent to '/*').
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[list[str], list[str], list[dict[str, str]]]
|
A tuple containing three elements: - found: List of found file paths (relative to app_dir) - missing: List of patterns that didn't match any files (excluding negation patterns) - files: List of dicts with 'interior_path' (relative path) and 'absolute_path' keys |
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If there is an error changing to the app directory. |
Examples:
>>> # Find Python files
>>> found, missing, files = find_files("/path/to/app", ["*.py", "src/"])
>>> # Exclude cache files
>>> found, missing, files = find_files("/path/to/app", ["*.py", "!__pycache__/*"])
Notes
- Only files are returned; directories are automatically excluded
- Negation patterns don't cause an error if they don't match anything
- The function changes the current working directory temporarily during execution
Source code in nextmv/nextmv/manifest.py
1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 | |
initialize_manifest
¶
initialize_manifest(
manifest_type: ManifestType,
content_format: ContentFormat,
dirpath: str | None = ".",
with_options: bool = True,
) -> str
Writes a sample manifest file, based on the given type and content format, to the given directory path.
The sample manifest files are located in the templates directory of the
package. The file that corresponds to the given type and content format is
copied to the specified directory path with the name app.yaml. If no
dirpath is provided, the file is written to the current directory.
You can import the initialize_manifest function directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
The type of manifest to write. This determines which sample manifest file is copied.
TYPE:
|
|
The content format to write in the manifest. This determines which sample manifest file is copied.
TYPE:
|
|
The directory path where the sample manifest file will be written. If not provided, it defaults to the current directory.
TYPE:
|
|
Whether to include options in the initialized manifest. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The path to the initialized manifest file. |
Source code in nextmv/nextmv/manifest.py
read_pyproject_dependencies
¶
read_pyproject_dependencies(path: str) -> list[str]
Read [project].dependencies from a pyproject.toml file using the
PEP 621 [project] table.
| PARAMETER | DESCRIPTION |
|---|---|
|
Absolute or relative path to the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
The list of dependency specifiers found under |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in nextmv/nextmv/manifest.py
resolve_manifest
¶
Resolve the manifest to use for loading the input data.
If a manifest is provided directly, it is returned as-is. Otherwise, the
method looks for an app.yaml file in the current working directory and
loads it as a manifest if it exists.
| PARAMETER | DESCRIPTION |
|---|---|
|
The manifest to use. If provided, it is returned unchanged.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Manifest or None
|
The resolved manifest, or |