Skip to content

Commit

Permalink
Use Rust git2 to find submodule of transitland and update it
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Mar 20, 2024
1 parent 162858d commit 00f8ede
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ dmfr-folder-reader = {git = "https://github.com/catenarytransit/dmfr-folder-read
tokio-zookeeper = "0.2.1"
uuid = "1.8.0"
zip = "0.6.6"
git2 = "0.18.3"

[[bin]]
name = "maple"
Expand Down
33 changes: 32 additions & 1 deletion src/maple/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,45 @@ mod transitland_download;
use chateau::chateau;
use dmfr_folder_reader::read_folders;
use dmfr_folder_reader::ReturnDmfrAnalysis;
use git2::Repository;

use crate::transitland_download::DownloadedFeedsInformation;

async fn run_ingest() -> Result<(), Box<dyn Error>> {

const maple_ingestion_version: i32 = 1;

// TODO! Ensure git submodule transitland-atlas downloads and updates correctly
//Ensure git submodule transitland-atlas downloads and updates correctly
match Repository::open("./") {
Ok(repo) => {
match repo.find_submodule("transitland-atlas") {
Ok(transitland_submodule) => {
println!("Submodule found.");

let mut transitland_submodule = transitland_submodule;

match transitland_submodule.update(true, None) {
Ok(update) => {
println!("Submodule updated.");
},
Err(update_err) => {
eprintln!("Unable to update submodule");

// don't need to fail if can't reach github servers for now
}
}
},
Err(find_submodule) => {
eprintln!("Can't find submodule!");
return Err(Box::new(find_submodule));
}
}
},
Err(repo_err) => {
eprintln!("Can't find own repo!");
return Err(Box::new(repo_err));
}
}

//These feeds should be discarded because they are duplicated in a larger dataset called `f-sf~bay~area~rg`, which has everything in a single zip file
let feeds_to_discard: HashSet<&str> = HashSet::from_iter(vec![
Expand Down
2 changes: 1 addition & 1 deletion src/maple/transitland_download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub async fn download_return_eligible_feeds(
transitland_meta: &ReturnDmfrAnalysis,
pool: &sqlx::Pool<sqlx::Postgres>,
) -> Result<Vec<DownloadedFeedsInformation>, ()> {
let threads: usize = 16;
let threads: usize = 32;

let _ = fs::create_dir("gtfs_static_zips");

Expand Down

0 comments on commit 00f8ede

Please sign in to comment.