From a52efe6996be5cc8b19acb05f39de4326186a794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Mon, 2 Sep 2024 20:35:39 +0200 Subject: [PATCH] Replace `tempdir` with `tempfile` `tempdir` has long been deprecated and it uses outdated dependencies. --- Cargo.lock | 181 +++++++++--------- Cargo.toml | 5 +- crates/hyperqueue/Cargo.toml | 2 +- .../hyperqueue/src/client/commands/worker.rs | 4 +- crates/hyperqueue/src/common/serverdir.rs | 22 ++- .../src/server/autoalloc/process.rs | 14 +- crates/hyperqueue/src/server/bootstrap.rs | 12 +- .../hyperqueue/src/server/event/log/read.rs | 14 +- crates/hyperqueue/src/worker/start/program.rs | 4 +- crates/pyhq/Cargo.toml | 2 +- crates/pyhq/src/cluster/mod.rs | 5 +- crates/tako/Cargo.toml | 2 +- .../tests/integration/utils/worker.rs | 4 +- 13 files changed, 133 insertions(+), 138 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index afae0213d..d9e9db3c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,7 +262,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -708,6 +708,22 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" + [[package]] name = "fiat-crypto" version = "0.2.9" @@ -730,12 +746,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "futures" version = "0.3.30" @@ -965,7 +975,7 @@ dependencies = [ "num_cpus", "orion", "psutil", - "rand 0.8.5", + "rand", "ratatui", "rmpv", "serde", @@ -975,7 +985,7 @@ dependencies = [ "signal-hook", "smallvec", "tako", - "tempdir", + "tempfile", "termion 1.5.6", "textwrap 0.16.1", "thiserror", @@ -1209,6 +1219,12 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + [[package]] name = "lock_api" version = "0.4.12" @@ -1447,7 +1463,7 @@ dependencies = [ "libc", "redox_syscall 0.5.2", "smallvec", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -1594,7 +1610,7 @@ dependencies = [ "pythonize", "serde", "tako", - "tempdir", + "tempfile", "termcolor", "tokio", ] @@ -1694,19 +1710,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi", -] - [[package]] name = "rand" version = "0.8.5" @@ -1715,7 +1718,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -1725,24 +1728,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.6.4" @@ -1792,15 +1780,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "redox_syscall" version = "0.2.16" @@ -1874,15 +1853,6 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - [[package]] name = "rmp" version = "0.8.14" @@ -1921,6 +1891,19 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "rustversion" version = "1.0.17" @@ -2205,12 +2188,12 @@ dependencies = [ "orion", "priority-queue", "psutil", - "rand 0.8.5", + "rand", "serde", "serde_bytes", "serde_json", "smallvec", - "tempdir", + "tempfile", "thin-vec", "thiserror", "tokio", @@ -2220,13 +2203,16 @@ dependencies = [ ] [[package]] -name = "tempdir" -version = "0.3.7" +name = "tempfile" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ - "rand 0.4.6", - "remove_dir_all", + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", ] [[package]] @@ -2662,7 +2648,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -2680,7 +2666,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -2700,18 +2695,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -2722,9 +2717,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -2734,9 +2729,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -2746,15 +2741,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -2764,9 +2759,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -2776,9 +2771,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -2788,9 +2783,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -2800,9 +2795,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" diff --git a/Cargo.toml b/Cargo.toml index 2878c3f54..6aa8cb19a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,14 +36,13 @@ hex = "0.4" rand = "0.8" gethostname = "0.4" thiserror = "1" -tempdir = "0.3" +tempfile = "3.12.0" tracing = "0.1" anyhow = "1" nix = { version = "0.29", features = ["process", "signal"] } bstr = { version = "1.9", features = ["serde"] } psutil = "3" - [profile.release] panic = "abort" @@ -53,4 +52,4 @@ panic = "abort" inherits = "release" lto = true codegen-units = 1 -debug = "line-tables-only" \ No newline at end of file +debug = "line-tables-only" diff --git a/crates/hyperqueue/Cargo.toml b/crates/hyperqueue/Cargo.toml index eb42f800e..92af0c0e1 100644 --- a/crates/hyperqueue/Cargo.toml +++ b/crates/hyperqueue/Cargo.toml @@ -29,7 +29,7 @@ bincode = { workspace = true } smallvec = { workspace = true } rand = { workspace = true } anyhow = { workspace = true } -tempdir = { workspace = true } +tempfile = { workspace = true } nix = { workspace = true } bstr = { workspace = true } psutil = { workspace = true } diff --git a/crates/hyperqueue/src/client/commands/worker.rs b/crates/hyperqueue/src/client/commands/worker.rs index 9acfd0497..a9cc82578 100644 --- a/crates/hyperqueue/src/client/commands/worker.rs +++ b/crates/hyperqueue/src/client/commands/worker.rs @@ -12,7 +12,7 @@ use tako::{Map, Set}; use clap::Parser; use tako::hwstats::GpuFamily; use tako::internal::worker::configuration::OverviewConfiguration; -use tempdir::TempDir; +use tempfile::TempDir; use tokio::time::sleep; use crate::client::globalsettings::GlobalSettings; @@ -245,7 +245,7 @@ fn gather_configuration(opts: WorkerStartOpts) -> anyhow::Result>(path: P) -> crate::Result anyhow::Result<()> { - let tmpdir = TempDir::new("hq")?; + let tmpdir = TempDir::with_prefix("hq")?; let mut handler = create_allocation_handler( ¶ms.manager, params.name.clone(), @@ -877,8 +876,6 @@ mod tests { use anyhow::anyhow; use derive_builder::Builder; use smallvec::smallvec; - use tempdir::TempDir; - use tako::gateway::{ LostWorkerReason, ResourceRequest, ResourceRequestEntry, ResourceRequestVariants, }; @@ -886,6 +883,7 @@ mod tests { use tako::resources::{AllocationRequest, TimeRequest, CPU_RESOURCE_NAME}; use tako::WorkerId; use tako::{Map, Set, WrappedRcRefCell}; + use tempfile::TempDir; use crate::common::arraydef::IntArray; use crate::common::manager::info::{ManagerInfo, ManagerType}; @@ -1255,7 +1253,7 @@ mod tests { let mut state = AutoAllocState::new(1); let make_dir = || { - let tempdir = TempDir::new("hq").unwrap(); + let tempdir = TempDir::with_prefix("hq").unwrap(); tempdir.into_path() }; @@ -1605,7 +1603,7 @@ mod tests { Handler::new( WrappedRcRefCell::wrap(()), move |_, _| async move { - let tempdir = TempDir::new("hq").unwrap(); + let tempdir = TempDir::with_prefix("hq").unwrap(); let dir = tempdir.into_path(); Ok(AllocationSubmissionResult::new( @@ -1625,7 +1623,7 @@ mod tests { state, move |state, _worker_count| async move { let mut state = state.get_mut(); - let tempdir = TempDir::new("hq").unwrap(); + let tempdir = TempDir::with_prefix("hq").unwrap(); let dir = tempdir.into_path(); state.allocation_attempts += 1; diff --git a/crates/hyperqueue/src/server/bootstrap.rs b/crates/hyperqueue/src/server/bootstrap.rs index aa01f1cec..60b267b91 100644 --- a/crates/hyperqueue/src/server/bootstrap.rs +++ b/crates/hyperqueue/src/server/bootstrap.rs @@ -375,7 +375,6 @@ async fn start_server(gsettings: &GlobalSettings, server_cfg: ServerConfig) -> a #[cfg(test)] mod tests { - use tempdir::TempDir; use tokio::sync::Notify; use crate::common::serverdir::{ @@ -395,6 +394,7 @@ mod tests { use std::future::Future; use std::path::Path; use std::sync::Arc; + use tempfile::TempDir; pub async fn init_test_server( tmp_dir: &Path, @@ -424,13 +424,13 @@ mod tests { #[tokio::test] async fn test_status_empty_directory() { - let tmp_dir = TempDir::new("foo").unwrap(); + let tmp_dir = TempDir::with_prefix("foo").unwrap(); assert!(get_server_status(&tmp_dir.into_path()).await.is_err()); } #[tokio::test] async fn test_status_directory_with_access_file() { - let tmp_dir = TempDir::new("foo").unwrap(); + let tmp_dir = TempDir::with_prefix("foo").unwrap(); let tmp_path = tmp_dir.into_path(); let server_dir = ServerDir::open(&tmp_path).unwrap(); let record = FullAccessRecord::new( @@ -454,7 +454,7 @@ mod tests { #[tokio::test] async fn test_status_directory_with_symlink() { - let tmp_dir = TempDir::new("foo").unwrap().into_path(); + let tmp_dir = TempDir::with_prefix("foo").unwrap().into_path(); let actual_dir = tmp_dir.join("server-dir"); std::fs::create_dir(&actual_dir).unwrap(); std::os::unix::fs::symlink(&actual_dir, tmp_dir.join(SYMLINK_PATH)).unwrap(); @@ -482,7 +482,7 @@ mod tests { #[tokio::test] async fn test_start_stop() { - let tmp_dir = TempDir::new("foo").unwrap().into_path(); + let tmp_dir = TempDir::with_prefix("foo").unwrap().into_path(); let (fut, _) = init_test_server(&tmp_dir).await; let (set, handle) = run_concurrent(fut, async { let mut session = get_client_session(&tmp_dir).await.unwrap(); @@ -494,7 +494,7 @@ mod tests { #[tokio::test] async fn test_stop_on_end_condition() { - let tmp_dir = TempDir::new("foo").unwrap().into_path(); + let tmp_dir = TempDir::with_prefix("foo").unwrap().into_path(); let (fut, notify) = init_test_server(&tmp_dir).await; notify.notify_one(); fut.await.unwrap(); diff --git a/crates/hyperqueue/src/server/event/log/read.rs b/crates/hyperqueue/src/server/event/log/read.rs index c5424d5e1..c7128c8bf 100644 --- a/crates/hyperqueue/src/server/event/log/read.rs +++ b/crates/hyperqueue/src/server/event/log/read.rs @@ -85,11 +85,11 @@ mod tests { use std::fs::{File, OpenOptions}; use std::io::Write; use tako::gateway::LostWorkerReason; - use tempdir::TempDir; + use tempfile::TempDir; #[test] fn read_empty_file() { - let tmpdir = TempDir::new("hq").unwrap(); + let tmpdir = TempDir::with_prefix("hq").unwrap(); let path = tmpdir.path().join("foo"); File::create(&path).unwrap(); @@ -98,7 +98,7 @@ mod tests { #[test] fn read_invalid_header_version() { - let tmpdir = TempDir::new("hq").unwrap(); + let tmpdir = TempDir::with_prefix("hq").unwrap(); let path = tmpdir.path().join("foo"); { let mut file = File::create(&path).unwrap(); @@ -110,7 +110,7 @@ mod tests { #[test] fn read_no_events() { - let tmpdir = TempDir::new("hq").unwrap(); + let tmpdir = TempDir::with_prefix("hq").unwrap(); let path = tmpdir.path().join("foo"); { let writer = EventLogWriter::create_or_append(&path, None).unwrap(); @@ -123,7 +123,7 @@ mod tests { #[test] fn test_not_fully_written_journal() { - let tmpdir = TempDir::new("hq").unwrap(); + let tmpdir = TempDir::with_prefix("hq").unwrap(); let path = tmpdir.path().join("foo"); { @@ -182,7 +182,7 @@ mod tests { #[test] fn roundtrip_exhaust_buffer() { - let tmpdir = TempDir::new("hq").unwrap(); + let tmpdir = TempDir::with_prefix("hq").unwrap(); let path = tmpdir.path().join("foo"); { @@ -215,7 +215,7 @@ mod tests { #[test] fn streaming_read_partial() { - let tmpdir = TempDir::new("hq").unwrap(); + let tmpdir = TempDir::with_prefix("hq").unwrap(); let path = tmpdir.path().join("foo"); let mut writer = EventLogWriter::create_or_append(&path, None).unwrap(); diff --git a/crates/hyperqueue/src/worker/start/program.rs b/crates/hyperqueue/src/worker/start/program.rs index 31da0bb29..2c7119203 100644 --- a/crates/hyperqueue/src/worker/start/program.rs +++ b/crates/hyperqueue/src/worker/start/program.rs @@ -11,7 +11,7 @@ use futures::future::Either; use futures::TryFutureExt; use nix::sys::signal; use nix::sys::signal::Signal; -use tempdir::TempDir; +use tempfile::TempDir; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::sync::oneshot; use tokio::sync::oneshot::Receiver; @@ -89,7 +89,7 @@ pub(super) fn build_program_task( pin_program(&mut program, build_ctx.allocation(), pin_mode, &build_ctx)?; let task_dir = if task_dir { - let task_dir = TempDir::new_in(&build_ctx.worker_configuration().work_dir, "t") + let task_dir = TempDir::with_prefix_in("t", &build_ctx.worker_configuration().work_dir) .map_err(|error| { format!( "Cannot create task_dir in worker's workdir at {}: {error:?}", diff --git a/crates/pyhq/Cargo.toml b/crates/pyhq/Cargo.toml index 3be7ab83f..9e4435c24 100644 --- a/crates/pyhq/Cargo.toml +++ b/crates/pyhq/Cargo.toml @@ -24,7 +24,7 @@ serde = { workspace = true } tokio = { workspace = true } anyhow = { workspace = true } log = { workspace = true } -tempdir = { workspace = true } +tempfile = { workspace = true } pyo3 = { version = "0.15", features = ["extension-module", "abi3", "abi3-py36", "anyhow", "serde"] } pyo3-asyncio = { version = "0.15", features = ["tokio-runtime", "attributes"] } diff --git a/crates/pyhq/src/cluster/mod.rs b/crates/pyhq/src/cluster/mod.rs index 331cf6fd8..306cc63f1 100644 --- a/crates/pyhq/src/cluster/mod.rs +++ b/crates/pyhq/src/cluster/mod.rs @@ -2,7 +2,7 @@ use crate::cluster::server::RunningServer; use crate::cluster::worker::RunningWorker; use anyhow::bail; use std::path::{Path, PathBuf}; -use tempdir::TempDir; +use tempfile::TempDir; pub mod server; mod worker; @@ -15,7 +15,8 @@ pub struct Cluster { impl Cluster { pub fn start(server_dir: Option) -> anyhow::Result { - let server_dir = server_dir.unwrap_or_else(|| TempDir::new("hq").unwrap().into_path()); + let server_dir = + server_dir.unwrap_or_else(|| TempDir::with_prefix("hq").unwrap().into_path()); let server = RunningServer::start(server_dir.clone())?; Ok(Self { server: Some(server), diff --git a/crates/tako/Cargo.toml b/crates/tako/Cargo.toml index 24aaac84f..6eeae3da5 100644 --- a/crates/tako/Cargo.toml +++ b/crates/tako/Cargo.toml @@ -40,7 +40,7 @@ derive_more = "0.99" [dev-dependencies] anyhow = { workspace = true } env_logger = { workspace = true } -tempdir = { workspace = true } +tempfile = { workspace = true } derive_builder = "0.11" criterion = { version = "0.3", features = ["html_reports"] } diff --git a/crates/tako/src/internal/tests/integration/utils/worker.rs b/crates/tako/src/internal/tests/integration/utils/worker.rs index f62ecdd15..f402f8d24 100644 --- a/crates/tako/src/internal/tests/integration/utils/worker.rs +++ b/crates/tako/src/internal/tests/integration/utils/worker.rs @@ -4,7 +4,6 @@ use std::path::PathBuf; use std::sync::Arc; use std::thread::JoinHandle; use std::time::Duration; -use tempdir::TempDir; use crate::internal::common::error::DsError; use crate::internal::common::resources::ResourceDescriptor; @@ -15,6 +14,7 @@ use crate::program::ProgramDefinition; use crate::worker::WorkerConfiguration; use derive_builder::Builder; use orion::auth::SecretKey; +use tempfile::TempDir; use tokio::io::AsyncWriteExt; use tokio::sync::Notify; use tokio::task::LocalSet; @@ -148,7 +148,7 @@ pub(super) async fn start_worker( ) -> anyhow::Result<(WorkerHandle, WorkerContext)> { let port = core_ref.get().get_worker_listen_port(); let (mut configuration, worker_secret_key) = create_worker_configuration(config); - let tmpdir = TempDir::new("tako").unwrap(); + let tmpdir = TempDir::with_prefix("tako")?; let workdir = tmpdir.path().to_path_buf().join("work"); let logdir = tmpdir.path().to_path_buf().join("logs");