def create_releases(name): """ extract an entry from the objects.yaml and reorganize by release """ data = get_object(name) if not data: return None data = copy.deepcopy(data) # pop out the works works = data.pop('work_version', None) # create a dictionary of the object parameters with release as the key dd = {} dd[data.get('release', 'DR15')] = data if works: # add any other work objects found for work in works: work_object = create_work_version(work, data) dd[f"WORK-{work_object['version_info']['number']}"] = work_object # expand the path envvars for k, v in dd.items(): release = 'WORK' if 'WORK' in k else k tree.replant_tree(release.lower()) dd[k]['path'] = os.path.expandvars(v.get('path', '')) return dd
def mocksess_sas(tmp_path_factory): ''' session fixture to change the SAS_BASE_DIR to a temp directory ''' path = str(tmp_path_factory.mktemp('sas')) orig_env = os.environ.copy() os.environ['SAS_BASE_DIR'] = path tree.replant_tree(config.release) yield None os.environ = orig_env
def get_path(name, work=None): ''' Function to return a path name ''' path = None data = get_object(name) if data: release = 'WORK' if work else data.get('release', 'DR15') tree.replant_tree(release.lower()) path = os.path.expandvars(data.get('path', '')) return path
def mock_sas(tmp_path, monkeypatch): ''' function fixture to change the SAS_BASE_DIR to a temp directory if used, this fixture must come first in test invocation also manually monkeypatches os.environ so we can replant the tree environ. ''' orig_env = os.environ.copy() path = str(tmp_path / 'sas') monkeypatch.setenv('SAS_BASE_DIR', path) tree.replant_tree(config.release) yield None os.environ = orig_env
def release(self, value: str) -> None: value = value.upper() if value not in self._allowed_releases: raise BrainError( f'trying to set an invalid release version {value}. ' f'Valid releases are: {", ".join(self._allowed_releases)}') # if work release or IPL, check for a validated user if 'dr' not in value.lower() and not self.user.validated: raise BrainError( f'User {self.user} is not validated. Can only access public data. ' 'Cannot access "work" data or internal SDSS releases. Consider ' 'validating the user, or check your SDSS netrc credentials.') # replant the tree if value.lower() == 'work': tree.replant_tree('sdsswork') else: tree.replant_tree(value.lower()) self._release = value
def reset_tree(): ''' resets the tree to the overall config for each module ''' tree.replant_tree(config.release.lower())