gridtest package

Submodules

gridtest.decorators module

Copyright (C) 2020 Vanessa Sochat.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

gridtest.func are short functions that serve as helpers for a gridtest. Any function in here can be referenced as {% func_name %} or with arguments {% func_name arg1=1 arg2=2 %}. If you possibly have a namespace conflict, you can also reference {% gridtest.func.func_name %} and it will work to reference the function here.

gridtest.decorators.length(func)[source]

calculate the length of a result, None if doesn’t have length

gridtest.decorators.result(func)[source]

result will simply capture the result (as a decorator).

gridtest.decorators.timeit(func)[source]

timeit is a well known Python decorator that will time the total executio time for a function. Any output to return to the calling function should be printed to stdout, and prefixed with the name of the objective (e.g., @timeit).

gridtest.defaults module

Copyright (C) 2020 Vanessa Sochat.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

gridtest.defaults.getenv(variable_key, default=None, required=False, silent=True)[source]

attempt to get an environment variable. If the variable is not found, None is returned.

Arguments:

  • variable_key (str) : the variable name

  • required (bool) : exit with error if not found

  • silent (bool) : Do not print debugging information

gridtest.func module

Copyright (C) 2020 Vanessa Sochat.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

gridtest.func are short functions that serve as helpers for a gridtest. Any function in here can be referenced as {% func_name %} or with arguments {% func_name arg1=1 arg2=2 %}. If you possibly have a namespace conflict, you can also reference {% gridtest.func.func_name %} and it will work to reference the function here.

gridtest.func.tmp_dir(requested_tmpdir=None, prefix='', create=True)[source]

get a temporary directory for an operation. Default creates it.

Arguments:
  • prefix (str) : prefix the filename with this string.

  • requested_tmpdir (str) : an optional requested temporary directory

  • create (bool) : create the temporary directory

gridtest.func.tmp_path(requested_tmpdir=None, prefix='', create=False, ext='')[source]

get a temporary file with an optional prefix. By default will be created in /tmp, and the file is closed (and just a name returned).

Arguments:
  • requested_tmpdir (str) : an optional requested temporary directory

  • prefix (str) : prefix the filename with this string.

  • create (bool) : create the file (empty) defaults to False

  • ext (str) : the extension to use, should include .

gridtest.utils module

Copyright (C) 2020 Vanessa Sochat.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

gridtest.utils.read_file(filename, readlines=True)[source]

write_file will open a file, “filename” and write content and properly close the file.

Arguments:
  • filename (str) : the filename to read

  • readlines (bool) : read lines of the file (vs all raw)

gridtest.utils.read_json(input_file)[source]

Read json from an input file.

gridtest.utils.read_yaml(filename)[source]

read a yaml file, only including sections between dashes

Arguments:
  • filename (str) : the filename to read

gridtest.utils.recursive_find(base, pattern='*.py')[source]

recursive find will yield python files in all directory levels below a base path.

Arguments:
  • base (str) : the base directory to search

  • pattern: a pattern to match, defaults to *.py

gridtest.utils.save_pickle(json_obj, filename)[source]

Save a pickle to file

gridtest.utils.write_json(json_obj, filename, pretty=True)[source]

write_json will write a json object to file, pretty printed

Arguents:
  • json_obj (dict) : the dict to print to json

  • filename (str) : the output file to write to

gridtest.utils.write_yaml(yaml_dict, filename)[source]

write a dictionary to yaml file

Arguments:
  • yaml_dict (dict) : the dict to print to yaml

  • filename (str) : the output file to write to

  • pretty_print (bool): if True, will use nicer formatting

gridtest.version module

Copyright (C) 2020 Vanessa Sochat.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Module contents

Copyright (C) 2020 Vanessa Sochat.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.