optiwindnet.db¶

Submodules¶

Package Contents¶

class optiwindnet.db.Machine(*args, **kwargs)[source]¶

Bases: BaseModel

id¶
name¶
attrs¶
class optiwindnet.db.Method(*args, **kwargs)[source]¶

Bases: BaseModel

digest¶
solver_name¶
funname¶
options¶
timestamp¶
funfile¶
funhash¶
class optiwindnet.db.NodeSet(*args, **kwargs)[source]¶

Bases: BaseModel

digest¶
name¶
T¶
R¶
B¶
VertexC¶
constraint_groups¶
constraint_vertices¶
landscape_angle¶
class optiwindnet.db.RouteSet(*args, **kwargs)[source]¶

Bases: BaseModel

id¶
handle¶
T¶
R¶
capacity¶
length¶
runtime¶
feeders_per_root¶
C¶
D¶
creator¶
detextra¶
num_diagonals¶
tentative¶
rogue¶
timestamp¶
misc¶
clone2prime¶
edges¶
nodes¶
method¶
machine¶
optiwindnet.db.database_connection(filepath: str, create_db: bool = False, timeout: int = _DEFAULT_SQLITE_TIMEOUT)[source]¶

Open the sqlite database for the duration of a context block.

Parameters:
  • filepath – path to database file

  • create_db – True -> create a new file if it does not exist

  • timeout – seconds to wait for a locked database to be released

Yields:

Connected SqliteDatabase object (Peewee)

optiwindnet.db.open_database(filepath: str, create_db: bool = False, timeout: int = _DEFAULT_SQLITE_TIMEOUT) peewee.SqliteDatabase[source]¶

Opens the sqlite database v3 file specified in filepath.

Parameters:
  • filepath – path to database file

  • create_db – True -> create a new file if it does not exist

  • timeout – seconds to wait for a locked database to be released

Returns:

SqliteDatabase object (Peewee)

optiwindnet.db.G_by_method(G: networkx.Graph, method: optiwindnet.db.model.Method) networkx.Graph[source]¶

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.

optiwindnet.db.G_from_routeset(routeset: optiwindnet.db.model.RouteSet) networkx.Graph[source]¶

Translate a RouteSet database entry to a routeset graph.

Parameters:

routeset – an entry from the database RouteSet table.

Returns:

Graph G containing the routeset.

optiwindnet.db.Gs_from_attrs(farm: object, methods: optiwindnet.db.model.Method | collections.abc.Sequence[object], capacities: int | collections.abc.Sequence[int]) list[tuple[networkx.Graph]][source]¶

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).

optiwindnet.db.L_from_nodeset(nodeset: optiwindnet.db.model.NodeSet, handle: str | None = None) networkx.Graph[source]¶

Translate a NodeSet database entry to a location graph.

Parameters:

nodeset – an entry from the database NodeSet table.

Returns:

Graph L containing the positions and location metadata.

optiwindnet.db.store_G(G: networkx.Graph) int[source]¶

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.

Parameters:

G – Graph with the routeset.

Returns:

Primary key of the newly created RouteSet record.