-
Notifications
You must be signed in to change notification settings - Fork 1
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: use model classes and also refactor original config impleme… #48
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @kapil-agnihotri, thank you for submitting a pull request. We will address it.
a79aa2f
to
1acb08a
Compare
…ntation to use model classes
1acb08a
to
5790d7d
Compare
c75409e
to
02a26a5
Compare
For now I have duplicated all model classes in here. I think later ranking-service can be modified to refer to the model classes from ProMCDA submodule. This will also reduce code duplication. |
@kapil-agnihotri The main reasons are:
|
@Flaminietta thank you for your feedback. I can create a new branch and push the changes to it once the review is complete. I believe that the review is still in progress? |
@kapil-agnihotri @mspada Did you already perform also end-to-end controlled tests? I still need to run it once. Do I run it from the terminal as before? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I didn't get around to running it, the principal structure is as I would have expected.
The README needs to be updated too for the new refactoring. For example, now the run is not initiated by typing: However, for now I cannot run it, I should dig deeper to find the issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that this file represents a combination of the previous configuration.json. file and the input_matrix.cvs. I would name it referring to the idea of a configuration anyway, like "configuration_car_data_rank_robustness_on_weight_no_sensitivity.json"
In "robustness", what happens if the user selects "robustness": "indicators"? The entry "onWeightsLevel" will be then substituted with "on_indicators"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, in this example writing the input matrix is easy (even manually). What would the strategy be when the input matrix is a table with many more rows and columns?
mcda/mcda_run.py
Outdated
@@ -7,21 +7,21 @@ | |||
Usage (from root directory): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that we won't run it from CLI anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will, I have updated the commands.
mcda/mcda_run.py
Outdated
|
||
def config_dict_to_configuration_model(input_config): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move the function somewhere outside of this script. It's a utility, let's keep this running script clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a docstring to the function by following the format used for the other functions.
Something like:
"""
Describe functionality.
Parameters:
- A (type): description.
- B (type): description.
Raises:
- ValueError: when it happens.
:param A: type
:param B: type
:return R: type
"""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the type hinting (that indicates the expected type of the value that the function will return).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Please let me know if you still feel something is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def config_dict_to_configuration_model(input_config) -> HINT TYPE OF RETURN:
"""
Method that converts Config object into a ConfigurationModel.
This method is used when ProMCDA is called using cli where input matrix is passed
in a separate file.
Parameters:
- input_config: EXPLAIN HERE WHAT OBJECT YOU EXPECT (SHORT DESCRIPTION)
Returns:
- EXPLAIN HERE WHAT OBJECT YOU EXPECT (SHORT DESCRIPTION)
:param input_config: dict
:rtype: dict - ALREADY GIVEN ABOVE, NOT NECESSARY
:return: GIVE THE TYPE OF RETURN
"""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried to respect this format throughout the entire package.
from ProMCDA.mcda import util | ||
|
||
|
||
class Configuration(Model): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the original class Config stays too, we need perhaps to review naming. It's quite confusing for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, adding short descriptions (docstrings) of the main functionalities helps navigate the various scripts.
For example:
The Configuration class encapsulates a configuration for MCDA, allowing for structured data representation and easy manipulation of attributes.
@kapil-agnihotri after my second review, this is my feedback:
About the end-to-end tests:
We can have a call any time. |
Yes,
One (config.json) works on plain json input and python primitive data types and the other (models/configuration.json) works on models and classes structure. I cannot rename classes from
Sure, if you want to. I am not sure how to run them.
I think if all the existing unit test passes then we don't need anything extra. However, if you feel then we can for sure add extra tests if there is scope.
No it is the other way round. ProMCDA is used as a submodule/ (library in future) in ranking-service. Ranking-service is the parent service which calls a module(ProMCDA) to get the job done.
Not sure if you already looked at my PR of ranking service but there spent some time to create another API that converts huge input csv matrix to desired input_matrix in json format to be used in ranking service. Thank you for the feedback Flaminia, I think I should pause my work in this branch for the beautification on documentation you proposed. As we discussed now you want to convert ProMCDA into library by getting rid of config/Configuration json/object. I think if the ProMCDA is again refactored then I would unnecessarily be spending time in beautifying the code here that might not be used in the future. |
…ntation to use model classes