Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resolver = "2"

[workspace.package]
edition = "2021"
version = "0.3.45"
version = "0.3.46"
description = "Tower is the best way to host Python data apps in production"
rust-version = "1.81"
authors = ["Brad Heller <brad@tower.dev>"]
Expand Down
4 changes: 1 addition & 3 deletions crates/tower-cmd/src/util/apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ pub async fn ensure_app_exists(
}
Err(create_err) => {
spinner.failure();
Err(crate::Error::ApiCreateAppError {
source: create_err,
})
Err(crate::Error::ApiCreateAppError { source: create_err })
}
}
}
43 changes: 32 additions & 11 deletions crates/tower-runtime/src/subprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,51 @@ impl SubprocessBackend {
/// Returns the Package (which keeps the temp directory alive)
async fn receive_and_unpack_package(
&self,
ctx: &tower_telemetry::Context,
mut package_stream: Box<dyn tokio::io::AsyncRead + Send + Unpin>,
) -> Result<Package, Error> {
use tower_telemetry::{debug, error, info};
// Create temp directory for this package
let temp_dir = TmpDir::new("tower-package")
.await
.map_err(|_| Error::PackageCreateFailed)?;
let temp_dir = TmpDir::new("tower-package").await.map_err(|e| {
error!(ctx: ctx, "Failed to create temp directory: {:?}", e);
Error::PackageCreateFailed
})?;

// Save stream to tar.gz file
let tar_gz_path = temp_dir.to_path_buf().join("package.tar.gz");
let mut file = File::create(&tar_gz_path)
.await
.map_err(|_| Error::PackageCreateFailed)?;
debug!(ctx: ctx, "Saving package stream to {:?}", tar_gz_path);

tokio::io::copy(&mut package_stream, &mut file)
let mut file = File::create(&tar_gz_path).await.map_err(|e| {
error!(ctx: ctx, "Failed to create package file: {:?}", e);
Error::PackageCreateFailed
})?;

let bytes_copied = tokio::io::copy(&mut package_stream, &mut file)
.await
.map_err(|_| Error::PackageCreateFailed)?;
.map_err(|e| {
error!(ctx: ctx, "Failed to save package stream: {:?}", e);
Error::PackageCreateFailed
})?;

debug!(ctx: ctx, "Downloaded {} bytes", bytes_copied);

file.flush().await.map_err(|_| Error::PackageCreateFailed)?;
file.flush().await.map_err(|e| {
error!(ctx: ctx, "Failed to flush package file: {:?}", e);
Error::PackageCreateFailed
})?;
drop(file);

// Unpack the package
info!(ctx: ctx, "Unpacking package");
let mut package = Package::default();
package.package_file_path = Some(tar_gz_path);
package.tmp_dir = Some(temp_dir);
package.unpack().await?;
package.unpack().await.map_err(|e| {
error!(ctx: ctx, "Failed to unpack package: {:?}", e);
Error::PackageUnpackFailed
})?;

info!(ctx: ctx, "Successfully unpacked package");
Ok(package)
}
}
Expand Down Expand Up @@ -93,7 +112,9 @@ impl ExecutionBackend for SubprocessBackend {
};

// Receive package stream and unpack it
let mut package = self.receive_and_unpack_package(spec.package_stream).await?;
let mut package = self
.receive_and_unpack_package(&spec.telemetry_ctx, spec.package_stream)
.await?;

let unpacked_path = package
.unpacked_path
Expand Down
15 changes: 11 additions & 4 deletions crates/tower-uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub fn cleanup_stale_uv_lock_files() {
Ok(f) => f,
Err(e) => {
debug!("Failed to open lock file {:?}: {:?}", path, e);
continue
continue;
}
};

Expand Down Expand Up @@ -187,7 +187,8 @@ fn is_uv_lock_file_name<S: AsRef<std::ffi::OsStr>>(lock_name: S) -> bool {
let uv_lock_pattern = Regex::new(r"^uv-[0-9a-f]{16}\.lock$").unwrap();
let os_str = lock_name.as_ref();

os_str.to_str()
os_str
.to_str()
.map(|name| uv_lock_pattern.is_match(name))
.unwrap_or(false)
}
Expand Down Expand Up @@ -567,10 +568,16 @@ mod tests {
cleanup_stale_uv_lock_files();

// UV lock file should be removed (it wasn't locked)
assert!(!uv_lock_file.exists(), "UV lock file should have been cleaned up");
assert!(
!uv_lock_file.exists(),
"UV lock file should have been cleaned up"
);

// Non-UV file should still exist
assert!(non_uv_file.exists(), "Non-UV file should not have been touched");
assert!(
non_uv_file.exists(),
"Non-UV file should not have been touched"
);

// Clean up the non-UV file
let _ = fs::remove_file(&non_uv_file);
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "tower"
version = "0.3.45"
version = "0.3.46"
description = "Tower CLI and runtime environment for Tower."
authors = [{ name = "Tower Computing Inc.", email = "brad@tower.dev" }]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

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