@@ -447,6 +447,58 @@ def convert_path(cls, v: Any) -> Path | None:
447447 return None
448448 return Path (v ) if not isinstance (v , Path ) else v
449449
450+ def resolve_store_name (self , store : str | None = None , * , use_filepath_default : bool = False ) -> str :
451+ """
452+ Name the configured store that a store reference resolves to.
453+
454+ An empty or missing name means the default store: ``stores.default``,
455+ or ``stores.filepath_default`` for filepath references. Codecs record
456+ the resolved name in their metadata, so a stored object stays tied to
457+ the store it was written to even if the default is later re-pointed.
458+
459+ Parameters
460+ ----------
461+ store : str, optional
462+ Store name as declared. ``""`` (the bare ``@`` form) and None both
463+ mean the default store.
464+ use_filepath_default : bool, optional
465+ If True, resolve the default to stores.filepath_default instead of
466+ stores.default. Default: False.
467+
468+ Returns
469+ -------
470+ str
471+ Name of a key in ``stores``.
472+
473+ Raises
474+ ------
475+ DataJointError
476+ If the default store is needed but not configured.
477+ """
478+ if store :
479+ return store
480+ # An empty name is the bare ``@`` form (``<npy@>``, ``<object@>``, ...),
481+ # which the declaration keeps as "" so the codec can tell "store
482+ # requested" from "no store"; it means the default store.
483+ if use_filepath_default :
484+ # Filepath references use separate default (not part of OAS)
485+ if "filepath_default" not in self .stores :
486+ raise DataJointError (
487+ "stores.filepath_default is not configured. "
488+ "Set stores.filepath_default or specify store explicitly with <filepath@store>"
489+ )
490+ store = self .stores ["filepath_default" ]
491+ else :
492+ # Integrated storage (hash, schema) uses stores.default
493+ if "default" not in self .stores :
494+ raise DataJointError ("stores.default is not configured" )
495+ store = self .stores ["default" ]
496+
497+ if not isinstance (store , str ):
498+ default_key = "filepath_default" if use_filepath_default else "default"
499+ raise DataJointError (f"stores.{ default_key } must be a string" )
500+ return store
501+
450502 def get_store_spec (self , store : str | None = None , * , use_filepath_default : bool = False ) -> dict [str , Any ]:
451503 """
452504 Get configuration for a storage store.
@@ -470,25 +522,7 @@ def get_store_spec(self, store: str | None = None, *, use_filepath_default: bool
470522 DataJointError
471523 If store is not configured or has invalid config.
472524 """
473- # Handle default store
474- if store is None :
475- if use_filepath_default :
476- # Filepath references use separate default (not part of OAS)
477- if "filepath_default" not in self .stores :
478- raise DataJointError (
479- "stores.filepath_default is not configured. "
480- "Set stores.filepath_default or specify store explicitly with <filepath@store>"
481- )
482- store = self .stores ["filepath_default" ]
483- else :
484- # Integrated storage (hash, schema) uses stores.default
485- if "default" not in self .stores :
486- raise DataJointError ("stores.default is not configured" )
487- store = self .stores ["default" ]
488-
489- if not isinstance (store , str ):
490- default_key = "filepath_default" if use_filepath_default else "default"
491- raise DataJointError (f"stores.{ default_key } must be a string" )
525+ store = self .resolve_store_name (store , use_filepath_default = use_filepath_default )
492526
493527 # Check store exists
494528 if store not in self .stores :
0 commit comments