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

move argparse boilerplate code to private header #4169

Merged
merged 24 commits into from
Jul 4, 2023

Conversation

nilsnolde
Copy link
Member

@nilsnolde nilsnolde commented Jun 17, 2023

Removes a few lines of code by breaking out argparse stuff of the programs into a private header.

The PR is based on #4168

@nilsnolde
Copy link
Member Author

Apart from adding the utility function, what it generally does:

  • adds a i,--inline-config wherever it made sense (i.e. where -i wasn't taken yet and a config is needed)
  • made all programs parse the args consistently, e.g. how exceptions are handled, help strings etc.

kevinkreiser
kevinkreiser previously approved these changes Jun 20, 2023
Copy link
Member

@kevinkreiser kevinkreiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok so this supercedes the previous one but a couple things:

  • can we put the interface for the elevation get_tileids back to unordered_set
  • can we not use relative paths to include the private headers, looked like cmakelists already had the source dir has an include directory

options.allow_unrecognised_options();
std::string config_file;
int main(int argc, char** argv) {
const std::string program = "valhalla_add_elevation";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can get this by messing around with __FILE__ then you dont have to type every single one though i guess it has to be the name of the source file (which we do adhere to)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jep, that worked, thanks! made it a function in argparse_utils.h

@nilsnolde
Copy link
Member Author

@kevinkreiser

can we put the interface for the elevation get_tileids back to unordered_set

done

can we not use relative paths to include the private headers, looked like cmakelists already had the source dir has an include directory

had to adjust the CMakeLists.txt a bit and add the entire ./src to target_include_directories(), the VALHALLA_SOURCE_DIR is actually root of the repo, threw me off too..

…, we need to put the ./src directory to target_include_directories()
@nilsnolde nilsnolde force-pushed the nn--exe-boilerplate branch from cdd4fd7 to 9d81545 Compare June 21, 2023 22:16
@kevinkreiser kevinkreiser mentioned this pull request Aug 28, 2018
@nilsnolde nilsnolde requested a review from kevinkreiser June 23, 2023 14:14
if (basename.length() <= 3) {
return "";
}
basename.erase(basename.length() - 3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: are you sure you dont want to rfind '.', i know its pedantic but its robust to us one day changing from stupid .cc for to the more prevalent .cpp/.hpp

@@ -6,14 +6,14 @@

Copy link
Member

@kevinkreiser kevinkreiser Jun 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole file seems misplaced. could we just move the functions into an existing utils header?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn’t feel it’s fitting anywhere.. def not mjolnir, and it’s not really midgard material.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why dont we just delete this file entirely and then we can change the interface of elevationbuilder::build to take an unordered_set and make a dequeue out of it and check the filesystem etc if that is what it needs. just move the functionality into the main function, or, if it means testing is less verbose thats ok with me. rather have less random files hanging around tbh

@@ -228,6 +228,7 @@ TEST(ElevationBuilder, get_tile_ids) {
// check if config contains tile_dir
EXPECT_TRUE(valhalla::mjolnir::get_tile_ids(config, {"/0/003/196.gph"}).empty());

// TODO: I don't understand what the following lines have to do with anything?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

above this uses the default config, i suppose if on your local computer you had elevation data in the default location it would pick that up and change the result of this test. to avoid that the person removes this value so that it cant happen

@kevinkreiser
Copy link
Member

this looks done to me, i woul just remove the extra file and push that logic into elevationbuilder::build and call it a day

@kevinkreiser kevinkreiser merged commit b81a6c2 into master Jul 4, 2023
@kevinkreiser kevinkreiser deleted the nn--exe-boilerplate branch July 4, 2023 17:22
rapidjson::read_json(config.c_str(), pt);

// configure logging
valhalla::midgard::logging::Configure({{"type", "std_err"}, {"color", "true"}});
Copy link
Member

@kevinkreiser kevinkreiser Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops we wanted to keep this stderr #4496

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants