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

[Feat/aut1000] - SmartPeak support for exporting workflow results as plots #412

Merged
merged 19 commits into from
Sep 13, 2021

Conversation

ahmedskhalil
Copy link
Collaborator

@ahmedskhalil ahmedskhalil commented Aug 27, 2021

Objectives

  • Exporting plots as PNG, PDF, HTML and SVG.

Sample plots

Original
image

As PDF (highest resolution)
smartpeak-exported-plot.pdf

As PNG
smartpeak-exported-plot

@ghost
Copy link

ghost commented Aug 27, 2021

DeepCode's analysis on #31a75f found:

  • ⚠️ 2 warnings 👇

Top issues

Description Example fixes
Missing check is_open on std::ofstream before writing to it. Occurrences: 🔧 Example fixes
Leaking memory. PlotExporter is allocated on the heap and never freed. In function drawSliders. Occurrences: 🔧 Example fixes

👉 View analysis in DeepCode’s Dashboard | Configure the bot

👉 The DeepCode service and API will be deprecated in August, 2021. Here is the information how to migrate. Thank you for using DeepCode 🙏 ❤️ !

If you are using our plugins, you might be interested in their successors: Snyk's JetBrains plugin and Snyk's VS Code plugin.

@ahmedskhalil ahmedskhalil linked an issue Aug 31, 2021 that may be closed by this pull request
@ghost
Copy link

ghost commented Aug 31, 2021

DeepCode's analysis on #4afb3e found:

  • ⚠️ 1 warning 👇

Top issues

Description Example fixes
Missing check is_open on std::ofstream before writing to it. Occurrences: 🔧 Example fixes

👉 View analysis in DeepCode’s Dashboard | Configure the bot

👉 The DeepCode service and API will be deprecated in August, 2021. Here is the information how to migrate. Thank you for using DeepCode 🙏 ❤️ !

If you are using our plugins, you might be interested in their successors: Snyk's JetBrains plugin and Snyk's VS Code plugin.

@ghost
Copy link

ghost commented Aug 31, 2021

DeepCode's analysis on #0f2579 found:

  • ⚠️ 1 warning 👇

Top issues

Description Example fixes
Missing check is_open on std::ofstream before writing to it. Occurrences: 🔧 Example fixes

👉 View analysis in DeepCode’s Dashboard | Configure the bot

👉 The DeepCode service and API will be deprecated in August, 2021. Here is the information how to migrate. Thank you for using DeepCode 🙏 ❤️ !

If you are using our plugins, you might be interested in their successors: Snyk's JetBrains plugin and Snyk's VS Code plugin.

@ghost
Copy link

ghost commented Aug 31, 2021

DeepCode's analysis on #086aad found:

  • ⚠️ 1 warning 👇

Top issues

Description Example fixes
Missing check is_open on std::ofstream before writing to it. Occurrences: 🔧 Example fixes

👉 View analysis in DeepCode’s Dashboard | Configure the bot

👉 The DeepCode service and API will be deprecated in August, 2021. Here is the information how to migrate. Thank you for using DeepCode 🙏 ❤️ !

If you are using our plugins, you might be interested in their successors: Snyk's JetBrains plugin and Snyk's VS Code plugin.

@ghost
Copy link

ghost commented Sep 1, 2021

DeepCode's analysis on #b5d503 found:

  • ⚠️ 1 warning 👇

Top issues

Description Example fixes
Missing check is_open on std::ofstream before writing to it. Occurrences: 🔧 Example fixes

👉 View analysis in DeepCode’s Dashboard | Configure the bot

👉 The DeepCode service and API will be deprecated in August, 2021. Here is the information how to migrate. Thank you for using DeepCode 🙏 ❤️ !

If you are using our plugins, you might be interested in their successors: Snyk's JetBrains plugin and Snyk's VS Code plugin.

Copy link
Collaborator

@dmccloskey dmccloskey left a comment

Choose a reason for hiding this comment

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

Good idea using the GNU plotting library. Overall it looks quite nice to me. I look forward to seeing the demo tomorrow.

It would be good to have Bertrands review as well.

@@ -266,5 +279,33 @@ namespace SmartPeak
}
return result;
}

void GraphicDataVizWidget::showInstallationInstructions()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good idea.


std::filesystem::remove_all(main_path / "plots");
#endif
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the Win version missing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed the directive to include Win

Copy link
Collaborator

@bertrandboudaud bertrandboudaud left a comment

Choose a reason for hiding this comment

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

It's nice, i would like to see a demo :)
I had some minor comments, but would be nice to handle them before to merge it.
one thing should be very nice is to use the FilePicker. to make the user choose where he want the plot to be saved.

@@ -18,6 +18,7 @@ set(sources_list_h
LogWidget.h
ParameterEditorWidget.h
ParametersTableWidget.h
Plotter.h
Copy link
Collaborator

Choose a reason for hiding this comment

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

(minor) Here all lines are using tabs but you are using space. please use tab.

ImGui::SameLine();
if (ImGui::Button("Save Plot"))
{
PlotExporter* exported_plot = new PlotExporter(application_handler_.main_dir_.string(), graph_viz_data_, selected_format);
Copy link
Collaborator

Choose a reason for hiding this comment

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

can't you use unique_ptr here ? (or just get a stack variable)

@@ -17,6 +17,7 @@ set(sources_list
LogWidget.cpp
ParameterEditorWidget.cpp
ParametersTableWidget.cpp
Plotter.cpp
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use tab instead of spaces here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes my editor had altered settings

@@ -30,6 +30,7 @@ set(core_executables_list
set(io_executables_list
CSVWriter_test
ParametersParser_test
PlotExporter_test
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use tab instead of spaces here.

std::filesystem::path main_path;
SmartPeak::SessionHandler::GraphVizData graph_viz_data_;

SmartPeak::Utilities::getEnvVariable("HOME", &home_path);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would be more in favor to use std::filesystem::temp_directory_path to create a directory suitable for unit tests.


//PNG=0, PDF=1, HTML=2, SVG=3
#if defined(__APPLE__) || defined(__linux__)
SmartPeak::PlotExporter* exported_png = new SmartPeak::PlotExporter(main_path.string(), graph_viz_data_, 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's always better to use smart pointer than the good old new/delete pair (or to construct on the stack?). is it possible?

@@ -85,6 +90,7 @@ namespace SmartPeak
std::optional<float> marker_position_;
bool use_markers_ = false;
bool is_spectra_ = false;
// const std::unique_ptr<std::filesystem::path> working_path_ = std::make_unique<std::filesystem::path>(application_handler_.main_dir_);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this could be remove ?

}
return true;
} else {
LOGW << "gnuplot not found! Not generating any plots.";
Copy link
Collaborator

Choose a reason for hiding this comment

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

It could be an error (LOGE).

@@ -22,6 +22,7 @@
// --------------------------------------------------------------------------

#include <SmartPeak/ui/GraphicDataVizWidget.h>
#include <SmartPeak/ui/FilePicker.h>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see you are using the FilePicker. it would be very nice to use it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It wasn't implemented by the time of reviewing, now it's in.

@bertrandboudaud bertrandboudaud merged commit 5f22eff into develop Sep 13, 2021
@ahmedskhalil ahmedskhalil deleted the ft1000 branch January 7, 2022 08:47
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.

3 participants