oxen.workspace
Workspace Objects
Examples
Adding Files to a Workspace
Create a workspace from a branch.__init__
repo-PyRemoteRepoThe remote repo to create the workspace from.branch-strThe branch name to create the workspace from. The workspace will be tied to the commit id of the branch at the time of creation.workspace_id-Optional[str]The workspace id to create the workspace from. If left empty, will create a unique workspace id.workspace_name-Optional[str]The name of the workspace. If left empty, the workspace will have no name.path-Optional[str]The path to the workspace. If left empty, the workspace will be created in the root of the remote repo.
id
name
branch
commit_id
created_at
repo
status
path-strThe path to check the status of.
add
src-str| Iterable[str] | Path | Iterable[Path] The path(s) to the local file(s) to be staged.dst-strThe path in the remote repo where the file(s) will be added.raise_on_failure-boolWhether to raise an exception if any files fail to upload. By default, raises an exception. Set toFalseto return a list of failed file paths instead.
PyErrorFileInfo for files that failed to upload.
An empty list means all files were uploaded successfully.
Each entry has .hash, .path, and .error attributes.
Raises:
ValueError if the provided input is not a valid filepath, an invalid
directory, or it points to an empty directory, or is a collection
of empty directories.
add_files
add, which places files into a flat destination directory,
this method uses each fileβs path relative to the supplied base directory as
its staging path on the server.
The base_dir serves as a stand-in for the root of the remote repository. The key
use of add_files is to import a large file tree into an existing repository.
For example, a file at
repo/data/images/cat.jpg will be staged as data/images/cat.jpg.
Arguments:
base_dir-str|PathThe base directory: all added files share this as an ancestor.paths-Iterable[str]|Iterable[Path]The file paths to add. Can be absolute or relative to the base directory. Each path must point to an existing file.raise_on_failure-boolWhether to raise an exception if any files fail to upload. By default, raises an exception. Set toFalseto return a list of failed file paths instead.
PyErrorFileInfo for files that failed to upload.
An empty list means all files were uploaded successfully.
Each entry has .hash, .path, and .error attributes.
Raises:
PyOxenError- If no valid file paths are provided.
add_bytes
src-strThe relative path to be used as the entryβs name in the workspacebuf-bytesThe memory buffer to be read from for this entrydst-strThe path in the remote repo where the file will be added
rm
unstage, which does the same thing
through the non-deprecated endpoint.
Arguments:
path-strThe path to the staged file to unstage
unstage
path-strThe path to the staged file to unstage
commit
message-strThe message to commit withbranch_name-Optional[str]The name of the branch to commit to. If left empty, will commit to the branch the workspace was created from.