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

Allow overwriting model properties via json files #18

Open
bernt-matthias opened this issue Jul 22, 2020 · 3 comments
Open

Allow overwriting model properties via json files #18

bernt-matthias opened this issue Jul 22, 2020 · 3 comments
Assignees

Comments

@bernt-matthias
Copy link
Contributor

One might have a json file that stores curated information that helps aclimatise's parser, e.g.

{
    'parameter1': {
         'property1': 'value',
         'property2': 2
    },
    ...
}

would overwrite property1 and property2 in aclimatise's internal representation of parameter1. A simple example would be to overwrite help text, default values, file types.

With an appropriate 'encoding' also the parameter type might be changed:

{
    'parameter1': {
         '--TYPE--': 'CliFloat'
    },
    ...
}

could overwrite aclimatise's (wrong) guess of the parameter type (I suggest to use -- prefix since this should be an impossible name prefix).

In this way also hardcoding parameters, or removing parameters could be done via special parameter classes, e.g. CliHardcoded, CliNull (I try not to use the term blacklist here).

In the same way (with separate json files) also properties in the generated languages would be possible. Eg. a json file like the first exampe might overwrite/add attributes 'property1' and 'property2' of the xml tag with name="parameter1".

@multimeric
Copy link
Collaborator

So there are really two tasks here. One is adding to the data model the concept of fixed values, because it currently assumes all inputs are variables. This would involve adding fields to my Type classes. And the second point is adding a "patch" mechanism to edit the Command representation. Your examples of "changing the type to a Float", and "setting the value of this parameter to 2" are just examples of the more flexible ability to patch the data model. For this, I propose something like python-json-patch, which could be used to patch the data model.

@MoffMade
Copy link

I could start working on this issue if no one else has

@multimeric multimeric assigned multimeric and MoffMade and unassigned multimeric Jul 23, 2020
@multimeric
Copy link
Collaborator

The main problem I forsee with this is that I think python-json-patch assumes that we're working with dictionaries and lists, ie objects you can [] index, but since the data model (ie a Command instance) involves dataclasses, it may not work. Maybe that functionality exists in the library, but if not then we look for a similar but compatible library, or we make a dataclass subclass that implements the "container" methods: https://docs.python.org/3/reference/datamodel.html#emulating-container-types, or we convert to a dict temporarily, or something like that.

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

No branches or pull requests

3 participants