• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

divviup / divviup-api / 8666760397

12 Apr 2024 07:02PM UTC coverage: 56.289% (+0.2%) from 56.083%
8666760397

Pull #968

github

web-flow
Merge 8c0857084 into a6cdbab81
Pull Request #968: Support for time bucketed fixed size

58 of 86 new or added lines in 8 files covered. (67.44%)

6 existing lines in 5 files now uncovered.

3692 of 6559 relevant lines covered (56.29%)

102.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/cli/src/tasks.rs
1
use crate::{CliResult, DetermineAccountId, Error, Output};
2
use clap::Subcommand;
3
use divviup_client::{DivviupClient, Histogram, NewTask, Uuid, Vdaf};
4
use humantime::Duration;
5

6
#[derive(clap::ValueEnum, Clone, Debug)]
7
pub enum VdafName {
8
    Count,
9
    Histogram,
10
    Sum,
11
    CountVec,
12
    SumVec,
13
}
14

15
#[derive(Subcommand, Debug)]
16
pub enum TaskAction {
17
    /// list all tasks for the target account
18
    List,
19

20
    /// create a new task for the target account
21
    Create {
22
        #[arg(long)]
23
        name: String,
×
24
        #[arg(long)]
25
        leader_aggregator_id: Uuid,
×
26
        #[arg(long)]
27
        helper_aggregator_id: Uuid,
×
28
        #[arg(long)]
29
        vdaf: VdafName,
×
30
        #[arg(long)]
31
        min_batch_size: u64,
×
32
        #[arg(long)]
33
        max_batch_size: Option<u64>,
34
        #[arg(long, requires = "max_batch_size")]
35
        batch_time_window_size_seconds: Option<u64>,
36
        #[arg(long)]
37
        time_precision: Duration,
×
38
        #[arg(long)]
39
        collector_credential_id: Uuid,
×
40
        #[arg(long, value_delimiter = ',')]
41
        categorical_buckets: Option<Vec<String>>,
×
42
        #[arg(long, value_delimiter = ',')]
43
        continuous_buckets: Option<Vec<u64>>,
×
44
        #[arg(long, required_if_eq_any([("vdaf", "count_vec"), ("vdaf", "sum_vec")]))]
45
        length: Option<u64>,
46
        #[arg(long, required_if_eq_any([("vdaf", "sum"), ("vdaf", "sum_vec")]))]
47
        bits: Option<u8>,
48
        #[arg(long)]
49
        chunk_length: Option<u64>,
50
    },
51

52
    /// rename a task
53
    Rename { task_id: String, name: String },
×
54

55
    /// retrieve the collector auth tokens for a task
56
    CollectorAuthTokens { task_id: String },
×
57
}
58

59
impl TaskAction {
60
    pub(crate) async fn run(
×
61
        self,
×
62
        account_id: DetermineAccountId,
×
63
        client: DivviupClient,
×
64
        output: Output,
×
65
    ) -> CliResult {
×
66
        let account_id = account_id.await?;
×
67

68
        match self {
×
69
            TaskAction::List => output.display(client.tasks(account_id).await?),
×
70
            TaskAction::Create {
71
                name,
×
72
                leader_aggregator_id,
×
73
                helper_aggregator_id,
×
74
                vdaf,
×
75
                min_batch_size,
×
76
                max_batch_size,
×
NEW
77
                batch_time_window_size_seconds,
×
78
                time_precision,
×
79
                collector_credential_id,
×
80
                categorical_buckets,
×
81
                continuous_buckets,
×
82
                length,
×
83
                bits,
×
84
                chunk_length,
×
85
            } => {
86
                let vdaf = match vdaf {
×
87
                    VdafName::Count => Vdaf::Count,
×
88
                    VdafName::Histogram => {
89
                        match (length, categorical_buckets, continuous_buckets) {
×
90
                            (Some(length), None, None) => Vdaf::Histogram(Histogram::Length {
×
91
                                length,
×
92
                                chunk_length,
×
93
                            }),
×
94
                            (None, Some(buckets), None) => {
×
95
                                Vdaf::Histogram(Histogram::Categorical {
×
96
                                    buckets,
×
97
                                    chunk_length,
×
98
                                })
×
99
                            }
100
                            (None, None, Some(buckets)) => Vdaf::Histogram(Histogram::Continuous {
×
101
                                buckets,
×
102
                                chunk_length,
×
103
                            }),
×
104
                            (None, None, None) => {
105
                                return Err(Error::Other("continuous-buckets, categorical-buckets, or length are required for histogram vdaf".into()));
×
106
                            }
107
                            _ => {
108
                                return Err(Error::Other("continuous-buckets, categorical-buckets, and length are mutually exclusive".into()));
×
109
                            }
110
                        }
111
                    }
112
                    VdafName::Sum => Vdaf::Sum {
×
113
                        bits: bits.unwrap(),
×
114
                    },
×
115
                    VdafName::CountVec => Vdaf::CountVec {
×
116
                        length: length.unwrap(),
×
117
                        chunk_length,
×
118
                    },
×
119
                    VdafName::SumVec => Vdaf::SumVec {
×
120
                        bits: bits.unwrap(),
×
121
                        length: length.unwrap(),
×
122
                        chunk_length,
×
123
                    },
×
124
                };
125

126
                let time_precision_seconds = time_precision.as_secs();
×
127

×
128
                let task = NewTask {
×
129
                    name,
×
130
                    leader_aggregator_id,
×
131
                    helper_aggregator_id,
×
132
                    vdaf,
×
133
                    min_batch_size,
×
134
                    max_batch_size,
×
NEW
135
                    batch_time_window_size_seconds,
×
136
                    time_precision_seconds,
×
137
                    collector_credential_id,
×
138
                };
×
139

×
140
                output.display(client.create_task(account_id, task).await?)
×
141
            }
142

143
            TaskAction::Rename { task_id, name } => {
×
144
                output.display(client.rename_task(&task_id, &name).await?)
×
145
            }
146

147
            TaskAction::CollectorAuthTokens { task_id } => {
×
148
                output.display(client.task_collector_auth_tokens(&task_id).await?)
×
149
            }
150
        }
151

152
        Ok(())
×
153
    }
×
154
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc