Skip to content

nestor.settings

NestorParams

Temporary subclass of dict to manage nestor contexts.

To be re-factored as typed dataclasses.

TODO: allow context-based switching (a.k.a matplotlib xParams style) A valid nestor config yaml is formated with these feilds:

entities:
  types:
    atomic:
        code: description
        ...
    derived:
        ...
    hole:
        ...
  rules:
    code:
      - [codeA,codeB]
      ...
    ...

datatypes:
    ...

For the default nestor.CFG, we provide a schema based on nestor's roots in manufacturing maintenance:

token_patt = '(?u)\w\w+'
entities:
  types:
    'atomic': # atomic types
      'P': 'Problem'
      'I': 'Item'
      'S': 'Solution'
    'derived':  # only made from atoms
      'PI': 'Object Fault'
      'SI': 'Object Resolution'
    'hole':
      'U': 'Unknown'
      'X': 'Non Entity'
      # 'NA': 'Not Annotated'

  rules:
    # two items makes one new item
    'I':
      - ['I','I']
    'PI':
      - ['P','I']
    'SI':
      - ['S','I']
    # redundancies
    'X':
      - ['P', 'P']
      - ['S', 'S']
      - ['P', 'S']
  # note: could try ordered as 'X':{1:'P',2:'S'}, etc.

datatypes:
  issue:
    description:
      problem: 'Description of Problem'
      solution: 'Description of Solution'
      cause: 'Description of Cause'
      effect: 'Description of Observed Symptoms (Effects)'
    machine_down: 'Machine Up/Down'
    necessary_part: 'Necessary Part'
    part_in_process: 'Part in Process'
    cost: 'Maintenance Cost'
    id: 'MWO ID Number'
    date:
      machine_down: 'Machine Down Time-stamp'
      workorder_start: 'Work Order Start Time-stamp'
      maintenance_technician_arrive: 'Maintenance Technician Arrives Time-stamp'
      solution_found: 'Problem Found Time-stamp'
      part_ordered: 'Part(s) Ordered Time-stamp'
      part_received: 'Part(s) Received Time-stamp'
      solution_solve: 'Problem Solved Time-stamp'
      machine_up: 'Machine Up Time-stamp'
      workorder_completion: 'Work Order Completion Time-stamp'

  technician:
    name: 'Maintenance Technician'
    skills: 'Skill(s)'
    crafts: 'Craft(s)'

  operator:
    name: 'Operator'

  machine:
    name: 'Asset ID'
    manufacturer: 'Original Equipment Manufacturer'
    type: 'Machine Type'

  location:
    name: "Location"
While future releases are focused on bringing more flexibility to users to define their own types, it is still possible to use these settings for a wide variety of tasks.

find any datatype that has a specific key

Source code in nestor/settings.py
def datatype_search(self, property_name):
    """find any datatype that has a specific key"""
    return find_path_from_key(self["datatypes"], property_name)

nestor_params()

Function to instantiate a :class:nestor.NestorParams instance from the default nestor config/type .yaml files

For now, provides the default settings.yaml, based on maintenance work-orders.

Returns:

Type Description
nestor.NestorParams

context-setting config object for other nestor behavior

Source code in nestor/settings.py
def nestor_params():
    """Function to instantiate a :class:`nestor.NestorParams` instance from
    the default nestor config/type .yaml files

    For now, provides the default `settings.yaml`, based on maintenance work-orders.

    Returns:
        nestor.NestorParams: context-setting config object for other nestor behavior
    """
    fnames = nestor_fnames()
    # could check they exist, probably
    return nestor_params_from_files(fnames)

nestor_params_from_files(fname)

Build up a nestor.NestorParams object from a passed config file locations

Parameters:

Name Type Description Default
fname pathlib.Path

location of a valid .yaml that defines a NestorParams object

required

Returns:

Type Description
nestor.NestorParams

context-setting config object for other nestor behavior

Source code in nestor/settings.py
def nestor_params_from_files(fname):
    """
    Build up a `nestor.NestorParams` object from a passed config file locations

    Args:
        fname (pathlib.Path): location of a valid `.yaml` that defines a NestorParams object

    Returns:
        nestor.NestorParams: context-setting config object for other nestor behavior
    """

    settings_dict = yaml.safe_load(open(fname))
    cfg = NestorParams(**settings_dict)
    return cfg