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

Specification of models inputs #10

Open
leo-desbureaux-tellae opened this issue May 31, 2021 · 2 comments
Open

Specification of models inputs #10

leo-desbureaux-tellae opened this issue May 31, 2021 · 2 comments
Labels
io Inputs/Outputs

Comments

@leo-desbureaux-tellae
Copy link
Contributor

leo-desbureaux-tellae commented May 31, 2021

Problem exposition

The specifications of the inputs of a given model (which properties are available, required, their type, etc) cannot be known from the outside of the simulator.

For instance, to know that the SB_VS User class can be provided with "max_tries" or "closest_station_evaluation" properties, one has to go look at the class declaration (and its parent class').

Same goes for the "operation_parameters" property of the SB_VS_R Operator class, which must contain the fields "start_time", "duration", "neighbor" and other ones.

Even the allowed agent types are stored in the Model class.

Today, new scenario inputs are created based on existing scenarios, which limits the use to the same properties.

Proposed solution

The idea is to generate JSON Schemas dynamically for a specific model. Call main.py with an option to get a complete JSON Schema for each agent type.

How to do so ?

  • Each agent could store the schema for its own properties in class attributes, and inherit from its parent' schema if needed.

    • The implementation can be fast enough (?). The idea is already present in the Person PROPERTIES class attribute.
    • Replication of code (enumeration of the parameters, default values...)
  • The schema could be generated from the class meta information (parameters with default values, description from docstring, etc)

    • The implementation may be difficult (no sure it is doable)
    • No replication of code
@leo-desbureaux-tellae leo-desbureaux-tellae added the enhancement New feature or request label May 31, 2021
@leo-desbureaux-tellae
Copy link
Contributor Author

Pydantic seems to provide interesting solutions for the problem exposed above

@leo-desbureaux-tellae
Copy link
Contributor Author

Important improvements on this matter have been proposed in #32.

The chosen approach was this one: "Each agent could store the schema for its own properties in class attributes, and inherit from its parent' schema if needed". However, the generation process of the schemas will hopefully be improved in the future, since it's really not clean at the moment. That's why this issue will stay open.

For now, the important is that schemas can be generated dynamically from Starling, which allows parameters specification, documentation, validation, but also form generation, etc.

@leo-desbureaux-tellae leo-desbureaux-tellae added io Inputs/Outputs enhancement New feature or request and removed enhancement New feature or request labels Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
io Inputs/Outputs
Projects
None yet
Development

No branches or pull requests

1 participant