lkmltools.linter package

Submodules

lkmltools.linter.field_rule module

abstract base / interface for a field rule

Authors:

Carl Anderson (carl.anderson@weightwatchers.com)

class lkmltools.linter.field_rule.FieldRule(config_dict=None)

Bases: lkmltools.abstract_rule.AbstractRule

concept of a rule that is applied to some view field: dimension, dimension_group, or measure

name()

name of the the rule

Returns

name of the the rule

abstract run(lookml_field)

run the rule

Parameters

lookml (LookMLField) – LookMLField instance

Returns

tuple containing:

relevant (bool): is this rule relevant for this JSON chunk?

passed (bool): did the rule pass?

Return type

(tuple)

lkmltools.linter.lookml_linter module

LookML linter: applies set of rules to some LookML file

Authors:

Carl Anderson (carl.anderson@weightwatchers.com)

class lkmltools.linter.lookml_linter.LookMlLinter(config)

Bases: object

A LookML linter that lints a set of LookML files specified in some config using a set of rules, specified in same config

initialize_rules(config)

create the set of rules, as specified in the config file

Parameters

config (JSON) – the config

Returns

nothing. side effect is to create internal list of file level rules and internal list of field level rules

other_rules_to_run()

Get set of other rules to run

Returns

set of names of rules

Return type

out (set)

run()

run the set of file and field-level rules against all files in the file glob

Returns

nothing. Saves two CSV files, specified in the config

run_field_rules(v, single_key, plural_key, simple_filepath, field_out)
run the set of field-level rules against some json_data, that came from simple_filepath,

and append results to field_out list

Parameters
  • v (JSON) – list of views

  • single_key (str) – e.g. dimension

  • plural_key (str) – e.g. dimensions

  • simple_fileapath (str) – path to some file

  • field_out (list) – list of results for field-level rules

Returns

input field_out list with additional dictionary results

run_file_rules(lookml, simple_filepath, file_out)
run the set of file level rules against some json_data, that came from simple_filepath,

and append results to file_out list

Parameters
  • lookml (LookML) – instance of LookML

  • simple_fileapath (str) – path to some file

  • file_out (list) – list of results for file-level rules

Returns

input file_out list with additional dictionary results

write_field_csv(df)

write field data to CSV :param df: dataframe :type df: pandas dataframe

Returns

nothing. Writes data to CSV

write_file_csv(df)

write file data to CSV

Parameters

df (pandas dataframe) – dataframe

Returns

nothing. Writes data to CSV

lkmltools.linter.rule module

abstract base / interface for a rule

Authors:

Carl Anderson (carl.anderson@weightwatchers.com)

class lkmltools.linter.rule.Rule(config_dict=None)

Bases: lkmltools.abstract_rule.AbstractRule

concept of a rule that is applied to some LookML

name()

name of the the rule

Returns

name of the the rule

abstract run(lookml)

run the rule

Parameters

lookml (LookML) – LookML instance

Returns

tuple containing:

relevant (bool): is this rule relevant for this JSON chunk?

passed (bool): did the rule pass?

Return type

(tuple)

lkmltools.linter.rule_factory module

a rule factory

Authors:

Carl Anderson (carl.anderson@weightwatchers.com)

class lkmltools.linter.rule_factory.RuleFactory

Bases: object

Singleton Factory where one can register Rules for instantiation

__getattr__(name)

getattr with instance name

Returns

gettattr

instance = None

Module contents