Registry module¶
Reference to the local.registry.py module.
registry
¶
Local app registry for app interactions.
This module provides functionality for interacting with the local registry of Nextmv applications. The registry allows users to manage applications they have created locally on their machine.
| CLASS | DESCRIPTION |
|---|---|
AppEntry |
Represents an entry in the local app registry. |
Registry |
Represents the local app registry and provides methods for managing registry entries. |
AppEntry
¶
Bases: BaseModel
Represents an entry in the local app registry.
You can import the AppEntry class directly from local:
This class contains information about a Nextmv application on the local machine.
| ATTRIBUTE | DESCRIPTION |
|---|---|
app_id |
The unique identifier of the application.
TYPE:
|
src |
The file system path where the application is located.
TYPE:
|
content_format |
The content format of the application, which is determined by the manifest.
TYPE:
|
created_at |
The timestamp when the application was registered in the local registry.
TYPE:
|
updated_at |
The timestamp when the application entry was last updated in the local registry.
TYPE:
|
description |
An optional description of the application.
TYPE:
|
content_format
instance-attribute
¶
The content format of the application, which is determined by the manifest.
created_at
instance-attribute
¶
created_at: datetime
The timestamp when the application was registered in the local registry.
Registry
¶
Bases: BaseModel
Represents the local app registry.
You can import the Registry class directly from local:
This class contains a list of local Nextmv applications registered on the machine.
| ATTRIBUTE | DESCRIPTION |
|---|---|
apps |
A list of locally registered Nextmv applications. |
apps
class-attribute
instance-attribute
¶
A list of locally registered Nextmv applications.
from_yaml
classmethod
¶
from_yaml() -> Registry
Load a Registry from a YAML file.
The YAML file is expected to be located at $HOME/.nextmv/registry.yaml.
| RETURNS | DESCRIPTION |
|---|---|
Registry
|
The loaded registry. |
| RAISES | DESCRIPTION |
|---|---|
FileNotFoundError
|
If the |
YAMLError
|
If there is an error parsing the YAML file. |
Examples:
Assuming an registry.yaml file exists in $HOME/.nextmv/ with the following content:
>>> from nextmv.local import Registry
>>> # registry = Registry.from_yaml() # This would load the registry from the YAML file
>>> # assert isinstance(registry, Registry)
Source code in nextmv-py/nextmv/nextmv/local/registry.py
delete_entry
¶
Remove an entry from the local app registry.
Specify either the app_id or the src to identify the entry to
delete. If both are provided, both criteria must match to ensure
registry consistency.
| PARAMETER | DESCRIPTION |
|---|---|
|
The ID of the application to remove from the registry.
TYPE:
|
|
The source path of the application to remove from the registry.
TYPE:
|
Examples:
>>> from nextmv.local import Registry
>>> registry = Registry.from_yaml()
>>> # Delete by app_id
>>> registry.delete_entry(app_id="my-app")
>>> # Delete by source path
>>> registry.delete_entry(src="/path/to/app")
Source code in nextmv-py/nextmv/nextmv/local/registry.py
entry
¶
Find an entry in the local app registry.
Specify either the app_id or the src to identify the entry to
find. If both are provided, both criteria must match to ensure
registry consistency.
| PARAMETER | DESCRIPTION |
|---|---|
|
The ID of the application to find in the registry.
TYPE:
|
|
The source path of the application to find in the registry.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AppEntry | None
|
The found registry entry, or |
Examples:
>>> from nextmv.local import Registry
>>> registry = Registry.from_yaml()
>>> # Find by app_id
>>> entry = registry.entry(app_id="my-app")
>>> # Find by source path
>>> entry = registry.entry(src="/path/to/app")
Source code in nextmv-py/nextmv/nextmv/local/registry.py
list_entries
¶
List all entries in the local app registry.
| RETURNS | DESCRIPTION |
|---|---|
list[AppEntry]
|
A list of all registry entries. |
Examples:
>>> from nextmv.local import Registry
>>> registry = Registry.from_yaml()
>>> entries = registry.list_entries()
>>> for entry in entries:
... print(entry.app_id)
Source code in nextmv-py/nextmv/nextmv/local/registry.py
register
¶
Store a new entry in the local app registry.
| PARAMETER | DESCRIPTION |
|---|---|
|
The file system path where the application is located. This path should point to a dir containing a valid Nextmv application manifest.
TYPE:
|
|
An optional unique identifier for the application. If not provided, a safe ID will be generated.
TYPE:
|
|
An optional description of the application.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AppEntry
|
The newly created registry entry. |
| RAISES | DESCRIPTION |
|---|---|
FileNotFoundError
|
If no manifest file is found at the specified source path. |
Examples:
>>> from nextmv.local import Registry
>>> registry = Registry.from_yaml()
>>> # Register with auto-generated ID
>>> entry = registry.register(src="/path/to/app")
>>> # Register with custom ID and description
>>> entry = registry.register(src="/path/to/app", app_id="my-app", description="My application")
Source code in nextmv-py/nextmv/nextmv/local/registry.py
to_yaml
¶
Write the registry to a YAML file.
The registry will be written to $HOME/.nextmv/registry.yaml.
| RAISES | DESCRIPTION |
|---|---|
IOError
|
If there is an error writing the file. |
YAMLError
|
If there is an error serializing the registry to YAML. |
Examples:
>>> from nextmv.local import Registry
>>> registry = Registry(apps=[])
>>> # registry.to_yaml() # This would write the registry to the YAML file
Source code in nextmv-py/nextmv/nextmv/local/registry.py
update_entry
¶
update_entry(
src: str | None = None,
app_id: str | None = None,
new_app_id: str | None = None,
description: str | None = None,
content_format: ContentFormat | None = None,
) -> AppEntry | None
Update an existing entry in the local app registry.
The entry to update is identified by src and/or app_id. You can
update the app_id (by means of new_app_id), description, and/or
content_format by providing non-None values for these parameters.
If no matching entry is found, the method will not make any changes
and will return None.
| PARAMETER | DESCRIPTION |
|---|---|
|
The source path of the application to find in the registry. If provided
along with
TYPE:
|
|
The ID of the application to find in the registry. If provided along
with
TYPE:
|
|
The new app_id to set. If None, the app_id will not be updated.
TYPE:
|
|
The new description to set. If None, the description will not be updated.
TYPE:
|
|
The new content format to set. If None, the content_format will not be updated.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AppEntry | None
|
The updated entry if found and updated successfully, or None if no matching entry was found. |
Examples:
>>> from nextmv.local import Registry
>>> from nextmv.content_format import ContentFormat
>>> registry = Registry.from_yaml()
>>> # Update by src only
>>> updated = registry.update_entry(src="/path/to/app", description="Updated description")
>>> if updated:
... print(f"Updated {updated.app_id}")
>>> # Update by app_id only
>>> updated = registry.update_entry(app_id="my-app", description="Updated description")
>>> # Update the app_id itself
>>> updated = registry.update_entry(
... src="/path/to/app",
... new_app_id="new-app-id",
... content_format=ContentFormat.MULTI_FILE,
... )
>>> # Update by both src and app_id (both must match)
>>> updated = registry.update_entry(
... src="/path/to/app",
... app_id="my-app",
... description="Updated description",
... )
Source code in nextmv-py/nextmv/nextmv/local/registry.py
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 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | |