From 67d63b14f25aebc3681f574daee9bdf5a2a53b48 Mon Sep 17 00:00:00 2001 From: Joanne Bogart Date: Fri, 10 May 2024 22:25:14 -0700 Subject: [PATCH] allow gaia data_dir to be absolute path --- skycatalogs/objects/gaia_object.py | 7 +++++-- skycatalogs/utils/config_utils.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/skycatalogs/objects/gaia_object.py b/skycatalogs/objects/gaia_object.py index 989e31cb..204ab783 100644 --- a/skycatalogs/objects/gaia_object.py +++ b/skycatalogs/objects/gaia_object.py @@ -1,7 +1,6 @@ import os import warnings from functools import wraps -import itertools from collections.abc import Iterable from pathlib import PurePath import numpy as np @@ -157,7 +156,10 @@ def _read_fits(htm_id, gaia_config, sky_root, out_dict, logger, region=None): f_dir = gaia_config['data_dir'] f_name = gaia_config['basename_template'].replace('(?P\\d+)', f'{htm_id}') - f_path = os.path.join(sky_root, f_dir, f_name) + if os.path.isabs(f_dir): + f_path = os.path.join(f_dir, f_name) + else: + f_path = os.path.join(sky_root, f_dir, f_name) if not os.path.isfile(f_path): logger.info(f'No file for requested htm id {htm_id}') return @@ -236,6 +238,7 @@ class GaiaCollection(ObjectCollection): def set_config(cls, config): GaiaCollection._gaia_config = config GaiaCollection._id_prefix = config['id_prefix'] + @classmethod def get_config(cls): return GaiaCollection._gaia_config diff --git a/skycatalogs/utils/config_utils.py b/skycatalogs/utils/config_utils.py index 4daebd1a..a1a2d679 100644 --- a/skycatalogs/utils/config_utils.py +++ b/skycatalogs/utils/config_utils.py @@ -71,7 +71,7 @@ def include(self, node: yaml.Node) -> list[Any] | dict[str, Any]: raise yaml.constructor.ConstructorError def extractFile(self, filepath: str) -> Any: - if filepath.startswith('/'): + if os.path.isabs(filepath): actual_path = filepath else: actual_path = os.path.join(self._current_dir, filepath)