Skip to content

Conversation

@awirb
Copy link
Contributor

@awirb awirb commented Jul 6, 2022

If using different modules in a new function

  • in the ini file for this function, add a section called modName_override for each module
  • configurations for these modules will be created using the (local if defaultConfig=False) default configuration and overriding the parameters from the modName_override section
  • in the end, a function_settings.ini is saved to the outputs folder of the function: all the other parameters, which were not part of the override parameters, are added in the override sections for easy reproduction

@awirb awirb requested review from fso42 and matthiasto July 6, 2022 14:17
@pep8speaks
Copy link

Hello @awirb! Thanks for opening this PR.

Line 130:121: E501 line too long (131 > 120 characters)
Line 102:121: E501 line too long (137 > 120 characters)
Line 84:121: E501 line too long (123 > 120 characters)
Line 79:27: E225 missing whitespace around operator
Line 54:121: E501 line too long (136 > 120 characters)

Line 889:41: E712 comparison to True should be 'if cond is True:' or 'if cond:'
Line 889:41: E225 missing whitespace around operator
Line 886:41: E712 comparison to False should be 'if cond is False:' or 'if not cond:'
Line 886:41: E225 missing whitespace around operator
Line 589:50: E712 comparison to False should be 'if cond is False:' or 'if not cond:'

Do see the Hitchhiker's guide to code style

comModule='com1DFA')

# fetch configuration for DFAPathGeneration
hybridModelPathCfg= cfgUtils.getModuleConfig(DFAPath, fileOverride='', modInfo=False, toPrint=False,

Choose a reason for hiding this comment

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

Similar blocks of code found in 3 locations. Consider refactoring.

@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit afa3305 and detected 6 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2
Duplication 4

The test coverage on the diff in this pull request is 22.7% (50% is the threshold).

This pull request will bring the total coverage in the repository to 73.2% (0.0% change).

View more on Code Climate.

@codecov
Copy link

codecov bot commented Jul 6, 2022

Codecov Report

Merging #739 (afa3305) into master (bd0b726) will decrease coverage by 0.14%.
The diff coverage is 22.72%.

@@            Coverage Diff             @@
##           master     #739      +/-   ##
==========================================
- Coverage   75.58%   75.43%   -0.15%     
==========================================
  Files          55       55              
  Lines       11337    11366      +29     
==========================================
+ Hits         8569     8574       +5     
- Misses       2768     2792      +24     
Impacted Files Coverage Δ
avaframe/com3Hybrid/com3Hybrid.py 0.00% <0.00%> (ø)
avaframe/in3Utils/cfgUtils.py 84.43% <34.48%> (-4.46%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd0b726...afa3305. Read the comment docs.

fU.makeADir(oPath)

# get comDFA configuration and save to file
hybridModelDFACfg = cfgUtils.getModuleConfig(com1DFA, fileOverride='', modInfo=False, toPrint=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

it is maybe a bit confusing to have both a fileOverride and a overrideConfig... Maybe we could rename this a bit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what is your suggestion? I think it is actually pretty accurate the one thing is a file path that you have to provide the other is configparser object that has the override parameters in it..

comModule='com1DFA')

# fetch configuration for DFAPathGeneration
hybridModelPathCfg= cfgUtils.getModuleConfig(DFAPath, fileOverride='', modInfo=False, toPrint=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to come up with a good way to name these cfg objects. DFAPathcom3HybridCfg and com1DFAcom3HybridCfg and com2ABcom3HybridCfg or so no? And we always use the same method to name these files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a good point!

Comment on lines +68 to +69
overrideConfig: cfg
if not empty, override configuration parameters with override parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

back to my other comment, the naming is confusing, we have two override files given in input. Also update the doc string so it is clear what is happening here

cfg.set(section, key, overrideParameters[key])
log.info('Override parameter: %s in section: %s with %s' % (key, section, str(overrideParameters[key])))
else:
overrideParameters[key] = cfg[section][key]
Copy link
Contributor

Choose a reason for hiding this comment

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

This updates the overrideParameters (which is the override cfg object) without you returning it as an output... I works but I am not a big fan of something happening without me knowing it. Should we change this?
If not at least mention this in the function description and add a comment here

# get comDFA configuration and save to file
hybridModelDFACfg = cfgUtils.getModuleConfig(com1DFA, fileOverride='', modInfo=False, toPrint=False,
onlyDefault=cfgHybrid['com1DFA_override']['defaultConfig'], overrideConfig=cfgHybrid)
hybridModelDFACfgFile = cfgUtils.writeCfgFile(avalancheDir, com1DFA, hybridModelDFACfg, fileName='com1DFA_settings', filePath=oPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

why write this one and not also the AB and pathGeneration cfgs to file?

@awirb
Copy link
Contributor Author

awirb commented Jul 7, 2022

newly opened in PR #740

@awirb awirb closed this Jul 7, 2022
@fso42 fso42 deleted the multipleCfgs branch November 15, 2023 13:26
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.

4 participants