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

Measure: storing of environment variables #93

Open
MatthieuDartiailh opened this issue Feb 1, 2017 · 1 comment
Open

Measure: storing of environment variables #93

MatthieuDartiailh opened this issue Feb 1, 2017 · 1 comment

Comments

@MatthieuDartiailh
Copy link
Member

MatthieuDartiailh commented Feb 1, 2017

Environment variables will be stored in an object in the measure plugin. This object will be responsible for storing the values, save them, reload them from a file and notify the measure about the changes in the values (it will be the plugin which will then update the edited measure). Follow a brief description of the Environment object:

  • to simplify the handling of preferences the Environment object will inherit from HasPreferencesAtom
  • it will have the following members:
    • path: path to the file in which to store the environment variables (this should be the path from which the environment was loaded or the last path to which the user manually saved the environment).
    • updated: an event to which the plugin will listen to know what variable has been added, edited, deleted. The exact format is to be defined.
    • a EnvNode instance (to be described below) in which the actual variables are stored as EnvVar instance (described below)
  • it should also have the following methods:
    • save(path=None): save the values in a config file. if path is None it should use the default. In the absence of a default raise an exception. The extension should be .env.ini
    • build_from_config(config): class method using a ConfigObj object to rebuild an environment
    • a method listening to the Node/Entry when a modification occurs, in charge of formatting the message to send to the measure plugin through updated
    • values(): returning a flat dict containing all the environment variables (in the format env.node_id.var_id) (Note that the id of the root Node should be "env".

As we allow the environment to have a hierarchical structure we need an object to represent nodes in that structure. It will be the EnvNode object whose description follows:

  • members:
    • id: id of the node used when formatting the environment variable names to store them in the task database
    • a list of children that can be either EnvNode or EnvVars (the only delicate thing here is the saving/recovery)
    • a signal delivering notification about changes in the list of children. Should be connected to environment notifying method. (cf tasks)
    • a reference to the Environment they belong to.
  • methods:
    • values(): returning a flat dict containing all the environment variables below this node (in the format node_id.var_id or node_id.nodebis_id.var_id)
    • add/move/remove_child: use to manipulate the child list, in charge of connecting observers and signaling the modification.

The env vars for a number cannot simply be stored as key value pairs in a dictionary and are hance stored as EnvVar instances whose description follows:

  • members:
    • id: id of the variable basically its name. It should be enforced by the node that ids are unique inside a node.
    • value: value of the variable that is actually untyped. Changes should be connected to environment notifying method. The saving/restoring of the value should be delegated to the editor declaration (cf Measure: editing environment variables #94 )
    • a description providing more details about the meaning of the variable.
    • an editor id: which specifies what editors to use to edit the values, and also how to save restore the value.
    • a metadata dictionary for additional infos.

The handling of environment variables requires some changes to the measure plugin, workspace and the execution in addition to the actual code storing the variables.

  • the path to the last used environment needs to be stored on the measure plugin (and saved automatically)
  • a default directory to save environment should be created (could benefit from App.preferences : add an extension allowing to require a subdirectory in application folder #63)
  • measure plugin should gain a method to be able to update edited measure task database after a change in the env vars
  • the workspace needs to gain methods to save/load environment
  • the processor needs to save the environment next to the measure when running a measure
@MatthieuDartiailh
Copy link
Member Author

Note I edited the above description to introduce the idea that the editor declaration handle the saving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant