openmobisim.config ================== .. py:module:: openmobisim.config .. autoapi-nested-parse:: The run configuration file, ``run.toml``: every parameter of a run in one file. ``config_write_defaults(path)`` writes the complete file at the shipped defaults (``openmobisim config --defaults`` prints it): every parameter on its own line, its comment giving the default, the meaning and the unit. Change what you want; a line left out keeps its default, so a file holding a few lines is valid. ``config_read(path)`` reads a file back as a ``Config``; ``Scenario.run(config="run.toml")`` and ``openmobisim run --config run.toml`` run one. Every run writes the complete file it ran with, ``run.toml``, beside its ``manifest.json`` (``Run.config()`` reads it back), so a run is repeated from its folder. Nothing is read unless a file is given. The tables, in the order a run is read: ``[inputs]`` (paths, relative to the file), ``[run]``, ``[equilibration]``, ``[choice]``, ``[modes]``, ``[prices]``, ``[services.]`` (a service's ``kind``, its tables as paths, its options), ``[service_assumptions]``, ``[policy]``, ``[network]`` (applied when the network is read), ``[loading]``, ``[routes]``, ``[route_update]``, ``[transit]`` and ``[parking]``. A method's name and its options share a table: ``[equilibration]`` holds ``method = "msa"`` and the method's options. The defaults are those of ``parameters()``, read from the core's defaults table, so the file and the code cannot disagree. Classes ------- .. autoapisummary:: openmobisim.config.Config Functions --------- .. autoapisummary:: openmobisim.config.config_read openmobisim.config.config_write_defaults Module Contents --------------- .. py:class:: Config A run's parameters, as a ``run.toml`` states them (``config_read``) or a run was given. ``values`` holds what is stated, by table (``values["choice"]["beta_time_min"]``; a service's under ``values["services"][name]``); every parameter not stated keeps its default. ``write(path)`` writes the complete file, ``text()`` returns it, ``differences()`` lists what differs from the defaults, ``scenario()`` reads its ``[inputs]`` into a ``Scenario`` and ``run()`` runs it. .. py:method:: differences() The stated parameters that differ from their defaults, as ``table.key``. A service or a policy is listed as a whole (``services.taxi``, ``policy``); the inputs are not parameters. .. py:method:: from_arguments(run_id = None, **arguments) :classmethod: The configuration of a run with these arguments, to write as a file. The keyword arguments of ``Scenario.from_parts`` and ``Scenario.run`` that are parameters (numbers, names, lists of modes, options dicts, services, a policy by name or a built-in one), and ``network_options``; ``run_id`` is the file's ``name``. What a file cannot hold (link values, disruptions, a Python choice model or policy) is listed in ``absent`` and the file's header. :raises TypeError: For an argument that is not one of these, with the list of them. .. py:method:: inputs() The ``[inputs]`` table's paths, resolved against the file's folder (dates as given). .. py:method:: run(output_dir = None, *, overwrite = False, quiet = False) Run the file: ``scenario()``, then ``Scenario.run(config=self)``. .. py:method:: scenario() A ``Scenario`` of the file's ``[inputs]`` (read by the package's readers) and values. ``network`` is read by its kind: a starter case's folder (its ``case.json``), a GMNS folder, an OpenStreetMap ``.osm.pbf`` (both with the file's ``[network]``) or a file ``network_write_cache`` wrote; ``demand`` (required), ``persons`` and ``zones`` are given to ``Scenario.from_parts`` as paths; ``classes`` by ``demand_read_classes``; ``transit`` by ``transit_read_gtfs`` (on ``transit_date``); ``parkings`` by ``parking_read_table`` (a ``.csv``), ``parking_read_osm`` (a ``.pbf``) or ``parking_read_cache``; a service's tables by ``dock_read_table``, ``vehicle_read_table`` and ``charger_read_table``. :raises ValueError: If ``network`` or ``demand`` is missing, or a value is not valid. .. py:method:: text() The complete file: every parameter, stated or at its default, with its comment. .. py:method:: write(path) Write the complete file to ``path`` and return the path. .. py:attribute:: absent :type: list[str] :value: [] .. py:attribute:: folder :type: pathlib.Path | None :value: None .. py:attribute:: name :type: str | None :value: None .. py:attribute:: resolved :type: dict[str, Any] .. py:attribute:: values :type: dict[str, Any] .. py:function:: config_read(path) Read a ``run.toml``: what it states, every name and value checked. Relative paths (``[inputs]``, a service's tables) are resolved against the file's folder when used. A table or a name not in the file's layout is refused with the list of its table's names, a value of the wrong kind with what it should be. :raises FileNotFoundError: If there is no such file. :raises ValueError: If it is not TOML, or a name or value is not valid. .. py:function:: config_write_defaults(path) Write the complete ``run.toml`` at the shipped defaults to ``path``; return the path. Every parameter on its line, its comment giving its default, its meaning and its unit; the inputs, a service and a policy (none by default) as comments to fill in.