LSSTDESC / gcr-catalogs

A Python module that provides a unified interface to access mock galaxy catalogs and more for the LSST DESC
https://github.com/LSSTDESC/gcr-catalogs
BSD 3-Clause "New" or "Revised" License
26 stars 20 forks source link

Incorrect `root_dir` #624

Closed AlexGKim closed 1 year ago

AlexGKim commented 1 year ago

The default path for root_dir causes an error

With the default

GCRCatalogs.get_root_dir()
'/global/cfs/cdirs/lsst/shared/xgal/skysim/'

I get the error

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[2], line 1
----> 1 catalog = GCRCatalogs.load_catalog('skysim_v3.1.0')

File /global/cfs/projectdirs/desi/users/akim/gcr-catalogs/GCRCatalogs/register.py:797, in load_catalog(catalog_name, config_overwrite)
    781 def load_catalog(catalog_name, config_overwrite=None):
    782     """
    783     Load a catalog as specified in the yaml file named *catalog_name*,
    784     with any *config_overwrite* options overwrite the default.
   (...)
    795     catalog : instance of a subclass of BaseGalaxyCatalog
    796     """
--> 797     return _config_register[catalog_name].load_catalog(config_overwrite)

File /global/cfs/projectdirs/desi/users/akim/gcr-catalogs/GCRCatalogs/register.py:400, in Config.load_catalog(self, config_overwrite)
    398 else:
    399     config_dict = self._resolved_content
--> 400 return load_catalog_from_config_dict(config_dict)

File /global/cfs/projectdirs/desi/users/akim/gcr-catalogs/GCRCatalogs/register.py:75, in load_catalog_from_config_dict(catalog_config)
     71 def load_catalog_from_config_dict(catalog_config):
     72     """
     73     Loads and returns the catalog specified in *catalog_config*.
     74     """
---> 75     return import_subclass(
     76         catalog_config[Config.READER_KEY], __package__, BaseGenericCatalog
     77     )(**catalog_config)

File /global/common/software/lsst/gitlab/desc-python-prod/84904/py/lib/python3.10/site-packages/GCR/base.py:28, in BaseGenericCatalog.__init__(self, **kwargs)
     26 def __init__(self, **kwargs):
     27     self._init_kwargs = kwargs.copy()
---> 28     self._subclass_init(**kwargs)
     29     self._native_quantities = set(self._generate_native_quantity_list())
     31     # enforce the existence of required attributes

File /global/cfs/projectdirs/desi/users/akim/gcr-catalogs/GCRCatalogs/cosmodc2.py:128, in CosmoDC2ParentClass._subclass_init(self, catalog_root_dir, catalog_filename_template, **kwargs)
    125 def _subclass_init(self, catalog_root_dir, catalog_filename_template, **kwargs):
    126     # pylint: disable=W0221
    127     if not os.path.isdir(catalog_root_dir):
--> 128         raise ValueError('Catalog directory {} does not exist'.format(catalog_root_dir))
    130     self.lightcone = kwargs.get('lightcone', True)
    132     get_file_list = self._get_healpix_file_list if self.lightcone else self._get_snapshot_file_list

ValueError: Catalog directory /global/cfs/cdirs/lsst/shared/xgal/skysim/xgal/skysim/skysim_v3.1.0 does not exist

Whereas to make things work I had to set the path to

GCRCatalogs.set_root_dir('/global/cfs/cdirs/lsst/shared/')

yymao commented 1 year ago

@AlexGKim Thanks. But I wasn't able to reproduce the error. I got the correct root_dir path when importing GCRCatalogs v1.6.0. Did you run anything else before calling GCRCatalogs?

In [4]: import GCRCatalogs

In [5]: GCRCatalogs.get_root_dir()
Out[5]: '/global/cfs/cdirs/lsst/shared'

In [6]: GCRCatalogs.__version__
Out[6]: '1.6.0'
AlexGKim commented 1 year ago

The problem is that I ran the command

python -m GCRCatalogs.user_config set root_dir /path/to/the/download/directory

Do you know how I can undo this without rerunning the above command, which I can't run again due to silly reasons?

yymao commented 1 year ago

Can you run

python -m GCRCatalogs.user_config del root_dir

?

If not, can you go to ~/.config/lsstdesc/ and remove the user config file directly?

AlexGKim commented 1 year ago

Success! I fixed the config file.