Skip to content

Commit

Permalink
re-use workspace by name
Browse files Browse the repository at this point in the history
  • Loading branch information
gschoeni committed Dec 21, 2024
1 parent 0d7b060 commit 07b9bd3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions oxen/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion oxen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ polars = { version = "0.44.0", features = [
] }
serde_json = "1.0.106"
uuid = { version = "1.4.1", features = ["serde", "v4"] }
liboxen = "0.24.0"
liboxen = "0.24.1"
# liboxen = { path = "../../Oxen/src/lib" }

[build-dependencies]
Expand Down
13 changes: 13 additions & 0 deletions oxen/src/py_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ impl PyWorkspace {
) -> Result<Self, PyOxenError> {
let name = name.unwrap_or_else(|| format!("workspace-{}", Uuid::new_v4()));

// Get the workspace by name
let workspace = pyo3_asyncio::tokio::get_runtime().block_on(async {
api::client::workspaces::get_by_name(&repo.repo, &name).await
})?;

if let Some(workspace) = workspace {
return Ok(Self {
repo,
branch_name: branch_name.clone(),
id: workspace.id,
});
}

let workspace = pyo3_asyncio::tokio::get_runtime().block_on(async {
api::client::workspaces::create_with_path(
&repo.repo,
Expand Down

0 comments on commit 07b9bd3

Please sign in to comment.