Skip to content

Commit b9585f8

Browse files
committed
treewide: Upgrade to clap 4.2.1
Upgrade the clap crate everywhere to version 4.2.1, updating usage of backwards-incompatible APIs along the way. Some highlights: - Many enums are now just deriving ValueEnum, as the new version of the previous method of using `FromStr` and `possible_values` is much clunkier than before. - Some values used in clap args now are required to derive Clone - We have to either avoid automatically creating arg groups for structs that are `#[clap(flatten)]`ed, or give them a unique name with `#[group(id = ...)]`, or clap will give us an error that the groups are not unique. - Arg names now use underscores instead of dashes when referenced from other args Also, to keep the single-version-policy intact, a couple of other dependencies had to update: - rustyline in readyset_repl, to update linux-raw-sys - console treewide - indicatif treewide Unfortunately the latest version of nperf-core depends on an older version of the `syn` crate than clap uses, so there's nothing we can do there and we just have to ignore it here. Change-Id: I4f353294c85ebd1d494537baa16d3b2e797bec69 Reviewed-on: https://gerrit.readyset.name/c/readyset/+/4660 Tested-by: Buildkite CI Reviewed-by: Dan Wilbanks <[email protected]>
1 parent 411dab3 commit b9585f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+675
-543
lines changed

Cargo.lock

Lines changed: 472 additions & 372 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benchmarks/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ vec1 = "1.8.0"
2121
url = "2.2.2"
2222
hdrhistogram = "7.4"
2323
zipf = "7.0.0"
24-
clap = { version = "3.0", features = ["derive", "env"] }
24+
clap = { version = "4.2", features = ["derive", "env"] }
2525
reqwest = { version = "0.11", features = ["stream", "native-tls"] }
2626
chrono = "0.4"
2727
atomic-counter = "1.0.1"
@@ -38,7 +38,7 @@ lazy_static = "1.4.0"
3838
thiserror = "1.0.30"
3939
async-stream = "0.3.2"
4040
parking_lot = "0.11.2"
41-
indicatif = "0.16"
41+
indicatif = "0.17"
4242
prometheus-parse = "0.2.2"
4343
walkdir = "2.3"
4444
tokio-postgres = { workspace = true }

benchmarks/src/benchmark.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,11 @@ pub struct DeploymentParameters {
9494

9595
/// Target database connection string. This is the database in the deployment
9696
/// we are benchmarking operations against.
97-
#[clap(
98-
long,
99-
env = "TARGET_CONN_STR",
100-
default_value = "",
101-
required_unless_present("deployment")
102-
)]
97+
#[clap(long, env = "TARGET_CONN_STR", default_value = "")]
10398
pub target_conn_str: String,
10499

105100
/// Setup database connection string.
106-
#[clap(
107-
long,
108-
env = "SETUP_CONN_STR",
109-
default_value = "",
110-
required_unless_present("deployment")
111-
)]
101+
#[clap(long, env = "SETUP_CONN_STR", default_value = "")]
112102
pub setup_conn_str: String,
113103

114104
#[clap(long)]

benchmarks/src/bin/extend_recipe.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ use readyset_data::Dialect;
99
struct ExtendRecipe {
1010
#[clap(short, long, env("AUTHORITY_ADDRESS"), default_value("127.0.0.1:2181"))]
1111
authority_address: String,
12-
#[clap(long, env("AUTHORITY"), default_value("zookeeper"), possible_values = &["consul", "zookeeper"])]
12+
#[clap(
13+
long,
14+
env("AUTHORITY"),
15+
default_value("zookeeper"),
16+
value_parser = ["consul", "zookeeper"]
17+
)]
1318
authority: AuthorityType,
1419
#[clap(short, long, env("DEPLOYMENT"))]
1520
deployment: String,

benchmarks/src/bin/extend_recipe_write_prop.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use clap::builder::NonEmptyStringValueParser;
12
use clap::Parser;
23
use readyset_client::consensus::AuthorityType;
34
use readyset_client::recipe::changelist::ChangeList;
@@ -9,9 +10,14 @@ use readyset_data::Dialect;
910
struct ExtendRecipeWritePropagation {
1011
#[clap(short, long, env("AUTHORITY_ADDRESS"), default_value("127.0.0.1:2181"))]
1112
authority_address: String,
12-
#[clap(long, env("AUTHORITY"), default_value("zookeeper"), possible_values = &["consul", "zookeeper"])]
13+
#[clap(
14+
long,
15+
env("AUTHORITY"),
16+
default_value("zookeeper"),
17+
value_parser = ["consul", "zookeeper"]
18+
)]
1319
authority: AuthorityType,
14-
#[clap(short, long, env("DEPLOYMENT"), forbid_empty_values = true)]
20+
#[clap(short, long, env("DEPLOYMENT"), value_parser = NonEmptyStringValueParser::new())]
1521
deployment: String,
1622
}
1723

benchmarks/src/bin/query_slammer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use readyset_data::DfValue;
1010
#[derive(Parser, Debug)]
1111
struct Opts {
1212
/// SQL endpoint to connect to
13-
#[clap(env = "DATABASE_URL", parse(try_from_str))]
13+
#[clap(env = "DATABASE_URL")]
1414
database_url: DatabaseURL,
1515

1616
/// Number of greenthreads to run hitting the database

benchmarks/src/bin/reader.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::time::{Duration, Instant};
44
use std::{env, fs, mem};
55

66
use anyhow::Result;
7-
use clap::{ArgEnum, Parser};
7+
use clap::{Parser, ValueEnum};
88
use database_utils::{DatabaseConnection, DatabaseURL};
99
use rand::distributions::{Distribution, Uniform};
1010
use rand::prelude::*;
@@ -16,7 +16,7 @@ use vec1::Vec1;
1616

1717
static THREAD_UPDATE_INTERVAL: Duration = Duration::from_secs(10);
1818

19-
#[derive(Clone, ArgEnum)]
19+
#[derive(Clone, ValueEnum)]
2020
enum Dist {
2121
Uniform,
2222
Zipf,
@@ -33,7 +33,13 @@ struct NoriaClientOpts {
3333
)]
3434
authority_address: String,
3535

36-
#[clap(long, env("AUTHORITY"), required_if_eq("database-type", "noria"), default_value("zookeeper"), possible_values = &["consul", "zookeeper"])]
36+
#[clap(
37+
long,
38+
env("AUTHORITY"),
39+
required_if_eq("database-type", "noria"),
40+
default_value("zookeeper"),
41+
value_parser = ["consul", "zookeeper"]
42+
)]
3743
authority: AuthorityType,
3844

3945
#[clap(
@@ -72,7 +78,7 @@ struct MySqlOpts {
7278
nparams: Option<usize>,
7379
}
7480

75-
#[derive(Clone, ArgEnum)]
81+
#[derive(Clone, Copy, ValueEnum)]
7682
enum DatabaseType {
7783
Noria,
7884
MySql,
@@ -104,7 +110,7 @@ struct Reader {
104110
///
105111
/// 'zipf' - sample pattern is skewed such that 90% of accesses are for 10% of the ids (Zipf;
106112
/// α=1.15)
107-
#[clap(arg_enum, default_value = "uniform")]
113+
#[clap(default_value = "uniform")]
108114
distribution: Dist,
109115

110116
/// Override the default alpha parameter for the zipf distribution
@@ -119,7 +125,7 @@ struct Reader {
119125
/// The type of database the client is connecting to. This determines
120126
/// the set of opts that should be populated. See `noria_opts` and
121127
/// `mysql_opts`.
122-
#[clap(arg_enum, default_value = "noria")]
128+
#[clap(default_value = "noria")]
123129
database_type: DatabaseType,
124130

125131
/// The set of options to be specified by the user to connect via a

benchmarks/src/bin/write_propagation.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use std::time::{Duration, Instant};
2323

2424
use benchmarks::utils::generate::load_to_backend;
2525
use benchmarks::utils::spec::{DatabaseGenerationSpec, DatabaseSchema};
26+
use clap::builder::NonEmptyStringValueParser;
2627
use clap::{Parser, ValueHint};
2728
use nom_sql::Relation;
2829
use query_generator::ColumnGenerationSpec;
@@ -56,10 +57,10 @@ struct Writer {
5657
#[clap(short, long, env("AUTHORITY_ADDRESS"), default_value("127.0.0.1:2181"))]
5758
authority_address: String,
5859

59-
#[clap(long, env("AUTHORITY"), default_value("zookeeper"), possible_values = &["consul", "zookeeper"])]
60+
#[clap(long, env("AUTHORITY"), default_value("zookeeper"), value_parser = ["consul", "zookeeper"])]
6061
authority: AuthorityType,
6162

62-
#[clap(short, long, env("DEPLOYMENT"), forbid_empty_values = true)]
63+
#[clap(short, long, env("DEPLOYMENT"), value_parser = NonEmptyStringValueParser::new())]
6364
deployment: String,
6465

6566
/// Path to the news app data model SQL schema.

benchmarks/src/eviction_benchmark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub struct EvictionBenchmark {
6464
/// The duration, specified as the number of seconds that the benchmark
6565
/// should be running. If `None` is provided, the benchmark will run
6666
/// until it is interrupted.
67-
#[clap(long, parse(try_from_str = crate::utils::seconds_as_str_to_duration))]
67+
#[clap(long, value_parser = crate::utils::seconds_as_str_to_duration)]
6868
run_for: Option<Duration>,
6969

7070
/// Attempt to scale down query range from query_spec in order to hit the desired

benchmarks/src/fallback_benchmark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub struct FallbackBenchmark {
4646
/// The duration, specified as the number of seconds that the benchmark
4747
/// should be running. If `None` is provided, the benchmark will run
4848
/// until it is interrupted.
49-
#[clap(long, parse(try_from_str = crate::utils::seconds_as_str_to_duration), default_value="30")]
49+
#[clap(long, value_parser = crate::utils::seconds_as_str_to_duration, default_value="30")]
5050
run_for: Duration,
5151

5252
/// Whether fallback cache should be enabled for this benchmark

0 commit comments

Comments
 (0)