Skip to content

kit Commands

These functions provide programmatic access to the KitOps Command-Line Interface.

Available commands include:

  • info()
  • inspect()
  • list()
  • login()
  • logout()
  • pack()
  • pull()
  • push()
  • remove()
  • tag()
  • unpack()
  • version()

You can import them all from kitops.cli.kit

import kitops.cli.kit as kit

Retrieve information about a kit repository.

Parameters:

Name Type Description Default
repo_path_with_tag str

The path to the repository along with the tag.

required
filters Optional[List[str]]

A list of kitfile parts for which to retrieve information. Defaults to None.

None
**kwargs

Additional arguments to pass to the command.

{}

Returns:

Type Description
None

None

Examples:

>>> info("jozu.ml/brett/titanic-survivability:latest")
# Returns information from the local registry about the 
# "titanic-survivability:latest" ModelKit.
Source code in kitops/cli/kit.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def info(repo_path_with_tag: str, 
         filters: Optional[List[str]] = None, **kwargs) -> None:
    """
    Retrieve information about a kit repository.

    Args:
        repo_path_with_tag (str): The path to the repository along with the tag.
        filters (Optional[List[str]]): A list of kitfile parts for which to
            retrieve information. Defaults to None.
        **kwargs: Additional arguments to pass to the command.

    Returns:
        None


    Examples:
        >>> info("jozu.ml/brett/titanic-survivability:latest")
        # Returns information from the local registry about the 
        # "titanic-survivability:latest" ModelKit.
    """
    command = ["kit", "info",  
               repo_path_with_tag]
    if filters:
        for filter in filters:
            command.append("--filter")
            command.append(filter)

    command.extend(_process_command_flags(kit_cmd_name="info", **kwargs))
    _run(command=command)

Inspect a repository using the 'kit' command.

Parameters: repo_path_with_tag (str): The path to the repository along with the tag. remote (Optional[bool]): Flag to indicate if the inspection should be done remotely. Defaults to True. Otherwise, the inspection will be done locally. **kwargs: Additional arguments to pass to the command.

Returns:

Type Description
None

None

Source code in kitops/cli/kit.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def inspect(repo_path_with_tag: str, remote: Optional[bool] = True, **kwargs) -> None:
    """
    Inspect a repository using the 'kit' command.

    Parameters:
    repo_path_with_tag (str): The path to the repository along with the tag.
    remote (Optional[bool]): Flag to indicate if the inspection should be done remotely. Defaults to True.
        Otherwise, the inspection will be done locally.
    **kwargs: Additional arguments to pass to the command.

    Returns:
        None
    """
    command = ["kit", "inspect", 
                repo_path_with_tag]

    command.extend(_process_command_flags(kit_cmd_name="inspect", **kwargs))
    _run(command=command)

Lists the ModelKits available in the specified repository path.

Parameters:

Name Type Description Default
repo_path_without_tag Optional[str]

The path to the repository without the tag. If not provided, lists kits from the local registry.

None
**kwargs

Additional arguments to pass to the command.

{}

Returns:

Type Description
None

None

Source code in kitops/cli/kit.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def list(repo_path_without_tag: Optional[str] = None, **kwargs) -> None:
    """
    Lists the ModelKits available in the specified repository path.

    Args:
        repo_path_without_tag (Optional[str]): The path to the repository without the tag. 
                                               If not provided, lists kits from the local registry.
        **kwargs: Additional arguments to pass to the command.

    Returns:
        None
    """
    command = ["kit", "list"]
    if repo_path_without_tag:
        command.append(repo_path_without_tag)

    command.extend(_process_command_flags(kit_cmd_name="list", **kwargs))
    _run(command=command)

Logs in to the specified registry using the provided username and password.

Parameters:

Name Type Description Default
user str

The username for the registry.

required
passwd str

The password for the registry.

required
registry str

The registry URL. Defaults to "jozu.ml".

'jozu.ml'
**kwargs

Additional arguments to pass to the command.

{}

Returns:

Type Description
None

None

Source code in kitops/cli/kit.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
def login(user: str, passwd: str, registry: Optional[str] = "jozu.ml", **kwargs) -> None:
    """
    Logs in to the specified registry using the provided username and password.

    Args:
        user (str): The username for the registry.
        passwd (str): The password for the registry.
        registry (str, optional): The registry URL. Defaults to "jozu.ml".
        **kwargs: Additional arguments to pass to the command.

    Returns:
        None
    """
    command = [
        "kit", "login", registry,
        "--username", user,
        "--password-stdin"
    ]

    command.extend(_process_command_flags(kit_cmd_name="login", **kwargs))
    _run(command=command, input=passwd)

Logs out from the specified registry.

Parameters:

Name Type Description Default
registry str

The registry to log out from. Defaults to "jozu.ml".

'jozu.ml'
**kwargs

Additional arguments to pass to the command.

{}

Returns:

Type Description
None

None

Source code in kitops/cli/kit.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
def logout(registry: Optional[str] = "jozu.ml", **kwargs) -> None:
    """
    Logs out from the specified registry.

    Args:
        registry (str, optional): The registry to log out from. Defaults to "jozu.ml".
        **kwargs: Additional arguments to pass to the command.

    Returns:
        None
    """
    command = ["kit", "logout", registry]

    command.extend(_process_command_flags(kit_cmd_name="logout", **kwargs))
    _run(command=command)

Packs the current directory into a ModelKit package with a specified tag.

Parameters:

Name Type Description Default
repo_path_with_tag str

The repository path along with the tag to be used for the package.

required
**kwargs

Additional arguments to pass to the command.

{}

Returns:

Type Description
None

None

Source code in kitops/cli/kit.py
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
def pack(repo_path_with_tag: str, **kwargs)-> None:
    """
    Packs the current directory into a ModelKit package with a specified tag.

    Args:
        repo_path_with_tag (str): The repository path along with the tag to be used for the package.
        **kwargs: Additional arguments to pass to the command.

    Returns:
        None
    """
    command = ["kit", "pack", ".", 
               "--tag", repo_path_with_tag]

    command.extend(_process_command_flags(kit_cmd_name="pack", **kwargs))
    _run(command=command)

Pulls the specified ModelKit from the remote registry.

Parameters:

Name Type Description Default
repo_path_with_tag str

The path to the repository along with the tag to pull.

required
**kwargs

Additional arguments to pass to the command.

{}

Returns:

Type Description
None

None

Source code in kitops/cli/kit.py
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
def pull(repo_path_with_tag: str, **kwargs) -> None:
    """
    Pulls the specified ModelKit from the remote registry.

    Args:
        repo_path_with_tag (str): The path to the repository along with the tag to pull.
        **kwargs: Additional arguments to pass to the command.

    Returns:
        None
    """
    command = ["kit", "pull", 
               repo_path_with_tag]

    command.extend(_process_command_flags(kit_cmd_name="pull", **kwargs))
    _run(command=command)

Pushes the specified ModelKit to the remote registry.

Parameters:

Name Type Description Default
repo_path_with_tag str

The path to the repository along with the tag to be pushed.

required
**kwargs

Additional arguments to pass to the command.

{}

Returns:

Type Description
None

None

Source code in kitops/cli/kit.py
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
def push(repo_path_with_tag: str, **kwargs) -> None:
    """
    Pushes the specified ModelKit to the remote registry.

    Args:
        repo_path_with_tag (str): The path to the repository along with the tag to be pushed.
        **kwargs: Additional arguments to pass to the command.

    Returns:
        None
    """
    command = ["kit", "push", 
               repo_path_with_tag]

    command.extend(_process_command_flags(kit_cmd_name="push", **kwargs))
    _run(command=command)

Remove a ModelKit from the registry.

Parameters:

Name Type Description Default
repo_path_with_tag str

The path to the repository with its tag.

required
**kwargs

Additional arguments to pass to the command.

{}

Returns:

Type Description
None

None

Source code in kitops/cli/kit.py
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
def remove(repo_path_with_tag: str, **kwargs) -> None:
    """
    Remove a ModelKit from the registry.

    Args:
        repo_path_with_tag (str): The path to the repository with its tag.
        **kwargs: Additional arguments to pass to the command.

    Returns:
        None
    """
    command = ["kit", "remove",  
               repo_path_with_tag]

    command.extend(_process_command_flags(kit_cmd_name="remove", **kwargs))

    try:
        _run(command=command)
    except subprocess.CalledProcessError as e:
        # If the repository is not found in the registry, ignore the error
        pass

Tag a ModelKit with a new tag.

Parameters:

Name Type Description Default
repo_path_with_tag str

The path to the repository with its tag.

required
repo_path_with_new_tag str

The new tag to be assigned to the ModelKit.

required
**kwargs

Additional arguments to pass to the command.

{}

Returns:

Type Description
None

None

Raises:

Type Description
CalledProcessError

If the command returns a non-zero exit status

Examples:

>>> tag("jozu.ml/brett/titanic-survivability:latest", 
        "jozu.ml/brett/titanic-survivability:v2")
Source code in kitops/cli/kit.py
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
def tag(repo_path_with_tag: str, repo_path_with_new_tag: str, **kwargs) -> None:
    """
    Tag a ModelKit with a new tag.

    Args:
        repo_path_with_tag (str): The path to the repository with its tag.
        repo_path_with_new_tag (str): The new tag to be assigned to the ModelKit.
        **kwargs: Additional arguments to pass to the command.

    Returns:
        None

    Raises:
        subprocess.CalledProcessError: If the command returns a non-zero exit status

    Examples:
        >>> tag("jozu.ml/brett/titanic-survivability:latest", 
                "jozu.ml/brett/titanic-survivability:v2")
    """
    command = ["kit", "tag", 
               repo_path_with_tag, 
               repo_path_with_new_tag]

    command.extend(_process_command_flags(kit_cmd_name="tag", **kwargs))
    _run(command=command)

Unpacks a ModelKit to the specified directory from the remote registry.

This function constructs a command to unpack a ModelKit and calls an internal function to execute the command.

Parameters:

Name Type Description Default
repo_path_with_tag str

The path to the repository along with the tag to be unpacked.

required
dir str

The directory to unpack the ModelKit to.

required
**kwargs

Additional arguments to pass to the command.

{}

Returns:

Type Description
None

None

Source code in kitops/cli/kit.py
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
def unpack(repo_path_with_tag: str, dir: str, 
           filters: Optional[List[str]] = None, **kwargs) -> None:
    """
    Unpacks a ModelKit to the specified directory from the remote registry.

    This function constructs a command to unpack a ModelKit and 
    calls an internal function to execute the command.

    Args:
        repo_path_with_tag (str): The path to the repository along with 
            the tag to be unpacked.
        dir (str): The directory to unpack the ModelKit to.
        **kwargs: Additional arguments to pass to the command.

    Returns:
        None
    """
    command = ["kit", "unpack", 
               "--dir", dir, 
               repo_path_with_tag]
    if filters:
        for filter in filters:
            command.append("--filter")
            command.append(filter)

    command.extend(_process_command_flags(kit_cmd_name="unpack", **kwargs))
    _run(command=command)

Lists the version of the KitOps Command-line Interface (CLI).

Parameters:

Name Type Description Default
**kwargs

Additional arguments to pass to the command.

{}

Returns:

Type Description
None

None

Source code in kitops/cli/kit.py
240
241
242
243
244
245
246
247
248
249
250
251
252
253
def version(**kwargs) -> None:
    """
    Lists the version of the KitOps Command-line Interface (CLI).

    Args:
        **kwargs: Additional arguments to pass to the command.

    Returns:
        None
    """
    command = ["kit", "version"]

    command.extend(_process_command_flags(kit_cmd_name="version", **kwargs))
    _run(command=command)