Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 004888f

Browse files
committed
Option for disabling autodetection
1 parent 3c9912f commit 004888f

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/hyperqueue/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ indicatif = "0.16.2"
4747
textwrap = "0.14"
4848

4949
# Tako
50-
tako = { path = "../../../tako", default-features = false }
51-
# tako = { git = "https://github.com/spirali/tako", branch = "main", default-features = false }
50+
# tako = { path = "../../../tako", default-features = false }
51+
tako = { git = "https://github.com/spirali/tako", branch = "main", default-features = false }
5252

5353
# Optional dependencies
5454
jemallocator = { version = "0.3.2", optional = true }

crates/hyperqueue/src/worker/start.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ pub struct WorkerStartOpts {
8585
#[clap(long, setting = clap::ArgSettings::MultipleOccurrences)]
8686
resource: Vec<String>,
8787

88+
#[clap(long = "no-detect-resources")]
89+
/// Disable auto-detection of resources
90+
no_detect_resources: bool,
91+
8892
/// How often should the worker announce its existence to the server. (default: "8s")
8993
#[clap(long, default_value = "8s")]
9094
heartbeat: ArgDuration,
@@ -479,9 +483,15 @@ fn gather_configuration(opts: WorkerStartOpts) -> anyhow::Result<WorkerConfigura
479483
.map(|cpus| parse_cpu_definition(&cpus))
480484
.unwrap_or_else(detect_cpus)?;
481485

482-
let mut generic = detect_generic_resource()?;
486+
let mut generic = if opts.no_detect_resources {
487+
Vec::new()
488+
} else {
489+
detect_generic_resource()?
490+
};
483491
for resource_def in opts.resource {
484-
generic.push(parse_resource_definition(&resource_def)?)
492+
let descriptor = parse_resource_definition(&resource_def)?;
493+
generic.retain(|desc| desc.name != descriptor.name);
494+
generic.push(descriptor)
485495
}
486496

487497
let resources = ResourceDescriptor::new(cpus, generic);

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def start_worker(
164164
self.server_dir,
165165
"worker",
166166
"start",
167+
"--no-detect-resources", # Ignore resources on testing machine
167168
]
168169
hostname = f"worker{worker_id}"
169170
if set_hostname:

0 commit comments

Comments
 (0)