Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #745

Merged
merged 2 commits into from
Sep 3, 2024
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
214 changes: 97 additions & 117 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -53,4 +52,4 @@ panic = "abort"
inherits = "release"
lto = true
codegen-units = 1
debug = "line-tables-only"
debug = "line-tables-only"
2 changes: 1 addition & 1 deletion crates/hyperqueue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions crates/hyperqueue/src/client/commands/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -245,7 +245,7 @@ fn gather_configuration(opts: WorkerStartOpts) -> anyhow::Result<WorkerConfigura
resources.validate()?;

let (work_dir, log_dir) = {
let tmpdir = TempDir::new("hq-worker").unwrap().into_path();
let tmpdir = TempDir::with_prefix("hq-worker")?.into_path();
(
work_dir.unwrap_or_else(|| tmpdir.join("work")),
tmpdir.join("logs"),
Expand Down
22 changes: 12 additions & 10 deletions crates/hyperqueue/src/common/serverdir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,15 @@ pub fn load_client_access_file<P: AsRef<Path>>(path: P) -> crate::Result<ClientA

#[cfg(test)]
mod tests {
use std::fs::DirEntry;
use std::path::PathBuf;
use std::sync::Arc;
use tempdir::TempDir;

use crate::common::serverdir::{
create_new_server_dir, load_client_access_file, load_worker_access_file,
store_access_record, ConnectAccessRecordPart, FullAccessRecord,
};
use crate::transfer::auth::generate_key;
use std::fs::DirEntry;
use std::path::PathBuf;
use std::sync::Arc;
use tempfile::TempDir;

#[test]
fn test_store_load() {
Expand All @@ -317,7 +316,10 @@ mod tests {
},
"testHQ".into(),
);
let path = TempDir::new("foo").unwrap().into_path().join("access.json");
let path = TempDir::with_prefix("foo")
.unwrap()
.into_path()
.join("access.json");
store_access_record(&record, path.clone()).unwrap();
let loaded = load_worker_access_file(&path).unwrap();
assert_eq!(loaded.version, record.version);
Expand All @@ -334,15 +336,15 @@ mod tests {

#[test]
fn test_server_dir_start_at_one() {
let path = TempDir::new("foo").unwrap();
let path = TempDir::with_prefix("foo").unwrap();
create_new_server_dir(path.as_ref()).unwrap();
let entry = std::fs::read_dir(&path).unwrap().next().unwrap().unwrap();
assert_eq!(entry.file_name().to_str().unwrap(), "001");
}

#[test]
fn test_server_dir_find_max_id() {
let path = TempDir::new("foo").unwrap();
let path = TempDir::with_prefix("foo").unwrap();
std::fs::create_dir_all(PathBuf::from(path.path()).join("001")).unwrap();
std::fs::create_dir_all(PathBuf::from(path.path()).join("002")).unwrap();
std::fs::create_dir_all(PathBuf::from(path.path()).join("003")).unwrap();
Expand All @@ -360,7 +362,7 @@ mod tests {

#[test]
fn test_server_dir_find_max_id_without_zero_padding() {
let path = TempDir::new("foo").unwrap();
let path = TempDir::with_prefix("foo").unwrap();
std::fs::create_dir_all(PathBuf::from(path.path()).join("1")).unwrap();
std::fs::create_dir_all(PathBuf::from(path.path()).join("3")).unwrap();
std::fs::create_dir_all(PathBuf::from(path.path()).join("8")).unwrap();
Expand All @@ -372,7 +374,7 @@ mod tests {

#[test]
fn test_server_dir_find_max_id_no_number() {
let path = TempDir::new("foo").unwrap();
let path = TempDir::with_prefix("foo").unwrap();
std::fs::create_dir_all(PathBuf::from(path.path()).join("a")).unwrap();
std::fs::create_dir_all(PathBuf::from(path.path()).join("b")).unwrap();
std::fs::create_dir_all(PathBuf::from(path.path()).join("c")).unwrap();
Expand Down
14 changes: 6 additions & 8 deletions crates/hyperqueue/src/server/autoalloc/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use std::path::PathBuf;
use std::time::SystemTime;

use futures::future::join_all;
use tempdir::TempDir;

use tako::WorkerId;
use tako::{Map, Set};
use tempfile::TempDir;

use crate::common::manager::info::{ManagerInfo, ManagerType};
use crate::common::rpc::RpcReceiver;
Expand Down Expand Up @@ -177,7 +176,7 @@ async fn handle_message(
}

pub async fn try_submit_allocation(params: AllocationQueueParams) -> anyhow::Result<()> {
let tmpdir = TempDir::new("hq")?;
let tmpdir = TempDir::with_prefix("hq")?;
let mut handler = create_allocation_handler(
&params.manager,
params.name.clone(),
Expand Down Expand Up @@ -877,15 +876,14 @@ mod tests {
use anyhow::anyhow;
use derive_builder::Builder;
use smallvec::smallvec;
use tempdir::TempDir;

use tako::gateway::{
LostWorkerReason, ResourceRequest, ResourceRequestEntry, ResourceRequestVariants,
};
use tako::program::ProgramDefinition;
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};
Expand Down Expand Up @@ -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()
};

Expand Down Expand Up @@ -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(
Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions crates/hyperqueue/src/server/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
14 changes: 7 additions & 7 deletions crates/hyperqueue/src/server/event/log/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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");

{
Expand Down Expand Up @@ -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");

{
Expand Down Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions crates/hyperqueue/src/worker/start/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:?}",
Expand Down
2 changes: 1 addition & 1 deletion crates/pyhq/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
5 changes: 3 additions & 2 deletions crates/pyhq/src/cluster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +15,8 @@ pub struct Cluster {

impl Cluster {
pub fn start(server_dir: Option<PathBuf>) -> anyhow::Result<Self> {
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),
Expand Down
4 changes: 2 additions & 2 deletions crates/tako/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ psutil = { workspace = true }

hashbrown = { version = "0.14", features = ["serde", "inline-more"], default-features = false }
tracing-subscriber = { version = "0.3", features = ["json"] }
priority-queue = "1"
priority-queue = "2"
bitflags = "2"
fxhash = "0.2"
thin-vec = "0.2"
Expand All @@ -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"] }

Expand Down
4 changes: 2 additions & 2 deletions crates/tako/src/internal/tests/integration/utils/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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");

Expand Down
Loading