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

Automatically download data sets #760

Merged
merged 64 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
63505e7
WIP
maplant Mar 7, 2024
7186673
WIP
maplant Mar 7, 2024
8337ed2
Implement automatic downloading of data set files
maplant Mar 12, 2024
d6cc42c
Revert dump.rs
maplant Mar 12, 2024
3f924db
Merge remote-tracking branch 'origin/main' into map/download-data-sets
maplant Apr 3, 2024
0e06a9a
Fixes from merge
maplant Apr 3, 2024
1b7f80c
Fixes
maplant Apr 5, 2024
f7e650a
Fmt
maplant Apr 5, 2024
4795389
Merge remote-tracking branch 'origin/main' into map/download-data-sets
maplant Apr 5, 2024
a2ba1ab
Merge remote-tracking branch 'origin/main' into map/download-data-sets
maplant Apr 9, 2024
fdb3dc8
Lock the hexes table in order to prevent deadlock
maplant Apr 10, 2024
7e7c3a2
Remove check for new data sets daemon, slight refactor
maplant Apr 22, 2024
71977d5
Merge remote-tracking branch 'origin/main' into map/download-data-sets
maplant Apr 22, 2024
3426c0d
Shutdown downloaders instantly
maplant Apr 23, 2024
b0f602a
Refactor code a bit
maplant Apr 24, 2024
065e6cc
Move one more fn to db mod
maplant Apr 24, 2024
3f0bbda
Merge remote-tracking branch 'origin/main' into map/download-data-sets
maplant Apr 24, 2024
6d6d071
Merge remote-tracking branch 'origin/main' into map/download-data-sets
maplant Apr 24, 2024
ec569fe
Commit missed file
maplant Apr 24, 2024
789c93f
Move data set downloading to separate module
maplant Apr 26, 2024
f3519c6
Remove outdated comment
maplant Apr 26, 2024
49a742f
Address comments, fix some subtle bugs
maplant Apr 29, 2024
f54b623
Fix incorrect constant
maplant Apr 29, 2024
a4634f0
Add builder for HexAssignments
maplant Apr 29, 2024
2afa497
Add comments to settings
maplant Apr 29, 2024
d9783e4
Merge remote-tracking branch 'origin/main' into map/download-data-sets
maplant May 2, 2024
bc48465
Remove geofence validation specialization
maplant May 2, 2024
e745e42
Fix weird warning
maplant May 2, 2024
e3ef992
ugh
maplant May 3, 2024
4996d1b
I am shouting at my computer rn
maplant May 3, 2024
31433de
Clean up
maplant May 3, 2024
b398390
add migration
maplant May 3, 2024
6468175
Don't lock table, don't process data sets when one is missing
maplant May 3, 2024
f334f38
Remove clippy
maplant May 3, 2024
cd5fa35
Remove is ready check for processing, delete old data sets
maplant May 3, 2024
6837d48
Refactor
maplant May 6, 2024
e581208
Merge remote-tracking branch 'origin/main' into map/download-data-sets
maplant May 6, 2024
fc5d5d4
Use try_send instead of send
maplant May 6, 2024
ffe553e
Merge remote-tracking branch 'origin/main' into map/download-data-sets
maplant May 6, 2024
f95aef9
Clippy and tests
maplant May 6, 2024
fcbd3ae
Fix tests
maplant May 6, 2024
b2ed62c
Address comments
maplant May 7, 2024
9f381ee
Move first fill to inside is_ready check
maplant May 7, 2024
94ce2a2
Move second in as well
maplant May 7, 2024
65de9ab
Change check_for_unprocessed_data_sets query
maplant May 7, 2024
7938cdf
Fix up a bit
maplant May 9, 2024
1367c27
Make clippy happy
bbalser May 14, 2024
9cc4cc6
Fix downloading
maplant May 14, 2024
7e447ab
Switch to not exists and fix path deletion
maplant May 14, 2024
bf83fb4
Fix migration
maplant May 15, 2024
198a838
Move things around
maplant May 15, 2024
f46c818
Fix up tests, address comments
maplant May 16, 2024
3a7a966
Merge remote-tracking branch 'origin/main' into map/download-data-sets
maplant May 16, 2024
a922849
use sleep_until
maplant May 17, 2024
902e62f
Wrap coverage obj notification in struct
maplant May 17, 2024
8cae6d0
Merge remote-tracking branch 'origin/main' into map/download-data-sets
maplant May 17, 2024
4b45c1c
Ahhh... that's better
maplant May 17, 2024
8ebb8c1
Fix
maplant May 17, 2024
c1a3f96
rename data_sets table to hex_assignments_data_set_status
maplant May 20, 2024
dc8a57d
Add footfall comment
maplant May 20, 2024
440776c
Remove allow dead code from tests per moogey
maplant May 20, 2024
6c65b8b
Nevermind
maplant May 20, 2024
01b787c
Make data set downloader poll duration a setting
maplant May 20, 2024
26d7c25
Change migration
maplant May 20, 2024
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
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ itertools = "*"
tokio-util = "0"
uuid = { version = "1", features = ["v4", "serde"] }
tower-http = { version = "0", features = ["trace"] }
derive_builder = "0"

[patch.crates-io]
sqlx = { git = "https://github.com/helium/sqlx.git", rev = "92a2268f02e0cac6fccb34d3e926347071dbb88d" }
2 changes: 1 addition & 1 deletion file_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ base64 = {workspace = true}
beacon = {workspace = true}
sqlx = {workspace = true, optional = true}
async-trait = {workspace = true}
derive_builder = "0"
derive_builder = {workspace = true}
retainer = {workspace = true}
uuid = {workspace = true}
h3o = {workspace = true}
Expand Down
15 changes: 15 additions & 0 deletions file_store/src/file_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ pub const COVERAGE_OBJECT_INGEST_REPORT: &str = "coverage_object_ingest_report";
pub const SENIORITY_UPDATE: &str = "seniority_update";
pub const BOOSTED_HEX_UPDATE: &str = "boosted_hex_update";
pub const ORACLE_BOOSTING_REPORT: &str = "oracle_boosting_report";
pub const URBANIZATION_DATA_SET: &str = "urbanization";
pub const FOOTFALL_DATA_SET: &str = "footfall";
pub const LANDTYPE_DATA_SET: &str = "landtype";

#[derive(Debug, PartialEq, Eq, Clone, Serialize, Copy, strum::EnumCount)]
#[serde(rename_all = "snake_case")]
Expand Down Expand Up @@ -200,6 +203,9 @@ pub enum FileType {
RadioThresholdReq,
RadioThresholdIngestReport,
VerifiedRadioThresholdIngestReport,
UrbanizationDataSet,
maplant marked this conversation as resolved.
Show resolved Hide resolved
FootfallDataSet,
LandtypeDataSet,
InvalidatedRadioThresholdReq,
InvalidatedRadioThresholdIngestReport,
VerifiedInvalidatedRadioThresholdIngestReport,
Expand Down Expand Up @@ -261,6 +267,9 @@ impl fmt::Display for FileType {
Self::SeniorityUpdate => SENIORITY_UPDATE,
Self::BoostedHexUpdate => BOOSTED_HEX_UPDATE,
Self::OracleBoostingReport => ORACLE_BOOSTING_REPORT,
Self::UrbanizationDataSet => URBANIZATION_DATA_SET,
Self::FootfallDataSet => FOOTFALL_DATA_SET,
Self::LandtypeDataSet => LANDTYPE_DATA_SET,
};
f.write_str(s)
}
Expand Down Expand Up @@ -322,6 +331,9 @@ impl FileType {
Self::SeniorityUpdate => SENIORITY_UPDATE,
Self::BoostedHexUpdate => BOOSTED_HEX_UPDATE,
Self::OracleBoostingReport => ORACLE_BOOSTING_REPORT,
Self::UrbanizationDataSet => URBANIZATION_DATA_SET,
Self::FootfallDataSet => FOOTFALL_DATA_SET,
Self::LandtypeDataSet => LANDTYPE_DATA_SET,
}
}
}
Expand Down Expand Up @@ -383,6 +395,9 @@ impl FromStr for FileType {
SENIORITY_UPDATE => Self::SeniorityUpdate,
BOOSTED_HEX_UPDATE => Self::BoostedHexUpdate,
ORACLE_BOOSTING_REPORT => Self::OracleBoostingReport,
URBANIZATION_DATA_SET => Self::UrbanizationDataSet,
FOOTFALL_DATA_SET => Self::FootfallDataSet,
LANDTYPE_DATA_SET => Self::LandtypeDataSet,
_ => return Err(Error::from(io::Error::from(io::ErrorKind::InvalidInput))),
};
Ok(result)
Expand Down
5 changes: 4 additions & 1 deletion mobile_verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ authors.workspace = true

[dependencies]
anyhow = {workspace = true}
async-compression = {version = "0", features = ["tokio", "gzip"]}
config = {workspace = true}
thiserror = {workspace = true}
serde = {workspace = true}
Expand Down Expand Up @@ -36,7 +37,8 @@ humantime = {workspace = true}
rust_decimal = {workspace = true}
rust_decimal_macros = {workspace = true}
tonic = {workspace = true}
tokio-stream = { workspace = true }
tokio-stream = {workspace = true}
tokio-util = {workspace = true}
metrics = {workspace = true}
metrics-exporter-prometheus = {workspace = true}
mobile-config = {path = "../mobile_config"}
Expand All @@ -51,6 +53,7 @@ retainer = {workspace = true}
uuid = {workspace = true}
task-manager = {path = "../task_manager"}
solana-sdk = {workspace = true}
derive_builder = {workspace = true}

[dev-dependencies]
backon = "0"
18 changes: 18 additions & 0 deletions mobile_verifier/migrations/33_data_sets.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TYPE data_set_status AS enum (
'pending',
'downloaded',
'processed'
);

CREATE TYPE data_set_type AS enum (
'urbanization',
'footfall',
'landtype'
);

CREATE TABLE data_sets (
maplant marked this conversation as resolved.
Show resolved Hide resolved
filename TEXT PRIMARY KEY,
data_set data_set_type NOT NULL,
time_to_use TIMESTAMPTZ NOT NULL,
status data_set_status NOT NULL
);
55 changes: 54 additions & 1 deletion mobile_verifier/src/boosting_oracles/assignment.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use anyhow::Result;
use helium_proto::services::poc_mobile::oracle_boosting_hex_assignment::Assignment as ProtoAssignment;
use rust_decimal::Decimal;
use rust_decimal_macros::dec;
use std::fmt;

use super::HexAssignment;

#[derive(Debug, Clone, PartialEq, Eq, sqlx::FromRow)]
pub struct HexAssignments {
pub footfall: Assignment,
Expand Down Expand Up @@ -58,11 +61,20 @@ impl fmt::Display for Assignment {
}

impl HexAssignments {
pub fn builder(cell: hextree::Cell) -> HexAssignmentsBuilder {
HexAssignmentsBuilder {
cell,
footfall: None,
landtype: None,
urbanized: None,
}
}

pub fn boosting_multiplier(&self) -> Decimal {
let HexAssignments {
footfall,
urbanized,
landtype,
urbanized,
} = self;

use Assignment::*;
Expand Down Expand Up @@ -97,6 +109,47 @@ impl HexAssignments {
}
}

pub struct HexAssignmentsBuilder {
cell: hextree::Cell,
footfall: Option<Result<Assignment>>,
maplant marked this conversation as resolved.
Show resolved Hide resolved
landtype: Option<Result<Assignment>>,
urbanized: Option<Result<Assignment>>,
}

impl HexAssignmentsBuilder {
pub fn footfall(mut self, footfall: &impl HexAssignment) -> Self {
self.footfall = Some(footfall.assignment(self.cell));
self
}

pub fn landtype(mut self, landtype: &impl HexAssignment) -> Self {
self.landtype = Some(landtype.assignment(self.cell));
self
}

pub fn urbanized(mut self, urbanized: &impl HexAssignment) -> Self {
self.urbanized = Some(urbanized.assignment(self.cell));
self
}

pub fn build(self) -> anyhow::Result<HexAssignments> {
let Some(footfall) = self.footfall else {
anyhow::bail!("footfall assignment not set");
};
let Some(landtype) = self.landtype else {
anyhow::bail!("landtype assignment not set");
};
let Some(urbanized) = self.urbanized else {
anyhow::bail!("urbanized assignment not set");
};
Ok(HexAssignments {
footfall: footfall?,
urbanized: urbanized?,
landtype: landtype?,
})
}
}

#[cfg(test)]
impl HexAssignments {
pub fn test_best() -> Self {
Expand Down
Loading
Loading