Comments (12)
Bugs and test coverage fixes in oasislmf
(0.0.1)
from oasislmf.
We can discuss this week, but @OmegaDroid I think I do need some guidance on the InputValues
class (oasislmf.cmd.base.InputValues
). It looks as the config_dir
path attribute is obtained from the parent directory of the configuration file argument (args.config
), but if it is not present it causes problems as with the generate-keys
subcommand.
class InputValues(object):
"""
Helper class for accessing the input values from either
the command line or the configuration file.
"""
def __init__(self, args):
self.args = args
self.config = {}
self.config_dir = os.path.dirname(args.config)
if os.path.exists(args.config):
with io.open(args.config, 'r', encoding='utf-8') as f:
self.config = json.load(f)
...
...
You're assuming here that args.config
exists, but we need to make each MDK subcommand also work if all the arguments are passed in directly without using a configuration file. In this case args.config
won't exist but it is not clear what happens. Later on you use config_dir
to join it with other path arguments. It is not clear.
Even with the fix I made (https://github.com/OasisLMF/OasisLMF/pull/11/files) I am getting errors when I try to generate keys without using the configuration file option but passing all the arguments directly on the command line.
(oasislmf-venv) [srm@~/Documents/sandeep/cst/dev/oasis/oasislmf]$ oasislmf model generate-keys -k ../OasisPiWind/keys_data/PiWind -v ../OasisPiWind/keys_data/PiWind/ModelVersion.csv -l ../OasisPiWind/src/keys_server -t 'list_keys' -e ../OasisPiWind/keys_data/PiWind/oasislmf_piwind_model_loc_test.csv -s piwind-keys.csv
Output file path does not exist: /Users/srm/Documents/sandeep/cst/dev/oasis/OasisLMF/keys-20180302172532
(oasislmf-venv) [srm@~/Documents/sandeep/cst/dev/oasis/oasislmf]$ oasislmf model generate-keys -k ../OasisPiWind/keys_data/PiWind -v ../OasisPiWind/keys_data/PiWind/ModelVersion.csv -l ../OasisPiWind/src/keys_server -t 'list_keys' -e ../OasisPiWind/keys_data/PiWind/oasislmf_piwind_model_loc_test.csv
usage: oasislmf model generate-keys [-h] [-V] [-C CONFIG] [-k KEYS_DATA_PATH]
[-v MODEL_VERSION_FILE_PATH]
[-l LOOKUP_PACKAGE_PATH]
[-t {oasis_keys,list_keys}]
[-e MODEL_EXPOSURES_FILE_PATH] [-s]
output-file-path
oasislmf model generate-keys: error: too few arguments
from oasislmf.
To test this fix I uninstalled the current oasislmf
package version from my virtual env., and re-installed the version from the bug-fix
branch using
pip install -e git+ssh://[email protected]/OasisLMF/OasisLMF.git@bug-fix#egg=oasislmf
from oasislmf.
So there is no assumption that the config file exists, if it doesn't then we don't try to attempt to get the value from the config.
The reason you are getting the too few arguments error is that it hasn't been setup to lookup from the config file, ill add that now.
from oasislmf.
Ahh ok, looks like you've sorted it already
from oasislmf.
@OmegaDroid There must be for each MDK subcommand two modes of specifying all the resources: via the command line using flags, or via a configuration file.
from oasislmf.
Thats what the Input values class handles, the logic is:
- Is it on the cmd line
- Is it in the config file
- Is there a default value
from oasislmf.
@OmegaDroid It might be a good idea to add a console logging option to the MDK commands. I imagine this wouldn't be difficult to do - at the moment you just get a message saying no logger set
No handlers could be found for logger "root"
it would be more meaningful in fact for console logging to appear, as it does with the MDK scripts.
from oasislmf.
I think there should be logging put in place already but maybe its not being set on the root logger. I'll take a look.
from oasislmf.
Thanks
from oasislmf.
It would be good to rebase this branch or your fixes branch against master
before merging, as master
has had a number of changes lately.
from oasislmf.
Flag conflict in generate-keys
command
(oasislmf-venv) [srm@~/Documents/sandeep/cst/dev/oasis/oasislmf]$ oasislmf model generate-keys --help
Traceback (most recent call last):
File "/Users/srm/Documents/sandeep/cst/dev/oasis/OasisLMF/oasislmf-venv/bin/oasislmf", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/Users/srm/Documents/sandeep/cst/dev/oasis/OasisLMF/oasislmf-venv/src/oasislmf/bin/oasislmf", line 7, in <module>
sys.exit(RootCmd().run())
File "/Users/srm/Documents/sandeep/cst/dev/oasis/OasisLMF/oasislmf-venv/src/oasislmf/oasislmf/cmd/root.py", line 36, in run
return super(OasisBaseCommand, self).run(args=args)
File "/Users/srm/Documents/sandeep/cst/dev/oasis/OasisLMF/oasislmf-venv/lib/python2.7/site-packages/argparsetree/cmd.py", line 153, in run
args = args or self.parse_args()
File "/Users/srm/Documents/sandeep/cst/dev/oasis/OasisLMF/oasislmf-venv/src/oasislmf/oasislmf/cmd/base.py", line 117, in parse_args
self.args = super(OasisBaseCommand, self).parse_args()
File "/Users/srm/Documents/sandeep/cst/dev/oasis/OasisLMF/oasislmf-venv/lib/python2.7/site-packages/argparsetree/cmd.py", line 59, in parse_args
return self.arg_parser.parse_args(self.argv)
File "/Users/srm/Documents/sandeep/cst/dev/oasis/OasisLMF/oasislmf-venv/lib/python2.7/site-packages/argparsetree/cmd.py", line 49, in arg_parser
self.register_sub_commands(self._arg_parser)
File "/Users/srm/Documents/sandeep/cst/dev/oasis/OasisLMF/oasislmf-venv/lib/python2.7/site-packages/argparsetree/cmd.py", line 87, in register_sub_commands
cmd.register_sub_commands(sub_parser)
File "/Users/srm/Documents/sandeep/cst/dev/oasis/OasisLMF/oasislmf-venv/lib/python2.7/site-packages/argparsetree/cmd.py", line 86, in register_sub_commands
cmd.add_args(sub_parser)
File "/Users/srm/Documents/sandeep/cst/dev/oasis/OasisLMF/oasislmf-venv/src/oasislmf/oasislmf/cmd/model.py", line 74, in add_args
help='Keys records output file path',
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.py", line 1308, in add_argument
return self._add_action(action)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.py", line 1682, in _add_action
self._optionals._add_action(action)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.py", line 1509, in _add_action
action = super(_ArgumentGroup, self)._add_action(action)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.py", line 1322, in _add_action
self._check_conflict(action)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.py", line 1460, in _check_conflict
conflict_handler(action, confl_optionals)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.py", line 1467, in _handle_conflict_error
raise ArgumentError(action, message % conflict_string)
argparse.ArgumentError: argument -o/--oasis-files-path: conflicting option string(s): -o
from oasislmf.
Related Issues (20)
- Add warning message when installing on unsupported platforms.
- Update the the `KeyLookupInterface` class to have access to the `lookup_complex_config_json`
- Pip install fails when running PiWind testing HOT 1
- Bug in latest platform2 release
- Add runtime user supplied secondary factor option to plapy
- Add option to enable or disable Post Loss Amplification
- model settings - correlation settings - allow optional hazard or damage correlation value
- Refactor footprint file format priorities
- Standardise docstrings
- PLT outputs are very slow to produce for equiprobable event sets HOT 1
- Partition parquet vunrability data by vunrability_id
- Update fm supported terms document HOT 2
- Incorect TIV in the summary info files
- Apply limits to aggregated exposures HOT 4
- Performace issue in get_exposure_summary
- Converting exposure files to previous OED version before running model
- Change vulnerability weight data type from 32-bit integer to 32-bit float in gulmc
- Flag required in oasislmf 1.28.X to turn off disaggregation. HOT 2
- Missing parquet library dependencies for gulmc in 1.27 HOT 1
- Net RI losses do not use -z in summarycalc HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oasislmf.