ch_util._db_tables

Private module for defining the DB tables with the peewee ORM.

These are imported into the layout and finder modules.

Module Attributes

EVENT_AT

Return events at the specified time.

EVENT_BEFORE

Return events before the specified time.

EVENT_AFTER

Return events after the specified time.

EVENT_ALL

Return all events (and ignore any specified time).

ORDER_ASC

Order search results in ascending order.

ORDER_DESC

Order search results in descending order.

Functions

add_component(comp[, time, notes, force])

Make one or more components available with a common timestamp.

compare_connexion(conn1, conn2)

See if two connexions are the same.

connect_peewee_tables([read_write, reconnect])

Initialize the connection to the CHIME data index database.

make_connexion(conn[, time, permanent, ...])

Connect one or more component pairs with a common timestamp.

remove_component(comp[, time, notes, force])

End availability of one or more components with a common timestamp.

set_property(comp, type, value[, time, ...])

Set a property value for one or more components with a common timestamp.

set_user(u)

Identify yourself as a user, for record keeping.

sever_connexion(conn[, time, notes, force])

Sever one or more component pairs with a common timestamp.

Classes

component(*args, **kwargs)

A CHIME component.

component_doc(*args, **kwargs)

For linking a component to a document in an external repository.

component_history(*args, **kwargs)

For providing history information on a component.

component_type(*args, **kwargs)

A CHIME component type.

component_type_rev(*args, **kwargs)

A CHIME component type revision.

connexion(*args, **kwargs)

A connexion between two components.

event(*args, **kwargs)

An event, or timestamp, for something graphy.

event_table(*args, **kwargs)

Baseclass for all models which are linked to the event class.

event_type(*args, **kwargs)

For differentiating event types.

external_repo(*args, **kwargs)

Information on an external repository.

global_flag(*args, **kwargs)

A simple flag index for global flags.

global_flag_category(*args, **kwargs)

Categories for global flags.

graph_obj(*args, **kwargs)

Parent table for any table that has events associated with it.

predef_subgraph_spec(*args, **kwargs)

A specification for a subgraph of a full graph.

predef_subgraph_spec_param(*args, **kwargs)

Parameters for a subgraph specification.

property(*args, **kwargs)

A property associated with a particular component.

property_component(*args, **kwargs)

A list associating property types with components.

property_type(*args, **kwargs)

A component property type.

timestamp(*args, **kwargs)

A timestamp.

user_permission(*args, **kwargs)

Specifies users' permissions.

user_permission_type(*args, **kwargs)

Defines permissions for the DB interface.

Exceptions

BadSubgraph

Raise when an error in subgraph specification is made.

ClosestDraw

There is a draw for the shortest path to a given component type.

DoesNotExist

The event does not exist at the specified time.

LayoutIntegrity

Action would harm the layout integrity.

NoPermission

User does not have permission for a task.

NoSubgraph

Raise when a subgraph specification is missing.

PropertyType

Bad property type.

PropertyUnchanged

A property change was requested, but no change is needed.

UnknownUser

The user requested is unknown.

exception ch_util._db_tables.BadSubgraph[source]

Bases: CHIMEdbError

Raise when an error in subgraph specification is made.

exception ch_util._db_tables.ClosestDraw[source]

Bases: CHIMEdbError

There is a draw for the shortest path to a given component type.

exception ch_util._db_tables.DoesNotExist[source]

Bases: CHIMEdbError

The event does not exist at the specified time.

ch_util._db_tables.EVENT_AFTER = 2

Return events after the specified time.

ch_util._db_tables.EVENT_ALL = 3

Return all events (and ignore any specified time).

ch_util._db_tables.EVENT_AT = 0

Return events at the specified time.

ch_util._db_tables.EVENT_BEFORE = 1

Return events before the specified time.

exception ch_util._db_tables.LayoutIntegrity[source]

Bases: CHIMEdbError

Action would harm the layout integrity.

exception ch_util._db_tables.NoPermission[source]

Bases: CHIMEdbError

User does not have permission for a task.

exception ch_util._db_tables.NoSubgraph[source]

Bases: CHIMEdbError

Raise when a subgraph specification is missing.

ch_util._db_tables.ORDER_ASC = 0

Order search results in ascending order.

ch_util._db_tables.ORDER_DESC = 1

Order search results in descending order.

exception ch_util._db_tables.PropertyType[source]

Bases: CHIMEdbError

Bad property type.

exception ch_util._db_tables.PropertyUnchanged[source]

Bases: CHIMEdbError

A property change was requested, but no change is needed.

exception ch_util._db_tables.UnknownUser[source]

Bases: CHIMEdbError

The user requested is unknown.

ch_util._db_tables.add_component(comp, time=datetime.datetime(2024, 6, 25, 23, 35, 49, 993016), notes=None, force=False)[source]

Make one or more components available with a common timestamp.

If you are adding only one component, this function is equivalent to calling component.add(). However, multiple calls to component.add() generate a unique timestamp per call. To assign a single timestamp to many additions at once, use this function.

Examples

>>> lna_type = layout.component_type.get(name = "LNA")
>>> lna_rev = lna_type.rev.where(layout.component_type_rev.name == "B").get()
>>> c = []
>>> for i in range(0, 10):
...   c.append(layout.component(sn = "LNA%04dB" % (i), type = lna_type, rev = lna_rev))
>>> layout.add_component(c, time = datetime(2014, 10, 10, 11), notes = "Adding many at once.")
Parameters:
  • comp (list of component objects) – The components to make available.

  • time (datetime.datetime) – The time at which to make the components available.

  • notes (string) – Any notes for the timestamp.

  • force (bool) – If True, then add any components that can be added, while doing nothing (except making note of such in the logger) for components whose addition would violate database integrity. If False, AlreadyExists is raised for any addition that violates database integrity.

ch_util._db_tables.compare_connexion(conn1, conn2)[source]

See if two connexions are the same. Because the connexion could store the two components in different orders, or have different instances of the same component object, direct comparison may fail. This function explicitly compares both possible combinations of serial numbers.

Parameters:
  • conn1 (connexion) – The first connexion object.

  • conn2 (connexion) – The second connexion object.

Return type:

True if the connexions are the same, False otherwise.

class ch_util._db_tables.component(*args, **kwargs)[source]

Bases: event_table

A CHIME component.

To add or remove components, use the add() and remove() methods. There are also methods for getting and setting component properties, history and documents.

id

The ID shared with parent table graph_obj.

Type:

foreign key, primary key

sn

The unique serial number of the component.

Type:

string, unique

type

The component type.

Type:

foreign key

type_rev

The revision of this component.

Type:

foreign key

DoesNotExist

alias of componentDoesNotExist

add(time=datetime.datetime(2024, 6, 25, 23, 35, 49, 990261), notes=None, force=True)[source]

Add this component.

This triggers the “component available” event.

To add many components at once, see add_component().

Examples

The following makes a new LNA available:

>>> lna_type = layout.component_type.get(name = "LNA")
>>> lna_rev = lna_type.rev.where(layout.component_type_rev.name == "B").get()
>>> comp = layout.component(sn = "LNA0000A", type = lna_type, rev = lna_type.rev).add()
Parameters:
  • time (datetime.datetime) – The time at which the component is to be made available.

  • notes (string) – Any notes for the timestamp.

  • force (bool) – If False, then raise AlreadyExists if this event creates a conflict; otherwise, do not add but ignore on conflict.

Returns:

self

Return type:

component

add_doc(repo, ref, time=datetime.datetime(2024, 6, 25, 23, 35, 49, 990267), notes=None)[source]

Add a document pointer for this component.

Parameters:
  • repo (external_repo) – The place where the document is.

  • ref (string) – A path or similar pointer, relevative to the root of repo.

  • time (datetime.datetime) – The time at which the document pointer is to be added.

  • notes (string) – Any notes for the timestamp.

Returns:

history – The newly-created document pointer object.

Return type:

component_doc

add_history(notes, time=datetime.datetime(2024, 6, 25, 23, 35, 49, 990266), timestamp_notes=None)[source]

Add a history item for this component.

Parameters:
  • notes (string) – The history note.

  • time (datetime.datetime) – The time at which the history is to be added.

  • timestamp_notes (string) – Any notes for the timestamp.

Returns:

history – The newly-created component history object.

Return type:

component_history

get_connexion(comp=None, time=datetime.datetime(2024, 6, 25, 23, 35, 49, 990256), when=0, order=0, active=True)[source]

Get connexions involving this component.

Parameters:
  • comp (component) – If this parameter is set, then search for connexions between this component and comp.

  • time (datetime.datetime) – Event time.

  • when (int) – Event when.

  • order (int) – Event order.

  • active (bool) – Event active.

Return type:

A peewee.SelectQuery for connexion entries.

get_doc(time=datetime.datetime(2024, 6, 25, 23, 35, 49, 990260))[source]

Get document pointers associated with this component.

Parameters:

time (datetime.datetime) – The time at which the document events should be active.

Return type:

A peewee.SelectQuery for component_doc entries.

get_history(time=datetime.datetime(2024, 6, 25, 23, 35, 49, 990258), when=0, order=0, active=True)[source]

Get history items associated with this component.

Parameters:
  • time (datetime.datetime) – Event time.

  • when (int) – Event when.

  • order (int) – Event order.

  • active (bool) – Event active.

Return type:

A peewee.SelectQuery for history entries.

get_property(type=None, time=datetime.datetime(2024, 6, 25, 23, 35, 49, 990268))[source]

Get a property for this component.

Parameters:
  • type (property_type) – The property type to search for.

  • time (obj:datetime.datetime) – The time at which to get the property.

Returns:

property – If no property is set, then None is returned.

Return type:

string

remove(time=datetime.datetime(2024, 6, 25, 23, 35, 49, 990262), notes=None, force=False)[source]

Remove this component.

This ends the “component available” event.

To remove many components at once, see remove_component().

Parameters:
  • time (datetime.datetime) – The time at which the component is to be removed.

  • notes (string) – Any notes for the timestamp.

  • force (bool) – If False, then raise DoesNotExist if this event creates a conflict; otherwise, do not add but ignore on conflict.

set_property(type, value, time=datetime.datetime(2024, 6, 25, 23, 35, 49, 990269), notes=None)[source]

Set a property for this component.

Parameters:
  • type (property_type) – The property type to search for.

  • value (string) – The value to set.

  • time (obj:datetime.datetime) – The time at which to get the property.

  • notes (string) – Notes for the timestamp.

Raises:
  • :exc:ValueError:, if value does not conform to the property regular

  • expression.

class ch_util._db_tables.component_doc(*args, **kwargs)[source]

Bases: event_table

For linking a component to a document in an external repository.

id

The ID shared with parent table graph_obj.

Type:

foreign key, primary key

comp

The component linked to the document.

Type:

foreign key

repo

The repository holding the document.

Type:

foreign key

ref

The location of the document within the repository (e.g., a filename).

Type:

string

DoesNotExist

alias of component_docDoesNotExist

class ch_util._db_tables.component_history(*args, **kwargs)[source]

Bases: event_table

For providing history information on a component.

id

The ID shared with parent table graph_obj.

Type:

foreign key, primary key

comp

The component linked to the history.

Type:

foreign key

notes

The history information.

Type:

string

DoesNotExist

alias of component_historyDoesNotExist

class ch_util._db_tables.component_type(*args, **kwargs)[source]

Bases: name_table

A CHIME component type. Examples of component types are antennas, 60m coaxial cables, and so on.

name

The name of the component type.

Type:

string

notes

An (optional) description of the component type.

Type:

string

DoesNotExist

alias of component_typeDoesNotExist

class ch_util._db_tables.component_type_rev(*args, **kwargs)[source]

Bases: name_table

A CHIME component type revision.

Component types can, optionally, have revisions. For example, when an antenna design changes, a new revision is introduced.

type

The component type this revision applies to.

Type:

foreign key

name

The name of the component type.

Type:

string

notes

An (optional) description of the component type.

Type:

string

DoesNotExist

alias of component_type_revDoesNotExist

ch_util._db_tables.connect_peewee_tables(read_write=False, reconnect=False)[source]

Initialize the connection to the CHIME data index database.

This function uses the current database connector from core to establish a connection to the CHIME data index. It must be called if you change the connection method after importing this module. Or if you wish to connect with both read and write privileges.

Parameters:
  • read_write (bool) – Whether to connect with read and write privileges.

  • reconnect (bool) – Force a reconnection.

class ch_util._db_tables.connexion(*args, **kwargs)[source]

Bases: event_table

A connexion between two components.

This should always be instatiated using the from_pair() method.

id

The ID shared with parent table graph_obj.

Type:

foreign key, primary key

comp1

The first component in the connexion.

Type:

foreign key

comp2

The second component in the connexion.

Type:

foreign key

DoesNotExist

alias of connexionDoesNotExist

classmethod from_pair(comp1, comp2, allow_new=True)[source]

Get a connexion given a pair of components.

Parameters:
  • comp1 (str or component) – Pass either the serial number or a component object.

  • comp2 (str or component) – Pass either the serial number or a component object.

  • allow_new (bool) – If False, then raise peewee.DoesNotExist if the connexion does not exist at all in the database.

Returns:

connexion

Return type:

connexion

is_connected(time=datetime.datetime(2024, 6, 25, 23, 35, 49, 990902))[source]

See if a connexion exists.

Connexions whose events have been deactivated are not included.

Parameters:

time (datetime) – The time at which to check whether the connexion exists.

Returns:

connectedTrue if there is a connexion, otherwise False.

Return type:

bool

Raises:

peewee.DoesNotExist – Raised if one or both of the components does not exist.

is_permanent(time=datetime.datetime(2024, 6, 25, 23, 35, 49, 990903))[source]

See if a permenant connexion exists.

Connexions whose events have been deactivated are not included.

Parameters:

time (datetime) – The time at which to check whether the connexion exists.

Returns:

connectedTrue if there is a permanent connexion, otherwise False.

Return type:

bool

Raises:

peewee.DoesNotExist – Raised if one or both of the components does not exist.

make(time=datetime.datetime(2024, 6, 25, 23, 35, 49, 990905), permanent=False, notes=None, force=False)[source]

Create a connexion. This method begins a connexion event at the specified time.

Parameters:
  • time (datetime.datetime) – The time at which to begin the connexion event.

  • permanent (bool) – If True, then make this a permanent connexion.

  • notes (string) – Any notes for the timestamp.

  • force (bool) – If False, then AlreadyExists will be raised if the connexion already exists; otherwise, conflicts will be ignored and nothing will be done.

Returns:

connexion

Return type:

connexion

other_comp(comp)[source]

Given one component in the connexion, return the other.

Parameters:

comp (component) – The component you know in the connexion.

Returns:

The other component in the connexion, i.e., the one that isn’t comp.

Return type:

component

Raises:

DoesNotExist – If comp is not part of this connexion, an exception occurs.

sever(time=datetime.datetime(2024, 6, 25, 23, 35, 49, 990906), notes=None, force=False)[source]

Sever a connexion. This method ends a connexion event at the specified time.

Parameters:
  • time (datetime.datetime) – The time at which to end the connexion event.

  • notes (string) – Any notes for the timestamp.

  • force (bool) – If False, then DoesNotExists will be raised if the connexion does not exist; otherwise, conflicts will be ignored and nothing will be done.

class ch_util._db_tables.event(*args, **kwargs)[source]

Bases: base_model

An event, or timestamp, for something graphy.

Never manually create, delete or alter events! Doing so can damage the integrity of the database.

To interact with events, use:

You can safely deactivate an event using deactivate(); this method only allows deactivation if it will not damage the database integrity.

active

Is this event active? (Instead of deleting events, we deactivate them.)

Type:

bool

replaces

Instead of editing events, we replace them, so that we have a history of event edits. This key indicates which event (if any) this event replaces.

Type:

foreign key

graph_obj

Which graph object is this event about?

Type:

foreign key

type

What kind of event is it?

Type:

foreign key

start

The timestamp for the event start.

Type:

foreign key

end

The timestamp for the event end.

Type:

foreign key

DoesNotExist

alias of eventDoesNotExist

deactivate()[source]

Deactivate an event.

Events are never deleted; rather, the active flag is switched off. This method first checks to see whether doing so would break database integrity, and only deactivates if it will not.

Raises:

:exc:LayoutIntegrity – if deactivating will compromise layout integrity.:

class ch_util._db_tables.event_table(*args, **kwargs)[source]

Bases: base_model

Baseclass for all models which are linked to the event class.

DoesNotExist

alias of event_tableDoesNotExist

event(self, time=datetime.datetime.now(), type=None, when=EVENT_ALL, order=None, active=True)[source]

Find events associated with entries in this table.

Parameters:
  • time (datetime.datetime) – Event time.

  • type (event_type) – Only get events of the specified type.

  • when (int) – Event when.

  • order (int or None) – Event order.

  • active (bool) – Event active.

Returns:

event

Return type:

peewee.SelectQuery

class ch_util._db_tables.event_type(*args, **kwargs)[source]

Bases: name_table

For differentiating event types.

The class methods comp_avail(), connexion() and so on return event type instances, and internally store the result. Thus, subsequent calls do not generate more database queries. This can reduce overhead.

name

The name of the event type.

Type:

string

human_name

A proper, English name.

Type:

string

assoc_table

The (optional) table that this event is about; it should be a child of graph_obj.

Type:

string

no_end

If ‘Y’, then this is an “instantaneous” event, i.e., there will never be recorded an end.

Type:

enum(‘Y’, ‘N’)

require_notes

If ‘Y’, then the notes of the event _must_ be set.

Type:

enum(‘Y’, ‘N’)

notes

Any notes about this event type.

Type:

string

DoesNotExist

alias of event_typeDoesNotExist

classmethod comp_avail()[source]

For getting the component available event type.

classmethod comp_doc()[source]

For getting the component document event type.

classmethod comp_history()[source]

For getting the component history event type.

classmethod connexion()[source]

For getting the connexion event type.

classmethod perm_connexion()[source]

For getting the permanent connexion event type.

classmethod property()[source]

For getting the property event type.

class ch_util._db_tables.external_repo(*args, **kwargs)[source]

Bases: name_table

Information on an external repository.

name

The name of the repository.

Type:

string

root

Its location, e.g., a URL onto which individual paths to files can be appended.

Type:

string

notes

Any notes about this repository.

Type:

string

DoesNotExist

alias of external_repoDoesNotExist

class ch_util._db_tables.global_flag(*args, **kwargs)[source]

Bases: event_table

A simple flag index for global flags.

id

The ID shared with parent table graph_obj.

Type:

foreign key, primary key

category

The category of flag.

Type:

foreign key

severity

An indication of how the data finder should react to this flag.

Type:

enum(‘comment’, ‘warning’, ‘severe’)

inst

The acquisition instrument, if any, affected by this flag.

Type:

foreign key

name

A short description of the flag.

Type:

string

notes

Notes about the global flag.

Type:

string

DoesNotExist

alias of global_flagDoesNotExist

end(time=datetime.datetime(2024, 6, 25, 23, 35, 49, 989433), notes=None)[source]

End this global flag.

See global_flag.start() for an example.

Parameters:
  • time (datetime.datetime) – The time at which the flag is to end.

  • notes (string) – Any notes for the timestamp.

Returns:

self

Return type:

global_flag

Raises:
  • AlreadyExists

  • if it has not been started.

start(time=datetime.datetime(2024, 6, 25, 23, 35, 49, 989431), notes=None)[source]

Start this global flag.

Examples

The following starts and ends a new global flag.

>>> cat = layout.global_flag_category.get(name = "pass")
>>> flag = layout.global_flag(category = cat, severity = "comment", name = "run_pass12_a").start(time = datetime.datetime(2015, 4, 1, 12))
>>> flag.end(time = datetime.datetime(2015, 4, 5, 15, 30))
Parameters:
  • time (datetime.datetime) – The time at which the flag is to start.

  • notes (string) – Any notes for the timestamp.

Returns:

self

Return type:

global_flag

Raises:

AlreadyExists

class ch_util._db_tables.global_flag_category(*args, **kwargs)[source]

Bases: base_model

Categories for global flags. Examples of component types are antennas, 60m coaxial cables, and so on.

name

The name of the category.

Type:

string

notes

An (optional) description of the category.

Type:

string

DoesNotExist

alias of global_flag_categoryDoesNotExist

class ch_util._db_tables.graph_obj(*args, **kwargs)[source]

Bases: base_model

Parent table for any table that has events associated with it. This is a way to make the event table polymorphic. It points to this table, which shares (unique) primary keys with child tables (e.g., component). It only has one key: ID.

id
DoesNotExist

alias of graph_objDoesNotExist

ch_util._db_tables.make_connexion(conn, time=datetime.datetime(2024, 6, 25, 23, 35, 49, 993023), permanent=False, notes=None, force=False)[source]

Connect one or more component pairs with a common timestamp.

If you are connecting only one pair, this function is equivalent to calling connexion.make(). However, multiple calls to connexion.make() generate a unique timestamp per call. To assign a single timestamp to many connexions at once, use this function.

Examples

>>> conn = []
>>> for i in range(0, 10):
...  comp1 = layout.component.get(sn = "LNA%04dB" % (i))
...  comp2 = layout.component.get(sn = "CXA%04dB"% (i))
...  conn.append(layout.connexion.from_pair(comp1, comp2))
>>> layout.make_connexion(conn, time = datetime(2013, 10, 11, 23, 15), notes = "Making multiple connexions at once.")
Parameters:
  • comp (list of connexion objects) – The connexions to make.

  • time (datetime.datetime) – The time at which to end availability.

  • notes (string) – Any notes for the timestamp.

  • force (bool) – If True, then remove any components that can be removed, while doing nothing (except making note of such in the logger) for components whose removal would violate database integrity. If False, DoesNotExist is raised for any addition that violates database integrity.

class ch_util._db_tables.predef_subgraph_spec(*args, **kwargs)[source]

Bases: name_table

A specification for a subgraph of a full graph.

name

The name of this subgraph specification.

Type:

string

start_type

The starting component type.

Type:

foreign key

notes

Optional notes about this specification.

Type:

string

DoesNotExist

alias of predef_subgraph_specDoesNotExist

class ch_util._db_tables.predef_subgraph_spec_param(*args, **kwargs)[source]

Bases: base_model

Parameters for a subgraph specification.

predef_subgraph_spec

The subgraph which this applies.

Type:

foreign key

type1

A component type.

Type:

foreign key

type2

A component type.

Type:

foreign key

action

The role of this component type: - T: terminate at type1 (type2 is left NULL). - H: hide type1 (type2 is left NULL). - O: only draw connexions one way between type1 and type2.

Type:

enum(‘T’, ‘H’, ‘O’)

DoesNotExist

alias of predef_subgraph_spec_paramDoesNotExist

class ch_util._db_tables.property(*args, **kwargs)[source]

Bases: event_table

A property associated with a particular component.

id

The ID shared with parent table graph_obj.

Type:

foreign key, primary key

comp

The component to which this property belongs.

Type:

foreign key

type

The property type.

Type:

foreign key

value

The actual property.

Type:

string

DoesNotExist

alias of propertyDoesNotExist

class ch_util._db_tables.property_component(*args, **kwargs)[source]

Bases: base_model

A list associating property types with components. A property can be for one or more component types. For example, “dist_from_n_end” is only a property of cassettes, but “termination” may be a property of LNA’s, FLA’s and so on. This is simply a table for matching property types to component types.

prop_type

The property type to be mapped.

Type:

foreign key

comp_type

The component type to be mapped.

Type:

foreign key

DoesNotExist

alias of property_componentDoesNotExist

class ch_util._db_tables.property_type(*args, **kwargs)[source]

Bases: name_table

A component property type.

name

The name of the property type (e.g., “attenuation”).

Type:

string

units

The (optional) units of the property (e.g., “dB”).

Type:

string

regex

An (optional) regular expression for controlling allowed property values.

Type:

string

notes

Any (optional) notes further explaining the property.

Type:

string

DoesNotExist

alias of property_typeDoesNotExist

ch_util._db_tables.remove_component(comp, time=datetime.datetime(2024, 6, 25, 23, 35, 49, 993021), notes=None, force=False)[source]

End availability of one or more components with a common timestamp.

If you are adding only one component, this function is equivalent to calling component.remove(). However, multiple calls to component.remove() generate a unique timestamp per call. To assign a single timestamp to many additions at once, use this function.

Parameters:
  • comp (list of component objects) – The components to end availability of.

  • time (datetime.datetime) – The time at which to end availability.

  • notes (string) – Any notes for the timestamp.

  • force (bool) – If True, then remove any components that can be removed, while doing nothing (except making note of such in the logger) for components whose removal would violate database integrity. If False, DoesNotExist is raised for any addition that violates database integrity.

ch_util._db_tables.set_property(comp, type, value, time=datetime.datetime(2024, 6, 25, 23, 35, 49, 993022), notes=None, force=False)[source]

Set a property value for one or more components with a common timestamp.

Passing None for the property value erases that property from the component.

If you altering only one component, this function is equivalent to calling component.set_property(). However, multiple calls to component.set_property() generate a unique timestamp per call. To assign a single timestamp to many additions at once, use this function.

Parameters:
  • comp (list of component objects) – The components to assign the property to.

  • type (property_type) – The property type.

  • value (str) – The property value to assign.

  • time (datetime.datetime) – The time at which to end availability.

  • notes (string) – Any notes for the timestamp.

  • force (bool) – If False, then complain if altering the property does nothing (e.g., because the property value would be unchanged for a certain component); otherwise, ignore such situations and merely issue logging information on them.

Raises:
  • :exc:ValueError:, if value does not conform to the property type's regular

  • expression; :exc:PropertyUnchanged – if force is False: and a:

  • component's property value would remain unaltered.

ch_util._db_tables.set_user(u)[source]

Identify yourself as a user, for record keeping.

All events recorded in the database are associated with a user, and not all users have all permissions. You must call this function before making any changes to the database.

Parameters:

u (string or integer) –

One of:
  • your CHIMEwiki username (string). Use an initial capital letter. This is the recommended input.

  • the name entered into the “real name” field in your CHIMEwiki profile

  • your CHIMEwiki integer user_id (not easy to find)

Raises:

UnknownUser

ch_util._db_tables.sever_connexion(conn, time=datetime.datetime(2024, 6, 25, 23, 35, 49, 993024), notes=None, force=False)[source]

Sever one or more component pairs with a common timestamp.

If you are severing only one pair, this function is equivalent to calling connexion.sever(). However, multiple calls to connexion.sever() generate a unique timestamp per call. To assign a single timestamp to many connexion severances at once, use this function.

Examples

>>> conn = []
>>> for i in range(0, 10):
...  comp1 = layout.component.get(sn = "LNA%04dB" % (i))
...  comp2 = layout.component.get(sn = "CXA%04dB"% (i))
...  conn.append(layout.connexion.from_pair(comp1, comp2))
>>> layout.sever_connexion(conn, time = datetime(2014, 10, 11, 23, 15), notes = "Severing multiple connexions at once.")
Parameters:
  • comp (list of connexion objects) – The connexions to sever.

  • time (datetime.datetime) – The time at which to end availability.

  • notes (string) – Any notes for the timestamp.

  • force (bool) – If True, then sever any connexions that can be severed, while doing nothing (except making note of such in the logger) for connexions whose severence would violate database integrity. If False, DoesNotExist is raised for any severence that violates database integrity.

class ch_util._db_tables.timestamp(*args, **kwargs)[source]

Bases: base_model

A timestamp.

time

The timestamp.

Type:

datetime

entry_time

The creation time of the timestamp.

Type:

datetime

user_id

In the actual DB, this is a foreign key to chimewiki.user(user_id), but peewee doesn’t support foreign keys to different schemas.

Type:

foreign key

notes

Any (optional) notes about the timestamp.

Type:

string

DoesNotExist

alias of timestampDoesNotExist

class ch_util._db_tables.user_permission(*args, **kwargs)[source]

Bases: base_model

Specifies users’ permissions.

user_id

In the actual DB, this is a foreign key to chimewiki.user(user_id), but peewee doesn’t support foreign keys to different schemas.

Type:

foreign key

type

The permission type to grant to the user.

Type:

foreign key

DoesNotExist

alias of user_permissionDoesNotExist

class ch_util._db_tables.user_permission_type(*args, **kwargs)[source]

Bases: name_table

Defines permissions for the DB interface.

name

The name of the permission.

Type:

string

notes

An (optional) description of the permission. peewee doesn’t support foreign keys to different schemas.

Type:

string

DoesNotExist

alias of user_permission_typeDoesNotExist