class ContreeImage
Attributes
timedelta
Time elapsed during execution.
int
Exit code of the executed command.
RunRequest | None
ContreeResult
Execution result. Only available after successful execution.
ImageState
Current state of the image in the execution lifecycle.
str | bytes | Path | Writable | AsyncWritable | None
Stderr output from the execution.
str | bytes | Path | Readable | AsyncReadable | None
Configured stdin source.
str | bytes | Path | Writable | AsyncWritable | None
Stdout output from the execution.
UUID | None
Unique identifier of the image.
str | None
Optional tag associated with the image.
Methods
apply_files()
str | Path | UploadFileSpec | list[str | Path | UploadFileSpec] | dict[str, str | Path | bytes | UploadFileSpec]
Files to upload.
list[str | Path | UploadFileSpec] | dict[str, str | Path | bytes | UploadFileSpec] | None
default:"None"
Files as a list or a dict mapping destination paths to sources.
When both args and files are provided, they are merged.
TypeVar(ImageLikeAsyncT, bound= ImageLikeAsync)
New image with the uploaded files baked in.
collect_result()
required
TypeVar(ImageLikeAsyncT, bound= ImageLikeAsync)
copy_self()
TypeVar(ImageLikeT, bound= ImageLikeBase)
copy_with_state()
required
TypeVar(ImageLikeT, bound= ImageLikeBase)
download()
str | PurePosixPath
required
Path to the file inside the image.
str | Path | None
default:"None"
Local destination path. Defaults to filename from image_path.
Path
Path to the downloaded file.
ensure_started()
tuple[TypeVar(ImageLikeAsyncT, bound= ImageLikeAsync), Executing]
ensure_state()
required
TypeVar(StateDataT, bound= Pulled | Prepared | Executing | Succeeded | Failed)
image_uuid()
str
iter_output()
AsyncIterator[OutputChunk]
list_entries()
required
required
required
list[TypeVar(FileTypeT) | TypeVar(DirTypeT)]
ls()
str | PurePosixPath
default:"'/'"
Path inside the image to list.
list[ImageFile | ImageDirectory]
list[
ImageFile | ImageDirectory]List of ImageFile and ImageDirectory objects.prepare_files_for_api()
required
dict[str, FileSpec]
read()
str | PurePosixPath
required
Path to the file inside the image.
bytes
File contents as bytes.
run()
str | None
default:"None"
Command to execute (mutually exclusive with shell).
str | None
default:"None"
Shell command string (mutually exclusive with command).
Iterable[str] | None
default:"None"
Command arguments.
dict[str, str] | None
default:"None"
Environment variables.
str | None
default:"None"
Working directory inside the image.
str | None
default:"None"
Hostname for the container.
str | bytes | Path | Readable | AsyncReadable | None
default:"None"
Input source.
str | Path | Writable | AsyncWritable | Literal[-1] | type[str | bytes] | None
default:"<class 'str'>"
Output destination for stdout.
str | Path | Writable | AsyncWritable | Literal[-1] | type[str | bytes] | None
default:"<class 'str'>"
Output destination for stderr.
str | None
default:"None"
Tag for the resulting image.
list[str | Path | UploadFileSpec] | dict[str, str | Path | bytes | UploadFileSpec] | None
default:"None"
Files to upload into the image.
float | timedelta | None
default:"None"
Execution timeout in seconds or as timedelta.
bool
default:"True"
If True, image is discarded after execution.
int | None
default:"None"
number of bytes to truncate stdout and stderr. Defaults to default_truncate_output_at
bool
default:"False"
If True, environment variables are preserved in resulting image after execution.
TypeVar(ImageLikeT, bound= ImageLikeBase)
New image instance configured for execution.
DisposableImageRunError – If attempting to run on a disposed image.
ValueError – If neither command nor shell is provided.
session()
ContreeSession
set_state()
required
None
start()
TypeVar(ImageLikeAsyncT, bound= ImageLikeAsync)
New image instance in EXECUTING state; await it or iterate its
output chunks to get the result.
tag_as()
str | None
required
Tag name to apply to the image, or None to remove the tag.
TypeVar(ImageLikeAsyncT, bound= ImageLikeAsync)
New instance with updated tag.
untag()
TypeVar(ImageLikeAsyncT, bound= ImageLikeAsync)
New instance with tag set to None.
update_request()
TypeVar(ImageLikeT, bound= ImageLikeBase)
wait()
TypeVar(ImageLikeAsyncT, bound= ImageLikeAsync)
New image instance with execution results.
class ContreeImageSync
Attributes
timedelta
Time elapsed during execution.
int
Exit code of the executed command.
RunRequest | None
ContreeResult
Execution result. Only available after successful execution.
ImageState
Current state of the image in the execution lifecycle.
str | bytes | Path | Writable | AsyncWritable | None
Stderr output from the execution.
str | bytes | Path | Readable | AsyncReadable | None
Configured stdin source.
str | bytes | Path | Writable | AsyncWritable | None
Stdout output from the execution.
UUID | None
Unique identifier of the image.
str | None
Optional tag associated with the image.
Methods
apply_files()
str | Path | UploadFileSpec | list[str | Path | UploadFileSpec] | dict[str, str | Path | bytes | UploadFileSpec]
Files to upload.
list[str | Path | UploadFileSpec] | dict[str, str | Path | bytes | UploadFileSpec] | None
default:"None"
Files as a list or a dict mapping destination paths to sources.
When both args and files are provided, they are merged.
TypeVar(ImageLikeSyncT, bound= ImageLikeSync)
New image with the uploaded files baked in.
collect_result()
required
TypeVar(ImageLikeSyncT, bound= ImageLikeSync)
copy_self()
TypeVar(ImageLikeT, bound= ImageLikeBase)
copy_with_state()
required
TypeVar(ImageLikeT, bound= ImageLikeBase)
download()
str | PurePosixPath
required
Path to the file inside the image.
str | Path | None
default:"None"
Local destination path. Defaults to filename from image_path.
Path
Path to the downloaded file.
ensure_started()
tuple[TypeVar(ImageLikeSyncT, bound= ImageLikeSync), Executing]
ensure_state()
required
TypeVar(StateDataT, bound= Pulled | Prepared | Executing | Succeeded | Failed)
image_uuid()
str
iter_output()
Iterator[OutputChunk]
list_entries()
required
required
required
list[TypeVar(FileTypeT) | TypeVar(DirTypeT)]
ls()
str | PurePosixPath
default:"'/'"
Path inside the image to list.
list[ImageFileSync | ImageDirectorySync]
list[
ImageFileSync | ImageDirectorySync]List of ImageFileSync and ImageDirectorySync objects.popen()
list[str] | str | None
default:"None"
Command and arguments list.
str | bytes | Path | Readable | AsyncReadable | None
default:"None"
Input source.
str | bytes | Path | Readable | AsyncReadable | None
default:"None"
Alternative input source (alias for stdin).
str | Path | Writable | AsyncWritable | Literal[-1] | type[str | bytes] | None
default:"None"
Output destination for stdout.
str | Path | Writable | AsyncWritable | Literal[-1] | type[str | bytes] | None
default:"None"
Output destination for stderr.
bool
default:"False"
If True, treat args as shell command.
str | None
default:"None"
Working directory inside the image.
float | None
default:"None"
Execution timeout in seconds.
bool
default:"False"
If True, raise on non-zero exit code.
bool | None
default:"None"
If True, decode output as text.
dict[str, str] | None
default:"None"
Environment variables.
ContreeProcessSync
ContreeProcessSyncContreeProcessSync object with execution results.prepare_files_for_api()
required
dict[str, FileSpec]
read()
str | PurePosixPath
required
Path to the file inside the image.
bytes
File contents as bytes.
run()
str | None
default:"None"
Command to execute (mutually exclusive with shell).
str | None
default:"None"
Shell command string (mutually exclusive with command).
Iterable[str] | None
default:"None"
Command arguments.
dict[str, str] | None
default:"None"
Environment variables.
str | None
default:"None"
Working directory inside the image.
str | None
default:"None"
Hostname for the container.
str | bytes | Path | Readable | AsyncReadable | None
default:"None"
Input source.
str | Path | Writable | AsyncWritable | Literal[-1] | type[str | bytes] | None
default:"<class 'str'>"
Output destination for stdout.
str | Path | Writable | AsyncWritable | Literal[-1] | type[str | bytes] | None
default:"<class 'str'>"
Output destination for stderr.
str | None
default:"None"
Tag for the resulting image.
list[str | Path | UploadFileSpec] | dict[str, str | Path | bytes | UploadFileSpec] | None
default:"None"
Files to upload into the image.
float | timedelta | None
default:"None"
Execution timeout in seconds or as timedelta.
bool
default:"True"
If True, image is discarded after execution.
int | None
default:"None"
number of bytes to truncate stdout and stderr. Defaults to default_truncate_output_at
bool
default:"False"
If True, environment variables are preserved in resulting image after execution.
TypeVar(ImageLikeT, bound= ImageLikeBase)
New image instance configured for execution.
DisposableImageRunError – If attempting to run on a disposed image.
ValueError – If neither command nor shell is provided.
session()
ContreeSessionSync
set_state()
required
None
start()
TypeVar(ImageLikeSyncT, bound= ImageLikeSync)
New image instance in EXECUTING state; call wait() or iterate its
output chunks to get the result.
tag_as()
str | None
required
Tag name to apply to the image, or None to remove the tag.
TypeVar(ImageLikeSyncT, bound= ImageLikeSync)
New instance with updated tag.
untag()
TypeVar(ImageLikeSyncT, bound= ImageLikeSync)
New instance with tag set to None.
update_request()
TypeVar(ImageLikeT, bound= ImageLikeBase)
wait()
TypeVar(ImageLikeSyncT, bound= ImageLikeSync)
New image instance with execution results.