commands

class ns_docker_wrapper.commands.ArgumentBuilder(command: Command, original_name: str, formatted_name: str)[source]

Bases: object

A helper class to recursively build dot-notation arguments.

Parameters:
  • command (Command) – The command to build arguments for.

  • original_name (str) – The original snake_case name of the argument.

  • formatted_name (str) – The formatted (kebab-case) name of the argument.

class ns_docker_wrapper.commands.Command(base_command: str)[source]

Bases: object

Represents a Nerfstudio command to be executed.

add_positional_arg(value: str) Command[source]

Adds a positional argument.

Note

Positional arguments are not automatically copied to the internal temporary volume. If a positional argument is a path, it must be relative to the output_base_path (which corresponds to /workspace in Docker mode).

Parameters:

value (str) – The value of the positional argument.

Returns:

The command with the new argument.

Return type:

Command

run() tuple[int, str][source]

Executes the command and returns the exit code or output.

Returns:

The exit code or output of the command execution.

Return type:

tuple[int, str]

class ns_docker_wrapper.commands.PathArgument(local_path: str, copy_depth: int)[source]

Bases: object

A special wrapper for local paths.

This wrapper indicates that the path needs to be copied into the Docker container’s internal temporary volume before being passed to Nerfstudio.

Parameters:
  • local_path (str) – The local path to the file or directory.

  • copy_depth (int) – The depth to copy the directory structure.

ns_docker_wrapper.commands.custom_command(command_string: str) Command[source]

Creates a custom command to be run.

Parameters:

command_string (str) – The command to run.

Returns:

A new Command object for the custom command.

Return type:

Command

ns_docker_wrapper.commands.path(local_path: str, copy_depth: int = 0) PathArgument[source]

Wraps a local file system path.

This indicates that it should be copied into an internal temporary volume before being used by Nerfstudio. This is useful for data that is not already in the output_base_path.

Parameters:
  • local_path (str) – The local path to the file or directory.

  • copy_depth (int) – The depth to copy the directory structure.

Returns:

A new PathArgument object.

Return type:

PathArgument

ns_docker_wrapper.commands.process_data(processor: str, data_path: str | PathArgument) Command[source]

Creates a ‘ns-process-data’ command.

Parameters:
  • processor (str) – The processor to use.

  • data_path (Union[str, PathArgument]) – The path to the data. Can be a local path wrapped with nsdw.path() or a path relative to output_base_path (which corresponds to /workspace in Docker mode).

Returns:

A new Command object for the process-data command.

Return type:

Command

ns_docker_wrapper.commands.process_images(input_image_path: str | PathArgument, output_dir: str) Command[source]

Creates a ‘ns-process-data images’ command.

Parameters:
  • input_image_path (Union[str, PathArgument]) – The path to the input images. Can be a local path wrapped with nsdw.path() or a path relative to output_base_path (which corresponds to /workspace in Docker mode).

  • output_dir (str) – The path to the output directory, relative to output_base_path.

Returns:

A new Command object for the process-images command.

Return type:

Command

ns_docker_wrapper.commands.train(method: str) Command[source]

Creates a ‘ns-train’ command.

When executed with .run(), this command returns the absolute path to the training config.yml file.

Parameters:

method (str) – The training method to use.

Returns:

A new Command object for the train command.

Return type:

Command