optiwindnet.db ============== .. py:module:: optiwindnet.db Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/optiwindnet/db/migrate/index Package Contents ---------------- .. py:class:: Machine(*args, **kwargs) Bases: :py:obj:`BaseModel` .. py:attribute:: id .. py:attribute:: name .. py:attribute:: attrs .. py:class:: Method(*args, **kwargs) Bases: :py:obj:`BaseModel` .. py:attribute:: digest .. py:attribute:: solver_name .. py:attribute:: funname .. py:attribute:: options .. py:attribute:: timestamp .. py:attribute:: funfile .. py:attribute:: funhash .. py:class:: NodeSet(*args, **kwargs) Bases: :py:obj:`BaseModel` .. py:attribute:: digest .. py:attribute:: name .. py:attribute:: T .. py:attribute:: R .. py:attribute:: B .. py:attribute:: VertexC .. py:attribute:: constraint_groups .. py:attribute:: constraint_vertices .. py:attribute:: landscape_angle .. py:class:: RouteSet(*args, **kwargs) Bases: :py:obj:`BaseModel` .. py:attribute:: id .. py:attribute:: handle .. py:attribute:: T .. py:attribute:: R .. py:attribute:: capacity .. py:attribute:: length .. py:attribute:: runtime .. py:attribute:: feeders_per_root .. py:attribute:: C .. py:attribute:: D .. py:attribute:: creator .. py:attribute:: detextra .. py:attribute:: num_diagonals .. py:attribute:: tentative .. py:attribute:: rogue .. py:attribute:: timestamp .. py:attribute:: misc .. py:attribute:: clone2prime .. py:attribute:: edges .. py:attribute:: nodes .. py:attribute:: method .. py:attribute:: machine .. py:function:: database_connection(filepath: str, create_db: bool = False, timeout: int = _DEFAULT_SQLITE_TIMEOUT) Open the sqlite database for the duration of a context block. :param filepath: path to database file :param create_db: True -> create a new file if it does not exist :param timeout: seconds to wait for a locked database to be released :Yields: Connected SqliteDatabase object (Peewee) .. py:function:: open_database(filepath: str, create_db: bool = False, timeout: int = _DEFAULT_SQLITE_TIMEOUT) -> peewee.SqliteDatabase Opens the sqlite database v3 file specified in `filepath`. :param filepath: path to database file :param create_db: True -> create a new file if it does not exist :param timeout: seconds to wait for a locked database to be released :returns: SqliteDatabase object (Peewee) .. py:function:: G_by_method(G: networkx.Graph, method: optiwindnet.db.model.Method) -> networkx.Graph Fetch from the database a layout for `G` by `method`. `G` must be a layout solution with the necessary info in the G.graph dict. `method` is a Method. .. py:function:: G_from_routeset(routeset: optiwindnet.db.model.RouteSet) -> networkx.Graph Translate a RouteSet database entry to a routeset graph. :param routeset: an entry from the database RouteSet table. :returns: Graph G containing the routeset. .. py:function:: Gs_from_attrs(farm: object, methods: optiwindnet.db.model.Method | collections.abc.Sequence[object], capacities: int | collections.abc.Sequence[int]) -> list[tuple[networkx.Graph]] Fetch from the database a list (one per capacity) of tuples (one per method) of layouts. `farm` must have the desired NodeSet name in the `name` attribute. `methods` is a (sequence of) Method instance(s). `capacities` is a (sequence of) int(s). .. py:function:: L_from_nodeset(nodeset: optiwindnet.db.model.NodeSet, handle: str | None = None) -> networkx.Graph Translate a NodeSet database entry to a location graph. :param nodeset: an entry from the database NodeSet table. :returns: Graph L containing the positions and location metadata. .. py:function:: store_G(G: networkx.Graph) -> int Store `G`'s data to a new `RouteSet` record in the database. If the NodeSet or Method are not yet in the database, they will be added. :param G: Graph with the routeset. :returns: Primary key of the newly created RouteSet record.