Recipes module initialization (moved to nskit.client).
DiscoveryClient
¶
Client for discovering available recipes.
Source code in src/nskit/client/discovery.py
__init__(backend)
¶
Initialize discovery client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
RecipeBackend
|
Backend for recipe discovery |
required |
discover_recipes(search_term=None)
¶
Discover available recipes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search_term
|
Optional[str]
|
Optional search term to filter recipes |
None
|
Returns:
| Type | Description |
|---|---|
list[RecipeInfo]
|
List of discovered recipes |
Source code in src/nskit/client/discovery.py
get_recipe_info(recipe_name)
¶
Get detailed info for a specific recipe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe_name
|
str
|
Recipe name |
required |
Returns:
| Type | Description |
|---|---|
Optional[RecipeInfo]
|
Recipe info or None if not found |
Source code in src/nskit/client/discovery.py
get_recipe_versions(recipe_name)
¶
Get available versions for a recipe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe_name
|
str
|
Recipe name |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of available versions |
DockerEngine
¶
Bases: RecipeEngine
Execute recipes in Docker containers.
Source code in src/nskit/client/engines/docker.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 155 156 | |
__init__(skip_pull=False, timeouts=None)
¶
Initialise the Docker engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skip_pull
|
bool
|
Skip pulling the image (useful for locally built images). |
False
|
timeouts
|
EngineTimeouts | dict | None
|
Timeout configuration for Docker operations. |
None
|
Source code in src/nskit/client/engines/docker.py
execute(recipe, version, parameters, output_dir, image_url=None, entrypoint=None)
¶
Execute recipe in a Docker container.
Writes parameters to a YAML file, mounts it into the container,
and invokes the nskit CLI init command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe
|
str
|
Recipe name. |
required |
version
|
str
|
Recipe version. |
required |
parameters
|
dict[str, Any]
|
Recipe input parameters. |
required |
output_dir
|
Path
|
Host directory for generated output. |
required |
image_url
|
str | None
|
Docker image URL (required). |
None
|
entrypoint
|
str | None
|
Not used for Docker engine. |
None
|
Returns:
| Type | Description |
|---|---|
RecipeResult
|
Recipe execution result. |
Source code in src/nskit/client/engines/docker.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 155 156 | |
ExecutionMode
¶
Bases: str, Enum
Recipe execution mode.
Source code in src/nskit/client/execution.py
LocalEngine
¶
Bases: RecipeEngine
Execute recipes from locally installed packages.
Source code in src/nskit/client/engines/local.py
execute(recipe, version, parameters, output_dir, image_url=None, entrypoint=None)
¶
Execute recipe from installed package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe
|
str
|
Recipe name. |
required |
version
|
str
|
Recipe version. |
required |
parameters
|
dict[str, Any]
|
Recipe parameters. |
required |
output_dir
|
Path
|
Output directory. |
required |
image_url
|
str
|
Not used for Local engine. |
None
|
entrypoint
|
str
|
Recipe entrypoint (required). |
None
|
Returns:
| Type | Description |
|---|---|
RecipeResult
|
Recipe execution result. |
Source code in src/nskit/client/engines/local.py
RecipeClient
¶
Pure Python client for recipe operations (no CLI dependencies).
Source code in src/nskit/client/recipes.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
__init__(backend, engine=None)
¶
Initialize the recipe client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
RecipeBackend
|
Backend for recipe discovery and fetching |
required |
engine
|
RecipeEngine | None
|
Execution engine (defaults to DockerEngine) |
None
|
Source code in src/nskit/client/recipes.py
create_repository(repo_name, project_path=None, description=None, private=True)
¶
Create a remote repository and optionally push the project.
Auto-detects the VCS provider from environment variables. If project_path is provided and contains a git repo, the project is committed and pushed to the new remote.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_name
|
str
|
Repository name. |
required |
project_path
|
Path | None
|
Local project directory to push. |
None
|
description
|
str | None
|
Repository description. |
None
|
private
|
bool
|
Whether the repository should be private. |
True
|
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
Tuple of (success, message). |
Source code in src/nskit/client/recipes.py
get_recipe_versions(recipe)
¶
Get available versions for a specific recipe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe
|
str
|
Recipe name |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of available versions |
initialize_recipe(recipe, version, parameters, output_dir, force=False)
¶
Initialize a new project from a recipe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe
|
str
|
Recipe name |
required |
version
|
str
|
Recipe version |
required |
parameters
|
dict[str, Any]
|
Recipe parameters |
required |
output_dir
|
Path
|
Output directory for the project |
required |
force
|
bool
|
Allow initialization in non-empty directory |
False
|
Returns:
| Type | Description |
|---|---|
RecipeResult
|
Result of the initialization |
Source code in src/nskit/client/recipes.py
list_recipes()
¶
List all available recipes from the backend.
Returns:
| Type | Description |
|---|---|
list[RecipeInfo]
|
List of recipe information |
RecipeInfo
¶
RecipeResult
¶
Bases: BaseModel
Result of recipe initialization.
Source code in src/nskit/client/models.py
RepositoryClient
¶
Client for managing recipe repositories.
Source code in src/nskit/recipes/repository_client.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 | |
__init__(vcs_client=None)
¶
Initialise repository client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcs_client
|
RepoClient | None
|
Optional VCS client (e.g., GithubRepoClient) |
None
|
configure_repository(repo_name, settings=None, default_branch=None, branch_rules=None)
¶
Apply repository configuration and branch protection via the provider.
Delegates to the VCS provider's configure and
set_branch_protection hooks. Providers that do not support remote
configuration treat these as no-ops, so this is safe to call always.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_name
|
str
|
Repository name. |
required |
settings
|
dict[str, Any] | None
|
Repository-level settings overrides (merge options, features). |
None
|
default_branch
|
str | None
|
Branch to apply protection to. If |
None
|
branch_rules
|
dict[str, Any] | None
|
Branch protection overrides for |
None
|
Source code in src/nskit/recipes/repository_client.py
create_and_push(repo_name, project_path, description=None, private=True)
¶
Create a remote repository and push an existing local repo to it.
Expects the project to already have a git repo with at least one commit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_name
|
str
|
Repository name. |
required |
project_path
|
Path
|
Local project directory to push. |
required |
description
|
str | None
|
Repository description. |
None
|
private
|
bool
|
Whether repository is private. |
True
|
Returns:
| Type | Description |
|---|---|
RepositoryInfo
|
Repository info including the remote URL. |
Source code in src/nskit/recipes/repository_client.py
create_repository(repo_name, description=None, private=True)
¶
Create a new remote repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_name
|
str
|
Repository name. |
required |
description
|
str | None
|
Repository description. |
None
|
private
|
bool
|
Whether repository is private. |
True
|
Returns:
| Type | Description |
|---|---|
RepositoryInfo
|
Repository info including the remote URL. |
Source code in src/nskit/recipes/repository_client.py
get_repository_info(repo_name)
¶
Get repository information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_name
|
str
|
Repository name. |
required |
Returns:
| Type | Description |
|---|---|
RepositoryInfo | None
|
Repository info or |
Source code in src/nskit/recipes/repository_client.py
RepositoryInfo
¶
Bases: BaseModel
Information about a created repository.
Source code in src/nskit/client/models.py
UpdateClient
¶
Pure Python client for recipe updates (no CLI dependencies).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
RecipeBackend
|
Backend for fetching recipe versions. |
required |
engine
|
RecipeEngine | None
|
Optional recipe engine for project generation. |
None
|
config_dir
|
str
|
Config directory name (default |
'.recipe'
|
config_filename
|
str
|
Config file name (default |
'config.yml'
|
Source code in src/nskit/client/update.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | |
check_update_available(project_path)
¶
Check if an update is available for the project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_path
|
Path
|
Path to the project. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Latest version string if an update is available, |
str | None
|
otherwise. |
Source code in src/nskit/client/update.py
update_project(project_path, target_version, diff_mode=DiffMode.THREE_WAY, dry_run=False)
¶
Update project to target version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_path
|
Path
|
Path to the project. |
required |
target_version
|
str
|
Target version to update to. |
required |
diff_mode
|
DiffMode
|
Diff mode (2-way or 3-way). |
THREE_WAY
|
dry_run
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
UpdateResult
|
Update result with conflicts and errors. |
Source code in src/nskit/client/update.py
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 155 156 157 158 159 | |
UpdateResult
¶
Bases: BaseModel
Result of recipe update.
Source code in src/nskit/client/models.py
nskit.recipes.recipe.RecipeRecipe
¶
Bases: PyRecipe
A Recipe for creating Recipes, meta!
Source code in src/nskit/recipes/recipe.py
contents = Field([ingredients.gitignore, ingredients.noxfile, ingredients.pre_commit, recipe_ingredients.pyproject_toml, recipe_ingredients.readme_md, recipe_ingredients.dockerfile, recipe_ingredients.docker_ignore, ingredients.test_dir, recipe_ingredients.src_dir, ingredients.docs_dir, LicenseFile()], description='The folder contents')
class-attribute
instance-attribute
¶
nskit.recipes.python.api.APIRecipe
¶
Bases: PyRecipe
API Service Recipe.
Source code in src/nskit/recipes/python/api.py
contents = Field([ingredients.gitignore, ingredients.noxfile, ingredients.pre_commit, api_ingredients.pyproject_toml, api_ingredients.readme_md, ingredients.test_dir, api_ingredients.src_dir, api_ingredients.docker.docker_ignore, api_ingredients.docker.dockerfile, ingredients.docs_dir, LicenseFile()], description='The folder contents')
class-attribute
instance-attribute
¶
nskit.recipes.python.package.PackageRecipe
¶
Bases: PyRecipe
Package Recipe.
Source code in src/nskit/recipes/python/package.py
contents = Field([ingredients.gitignore, ingredients.noxfile, ingredients.pre_commit, ingredients.pyproject_toml, ingredients.readme_md, ingredients.test_dir, ingredients.src_dir, ingredients.docs_dir, LicenseFile()], description='The folder contents')
class-attribute
instance-attribute
¶
Python Ingredients¶
nskit.recipes.python.PyRecipe
¶
Bases: CodeRecipe
Base recipe for python recipes.
Source code in src/nskit/recipes/python/__init__.py
name = Field(None, validate_default=True, description='The repository name')
class-attribute
instance-attribute
¶
version = __version__
class-attribute
instance-attribute
¶
Version of the recipe.
repo = Field(...)
class-attribute
instance-attribute
¶
Python repo metadata.
pre_hooks = Field(default_factory=list, validate_default=True, description='Hooks that can be used to modify a recipe path and context before writing')
class-attribute
instance-attribute
¶
post_hooks = Field([hooks.git.GitInit(), hooks.pre_commit.PrecommitInstall()], validate_default=True, description='Hooks that can be used to modify a recipe path and context after writing')
class-attribute
instance-attribute
¶
extension_name = Field(None, description='The name of the recipe as an extension to load.')
class-attribute
instance-attribute
¶
git = GitConfig()
class-attribute
instance-attribute
¶
context
property
¶
Get the context on the initialised recipe.
recipe_batch
property
¶
Get information about the specific info of this recipe.
dryrun(base_path=None, override_path=None, **additional_context)
¶
See the recipe as a dry run.
Source code in src/nskit/mixer/components/recipe.py
validate(base_path=None, override_path=None, **additional_context)
¶
Validate the created repo.
Source code in src/nskit/mixer/components/recipe.py
create(base_path=None, override_path=None, **additional_context)
¶
Create the recipe.
Use the configured parameters and any additional context as kwargs to create the recipe at the base path (or current directory if not provided).
Source code in src/nskit/mixer/components/recipe.py
load(recipe_name, entrypoint=None, initialize=True, **kwargs)
staticmethod
¶
Load a recipe as an extension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe_name
|
str
|
Name of the recipe to load |
required |
entrypoint
|
Optional[str]
|
Recipe entrypoint to use (defaults to RECIPE_ENTRYPOINT) |
None
|
initialize
|
bool
|
Whether to initialize the recipe instance (default True) |
True
|
**kwargs
|
Arguments to pass to recipe initialization |
{}
|
Returns:
| Type | Description |
|---|---|
|
Recipe instance if initialize=True, otherwise recipe class |
Source code in src/nskit/mixer/components/recipe.py
nskit.recipes.python.PyRepoMetadata
¶
Bases: RepoMetadata
Repo Metadata for python templates.
Source code in src/nskit/recipes/python/__init__.py
owner = Field(..., description='Who is the owner of the repo')
class-attribute
instance-attribute
¶
email = Field(..., description='The email for the repo owner')
class-attribute
instance-attribute
¶
url = Field(..., description='The Repository url.')
class-attribute
instance-attribute
¶
name
property
writable
¶
Get repo name.
py_name
property
¶
Get python module name.
py_root
property
¶
Get root python module name.
src_path
property
¶
Get module folder structure (src not included).
module_depth
property
¶
Get the module depth.
a.b.c has a depth of 3, a has a depth of 1
nskit.recipes.python.ingredients
¶
Ingredients for repos.
gitignore = File(name='.gitignore', content='nskit.recipes.python.ingredients.tools:gitignore.jinja')
module-attribute
¶
noxfile = File(name='noxfile.py', content='nskit.recipes.python.ingredients.tools:noxfile.py.jinja')
module-attribute
¶
pre_commit = File(name='.pre-commit-config.yaml', content='nskit.recipes.python.ingredients.tools:pre-commit-config.yaml.jinja')
module-attribute
¶
pyproject_toml = File(name='pyproject.toml', content='nskit.recipes.python.ingredients.tools:pyproject.toml.jinja')
module-attribute
¶
readme_md = File(name='README.md', content='nskit.recipes.python.ingredients.tools:README.md.jinja')
module-attribute
¶
test_dir = Folder(name='tests', contents=[Folder(name='unit', contents=[File(name='test__version.py', content=test_version)]), Folder(name='functional', contents=[File(name=_GIT_KEEP, content='')]), Folder(name='integration', contents=[File(name=_GIT_KEEP, content='')]), Folder(name='performance', contents=[File(name=_GIT_KEEP, content='')]), Folder(name='smoke', contents=[File(name=_GIT_KEEP, content='')])])
module-attribute
¶
src_dir = Folder(name='src', contents=[Folder(id_='src_path', name='{{repo.src_path}}', contents=[File(name='__init__.py', content='nskit.recipes.python.ingredients.src:__init__.py.jinja'), File(name='_version.py', content='__version__ = "0.0.0"\n')])])
module-attribute
¶
nskit.recipes.python.ingredients.api
¶
API Service ingredients.
Contains fastapi based api service ingredients.
src_dir¶
Adds app.py, server.py, api/__init__.py, base.py to [nskit.recipes.python.ingredients.src_dir]
nskit.recipes.python.ingredients.docker
¶
nskit.recipes.python.ingredients.recipe
¶
src_dir¶
Adds recipe.py and ingredient.py.jinja to [nskit.recipes.python.ingredients.src_dir]