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

Refactor state.dart (part 1) #591

Merged
merged 15 commits into from
Oct 27, 2022
Merged

Refactor state.dart (part 1) #591

merged 15 commits into from
Oct 27, 2022

Conversation

d-uzlov
Copy link
Contributor

@d-uzlov d-uzlov commented Oct 26, 2022

Part of #556

In this PR I extract several helper classes from BenchmarkState: TaskRunner, ResultHelper, ValidationHelper.

Overall the layout of classes and methods is still suboptimal, but I want to merge this now to reduce possible merge issues.
I have already done manual merge/rebase 3 times 4 times because literally any changes to state.dart in other PRs require manual merge with this one. And almost any changes in the app require a change in the state.dart.

@github-actions
Copy link

github-actions bot commented Oct 26, 2022

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

@d-uzlov d-uzlov requested a review from anhappdev October 26, 2022 10:08
@d-uzlov
Copy link
Contributor Author

d-uzlov commented Oct 26, 2022

@anhappdev I think it would be better if you leave your comments, but approve this PR, and then I'll fix it in the next PR for #556.

flutter/lib/state/task_runner.dart Outdated Show resolved Hide resolved
flutter/lib/state/task_runner.dart Outdated Show resolved Hide resolved
@@ -1,6 +1,6 @@
import 'package:mlperfbench_common/data/results/benchmark_result.dart';

class RunResult {
class NativeRunResult {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think adding a brief description for each of the class as a comment will be helpful since the class name some time is not descriptive enough.

final String mode;
final String logSuffix;
final String loadgenMode;
final String readable;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does readable mean here? Do you mean description?

Copy link
Contributor Author

@d-uzlov d-uzlov Oct 27, 2022

Choose a reason for hiding this comment

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

Value of this variable should be human-readable.
Previously it was used only in log dir name (which is intended to be handled by vendor developers), now I also use as a log prefix.

Value should be short, to consume less screen space, and it should look nice.
I don't think description would fit here, because I would expect description to be more than just one word.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a comment and example value to explain it? I still not understand what is it and for what it's used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All possible values are already in this file: performance and accuracy, just few lines above.
I think they are pretty self-explanatory.
Example usage:
log dir name: image_classification_offline-performance
live logs: image_classification: performance mode: starting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would be better to change the name than adding comments with example usage.
But I can't come up with a good name.

If you also don't have any fitting suggestions, I'll add a comment in next PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, just like it was before this PR :-)
I renamed the field because I thought logSuffix kinda doesn't fit the fact that it is no longer a true suffix, and the content of the variable will look fitting in any text.

OK, I'll revert it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I only see it used as a log dir suffix in the code, so that name would be good for now.

Copy link
Contributor Author

@d-uzlov d-uzlov Oct 27, 2022

Choose a reason for hiding this comment

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

live logs: image_classification: performance mode: starting

Not a log dir suffix

Copy link
Collaborator

@anhappdev anhappdev Oct 27, 2022

Choose a reason for hiding this comment

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

The only place I see it used is logDir = '$logParentDir/${benchmark.id}-${runMode.readable}'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

String toString() {
return readable;
}

}

Future<LoadgenInfo?> extractLoadgenInfo() async {
const logFileName = 'mlperf_log_detail.txt';
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can make all string const like this static const.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const keyword in Dart is not like const in C++. It's already static const, because in Dart all const values use static initialization, and can only have one instance.
static const varName in code will result in compilation error, because it's not a valid syntax in Dart for local fields (for class fields it's the other way around).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, static const mean the same as class const in some other languages, so it needs to be defined as a class field. Normally, I would either define this kind of string as a global constant, or a class constant, since it is kind of setting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I'll move it to class level

@d-uzlov d-uzlov force-pushed the 556/refactor-state-1 branch from 7e28ef9 to 71b8438 Compare October 27, 2022 08:34
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@d-uzlov
Copy link
Contributor Author

d-uzlov commented Oct 27, 2022

@anhappdev could you approve this, please?

@d-uzlov d-uzlov merged commit 46a1bbb into master Oct 27, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 27, 2022
@d-uzlov d-uzlov deleted the 556/refactor-state-1 branch October 27, 2022 09:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants