-
Notifications
You must be signed in to change notification settings - Fork 0
Dev_cli_tool --> Main (#7, #20) #55
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c20c5e6
Cli tool initial commit (#7)
SamuelPalmhager 4603dd7
Second commit of cli_cpp_tool
SamuelPalmhager 6ed1511
Complete cpp_cli_tool file as according to DoD
SamuelPalmhager ca9d613
Commit for run_pipeline.sh including changes to data_cleaner (#20)
SamuelPalmhager 994bffb
Commit before integrating report generator (#20)
SamuelPalmhager c310c24
Functional pipeline for one input file, hardcoded in libs/math/build …
SamuelPalmhager 5c6e4fd
Completed pipeline with hardcoded inputfile for rule, to run: bash sc…
SamuelPalmhager b6b88c8
Included build files for the output folder, needed for the ci.yml to …
SamuelPalmhager 8dc3ead
Reverted change of defs.bzl (#20)
SamuelPalmhager 2f8b444
Resolved comments from Xin (#20)
SamuelPalmhager 6ef2b03
Fixes for ci (#20)
SamuelPalmhager 196633a
Permission fix for ci (#20)
SamuelPalmhager fdf33c9
Commit to fix ci filepath normalization in data_cleaner (#20)
SamuelPalmhager a57a51d
Commit for fixing ci (#20)
SamuelPalmhager 1079a58
Fixed CI, part 2 (#20)
RaphaelRevivor 96f7e95
Delete unecessary filegroup (#20)
RaphaelRevivor 212e0b8
Merge branch 'main' into dev_cli_tool
RaphaelRevivor b0a7397
Resolve CI issues and update ci yml file (#20)
RaphaelRevivor bc3fbb5
Fix CI issues, hopfully final (#20)
RaphaelRevivor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,14 @@ | ||
| cc_library( | ||
|
|
||
| ) | ||
| cc_binary( | ||
| name = "cli", | ||
| srcs = ["cli.cc"], | ||
| deps = [ | ||
| "//libs/parser:parser_factory", | ||
| "//libs/math:stats", | ||
| "@bazel_tools//tools/cpp/runfiles", | ||
| ], | ||
| visibility = ["//scripts:__subpackages__"], | ||
|
|
||
| data = ["//tests/python:testdata"], | ||
|
|
||
| ) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /** | ||
| * This should accept file path + type, use factory parser, run statistics, print summary. | ||
| * | ||
| * DoD: | ||
| * bazel run //apps/cpp_cli_tool:cli -- data.csv works. | ||
| * Console output includes mean, median, variance, frequencies. | ||
| * | ||
| */ | ||
|
|
||
| #include <iostream> | ||
| #include <string> | ||
| #include <iomanip> | ||
|
|
||
| #include "tools/cpp/runfiles/runfiles.h" | ||
| #include "libs/parser/parser_factory.h" | ||
| #include "libs/math/stats.h" | ||
|
|
||
|
|
||
| /** | ||
| * main function for CLI tool. Call by running bazel run //apps/cpp_cli_tool:cli --<filepath> | ||
| * @param argc argument count, @param argv an array of C strings (the arguments themselves) | ||
| * @return 0 on success, 1 on failure | ||
| */ | ||
|
|
||
| int main(int argc, char* argv[]){ | ||
| if(argc < 2){ | ||
| std::cout << "Usage: mytool <filepath>" << std::endl; | ||
| return 1; | ||
| } | ||
| std::string filename = argv[1]; | ||
| std::string filetype = filename.substr(filename.find_last_of(".") + 1); | ||
|
|
||
| std::string err; | ||
| auto runfiles(bazel::tools::cpp::runfiles::Runfiles::Create(argv[0], &err)); | ||
| if (runfiles == nullptr) { | ||
| std::cerr << "Error initializing runfiles: " << err << std::endl; | ||
| return 1; | ||
| } | ||
|
|
||
| std::string filepath = runfiles->Rlocation(filename); //<-- Will cause a seg fault if runfiles==nullptr :( | ||
|
|
||
|
|
||
| //Create parser w. parserfactory | ||
| static shared_ptr<Parser> parserPtr; | ||
| parserPtr = ParserFactory(filetype); //Evaluates to csv or json parser | ||
|
|
||
| parserPtr->parse(filepath); //Parses the file | ||
|
|
||
| Stats stats = Stats(); | ||
|
|
||
| stats.readData(parserPtr->getEntries()); // Should pass in correct datatype | ||
| stats.loadScores(); | ||
| std::cout << "\n\n\n"; | ||
|
|
||
| std::cout << std::setfill('=') << std::setw(25 + strlen("SCORES-STATISTICS")) << "SCORES-STATISTICS" << std::setw(25) << '\n'; | ||
| std::cout << std::setfill(' ') << "Mean: " << stats.calcMean() << std::setw(strlen("Median: ") + 2); | ||
| std::cout << "Median: " << stats.calcMedian() << std::setw(strlen("Variance: " + 2)) << " Variance: " << stats.calcVariance(); | ||
| std::cout << std::setw(strlen("Standard deviation: ") + 2) << " Standard deviation: " << stats.calcStandardDeviation(); | ||
|
|
||
| auto data = parserPtr->getEntries(); | ||
| std::vector<int> scores {}; | ||
|
|
||
| for (size_t i = 0; i < data.size(); i++) | ||
| { | ||
| auto entry = parserPtr->getEntryById(std::to_string(i+1)); | ||
| for (auto &&[k, v]: entry) | ||
| { | ||
| if(k == "score"){ | ||
| scores.push_back(std::stoi(v)); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if(stats.calcMode().size() == scores.size()){ | ||
| std::cout << std::setw(strlen("No identifiable mode") + 2) << "No identifiable mode"; | ||
| }else{ | ||
| std::cout << std::setw(strlen("Mode: ") + 2) << "Mode: " << stats.calcMode()[0]; | ||
| } | ||
| std::cout << "\n" << std::endl; | ||
|
|
||
| std::cout << std::setfill('=') << std::setw(25 + strlen("FREQUENCIES-OF-SCORES")) << "FREQUENCIES-OF-SCORES" << std::setw(25) << "\n"; | ||
| for (auto &&[k,v] : stats.calcFrequencies()) | ||
| { | ||
| std::cout << k << " appeared " << v << " time(s) "; | ||
| } | ||
| std::cout << std::endl; | ||
| std::cout << "\n\n"; | ||
|
|
||
|
|
||
|
|
||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
|
RaphaelRevivor marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| exports_files(glob(allow_empty=True, include=["*.csv", "*.json"])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| sh_library( | ||
| name = "run_pipeline_lib", | ||
| visibility = ["//visibility:public"], | ||
| #srcs = ["run_pipeline.sh"], | ||
|
SamuelPalmhager marked this conversation as resolved.
|
||
| data = [ | ||
| ":run_pipeline", #Sh_binary below | ||
| ], | ||
|
|
||
| ) | ||
|
|
||
| sh_binary( | ||
| name = "run_pipeline", | ||
| srcs = ["run_pipeline.sh",], | ||
| #data = ["//tests/python:testdata",], | ||
| data = [ | ||
| "//apps/cpp_cli_tool:cli", | ||
| "//python_tools/data_cleaner:cleaner", | ||
| "//tests/python:testdata", | ||
| ":bash_data" | ||
| ], | ||
| visibility = ["//visibility:__subpackages__"], | ||
| #deps = [":run_pipeline_lib"], | ||
| ) | ||
|
|
||
| filegroup( | ||
| name = "bash_data", | ||
| srcs = glob(["*.csv", "*.json"]), | ||
| visibility = ["//:__subpackages__"], | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.