flg_prms.yml cannot be empty ?
- Dominant language
- Python
- Stars
- 4
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Hey @modolol, here's a fun bug for when you need a fun break. Turns out, dvas complains if I define no user flags, i.e. if
the `flg_prms.yml` configuration file remains empty.
Any idea why that is ? Is this something that could be "easily" fixed you think ? I guess the idea would be to ignore configuration files that contain "nothing" (i.e. only empty lines and comments).
What do you think ?
Here's the full error stack:
```
Traceback (most recent call last):
File ".../src/dvas/config/config.py", line 335, in _validate_json
validate(instance=document, schema=self.json_schema)
File ".../python3.10/site-packages/jsonschema/validators.py", line 1058, in validate
raise error
jsonschema.exceptions.ValidationError: {} is not of type 'array'
Failed validating 'type' in schema:
{'$schema': 'http://json-schema.org/draft-07/schema#',
'items': {'additionalProperties': False,
'patternProperties': {'^bit_pos$': {'maximum': 62,
'minimum': 0,
'type': 'integer'},
'^flg_desc$': {'type': 'string'},
'^flg_name$': {'type': 'string'}},
'type': 'object'},
'type': 'array'}
On instance:
{} (<= @modolol: this is were it picks up my empty file ...)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ".../src/dvas/config/config.py", line 278, in _get_document
self.read_yaml(Path(filepath))
File ".../src/dvas/config/config.py", line 318, in read_yaml
self._validate_json(document)
File ".../src/dvas/config/config.py", line 339, in _validate_json
raise ConfigCheckJSONError(
dvas.errors.ConfigCheckJSONError: JSON validation error::
{}
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ".../src/dvas/config/config.py", line 430, in read
self._get_document(doc_in)
File ".../src/dvas/config/config.py", line 455, in _get_document
super()._get_document(doc_in=doc_in)
File ".../src/dvas/config/config.py", line 281, in _get_document
raise ConfigReadError(f"Error in reading config file '{filepath}'") from exc
dvas.errors.ConfigReadError: Error in reading config file '.../src/dvas_demo/config/flg_config.yml'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ".../src/dvas/config/config.py", line 77, in instantiate_config_managers
inst.read()
File ".../src/dvas/config/config.py", line 433, in read
raise ConfigReadError('Error in user config') from exc
dvas.errors.ConfigReadError: Error in user config
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ".../dvas310/bin/dvas_run_recipe", line 33, in
sys.exit(load_entry_point('dvas', 'console_scripts', 'dvas_run_recipe')())
File ".../src/dvas_recipes/__main__.py", line 125, in dvas_run_recipe
run_recipe(args.rcp_fn, args.fid_log_fn, fid_to_treat=args.f,
File ".../src/dvas_recipes/hl_commands.py", line 299, in run_recipe
rcp.execute(from_step_id=from_step_id, until_step_id=until_step_id)
File ".../src/dvas_recipes/recipe.py", line 359, in execute
self.init_db(reset=self._reset_db)
File ".../src/dvas_recipes/recipe.py", line 303, in init_db
DB.refresh_db()
File ".../src/dvas/dvas.py", line 63, in refresh_db
DatabaseManager().refresh_db()
File ".../src/dvas/helper.py", line 65, in __call__
instance = super(SingleInstanceMetaClass, cls).__call__(*args, **kwargs)
File ".../src/dvas/database/database.py", line 91, in __init__
self._cfg_mngr = instantiate_config_managers(ParameterCfg, ModelCfg, FlgCfg, TagCfg,
File ".../src/dvas/config/config.py", line 79, in instantiate_config_managers
raise ConfigError(f"Error in reading instance of '{inst.CLASS_KEY}'") from exc
dvas.errors.ConfigError: Error in reading instance of 'Flg'
```
Contributor guide
Assessment
This issue has not been assessed yet.