tree Reference

Tree

class tree.tree.Tree(*args, **kwargs)[source]

Bases: object

Initialize the sdss tree object

This class provides Python programmatic access to the SDSS tree envionment structure

Parameters:
  • key (str|list) – A section or list of sections of the tree to add into the local environment
  • uproot_with (str) – A new TREE_DIR path used to override an existing TREE_DIR environment variable
  • config (str) – Name of manual config file to load. Default is sdsswork.
  • update (bool) – If True, overwrites existing tree environment variables in your local environment. Default is False.
  • exclude (list) – A list of environment variables to exclude from forced updates
Variables:
  • treedir (str) – The directory of the tree
  • environ (dict) – The fully loaded SDSS config file held internally
add_limbs(key=None)[source]

Add a new section from the tree into the existing os environment

Parameters:key (str) – The section name to grab from the environment
add_paths_to_os(key=None, update=None)[source]

Add the paths in tree environ into the os environ

This code goes through the tree environ and checks for existence in the os environ, then adds them

Parameters:
  • key (str) – The section name to check against / add
  • update (bool) – If True, overwrites existing tree environment variables in your local environment. Default is False.
branch_out(limb=None)[source]

Set the individual section branches

This adds the various sections of the config file into the tree environment for access later. Optically can specify a specific branch. This does not yet load them into the os environment.

Parameters:limb (str/list) – The name of the section of the config to add into the environ or a list of strings
check_paths(paths, update=None)[source]

Check if the path is in the os environ, and if not add it

Paramters:
paths (OrderedDict):
An ordered dict containing all of the paths from the a given section, as key:val = name:path
update (bool):
If True, overwrites existing tree environment variables in your local environment. Default is False.
get_available_releases(public=None)[source]

Get the available releases

Parameters:public (bool) – If True, only return public data releases
get_paths(key)[source]

Retrieve a set of environment paths from the config

Parameters:key (str) – The section name to grab from the environment
Returns:self.environ[newkey] (OrderedDict) – An ordered dict containing all of the paths from the specified section, as key:val = name:path
list_available_configs()[source]

List the available config files able to be loaded

list_keys()[source]

List the available keys you can load

load_config(config=None)[source]

loads a config file

Parameters:config (str) – Optional name of manual config file to load
replant_tree(config=None, exclude=None)[source]

Replant the tree with a different config setup

Parameters:
  • config (str) – The config name to reload
  • exclude (list) – A list of environment variables to exclude from forced updates
set_roots(uproot_with=None)[source]

Set the roots of the tree in the os environment

Parameters:uproot_with (str) – A new TREE_DIR path used to override an existing TREE_DIR environment variable

Utilities

tree.utils.compute_changelog(new, old, pprint=None, remove_sas=True)[source]

Compute the difference between two Tree environments

Finds and prints the difference between two tree environment configurations. Accepts either string names of config files, e.g. “dr16” and “dr15”, or the preloaded Tree configs, e.g. Tree(config='dr16').

Parameters:
  • new (str|Tree) – The new tree enviroment to compare
  • old (str|Tree) – The old tree environment to compare
  • pprint (bool) – If True, returns a single joined string for printing
  • remove_sas (bool) – If True, removes the SAS_BASE_DIR from environment values. Default is True.
Returns:

A list of strings with printed changes

Example

>>> # print the differences DR16 and DR15
>>> diffs = compute_changelog('dr16', 'dr15', pprint=True)
>>> print(diffs)