discovery.manager
napt.discovery.manager
Discovery pipeline orchestration.
This module owns the top-level discover_recipe
entry point used by napt discover. It loads the merged configuration,
picks a flow based on the recipe's discovery.strategy value, records
the release as a pending publication candidate in deployment state, and
returns the public DiscoverResult.
Two Flows
Two flows feed into the same orchestration:
- Version-first (api_github, api_json, web_scrape and any other registered DiscoveryStrategy): the strategy returns a RemoteVersion, whose version is the trigger: a run that finds the same version as last time reuses the previous download without a request.
- url_download (handled by
run_url_download):
has no version to compare, so it sends HTTP conditional headers
(
ETag/Last-Modified) and reuses the file on HTTP 304. Not a registered strategy because it cannot determine the version without the file.
Both flows end in resolve_installer, which downloads when needed, reads the version from an MSI or MSIX installer, and returns a StrategyResult that this module unwraps into the pending release and the public result.
discover_recipe
discover_recipe(
recipe_path: Path,
output_dir: Path | None = None,
state_dir: Path | None = None,
stateless: bool = False,
) -> DiscoverResult
Discovers the latest version of an app and resolves its installer.
Loads the recipe configuration, dispatches to the appropriate
discovery flow (version-first registered strategy or url_download),
records the release as the pending publication candidate in deployment
state when it differs from the published version, and returns the
public discovery result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe_path
|
Path
|
Path to the recipe YAML file. Must exist and be readable. |
required |
output_dir
|
Path | None
|
Directory to download the installer into. When
omitted, falls back to |
None
|
state_dir
|
Path | None
|
State root; per-app deployment state files live in its
|
None
|
stateless
|
bool
|
When True, deployment state is neither read nor written, so no pending release is recorded. |
False
|
Returns:
| Type | Description |
|---|---|
DiscoverResult
|
Public discovery result containing the resolved version, |
DiscoverResult
|
file path, and SHA-256 hash. |
Raises:
| Type | Description |
|---|---|
ConfigError
|
On missing or invalid configuration, including
an unknown |
NetworkError
|
On download or version-extraction failures from either flow. |
StateError
|
On a corrupted deployment state file. |
Source code in napt/discovery/manager.py
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 | |