CWorthy-ocean / C-Star

C-Star is a python package for setting up and running ocean model simulations, with a particular focus on marine carbon dioxide removal (mCDR) applications.
https://c-star.readthedocs.io
8 stars 3 forks source link

ValueError: supplied checkout_target does not appear to be a valid reference for this repository #12

Open TomNicholas opened 1 month ago

TomNicholas commented 1 month ago

Running the first two cells of the example notebook gives

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[2], line 3
      1 #BaseModel object, ROMS:
----> 3 roms_base_model=cstar.ROMSBaseModel(
      4                            source_repo='https://github.com/dafyddstephenson/ucla-roms.git',
      5                            checkout_target='marbl_improvements_20240611')
      7 marbl_base_model=cstar.MARBLBaseModel(
      8                             source_repo='https://github.com/marbl-ecosys/MARBL.git',
      9                             checkout_target='marbl0.45.0')

File [~/Documents/Work/Code/C-Star/cstar_ocean/base_model.py:89](http://localhost:8888/lab/tree/~/Documents/Work/Code/C-Star/cstar_ocean/base_model.py#line=88), in BaseModel.__init__(self, source_repo, checkout_target)
     81 self.source_repo = (
     82     source_repo if source_repo is not None else self.default_source_repo
     83 )
     84 self.checkout_target = (
     85     checkout_target
     86     if checkout_target is not None
     87     else self.default_checkout_target
     88 )
---> 89 self.checkout_hash = _get_hash_from_checkout_target(
     90     self.source_repo, self.checkout_target
     91 )
     92 self.repo_basename = os.path.basename(self.source_repo).replace(".git", "")
     94 self.local_config_status = self.get_local_config_status()

File [~/Documents/Work/Code/C-Star/cstar_ocean/utils.py:119](http://localhost:8888/lab/tree/~/Documents/Work/Code/C-Star/cstar_ocean/utils.py#line=118), in _get_hash_from_checkout_target(repo_url, checkout_target)
    117         return checkout_target
    118     else:
--> 119         raise ValueError(
    120             "supplied checkout_target does not appear "
    121             + "to be a valid reference for this repository"
    122         )
    123 else:
    124     return ls_remote.split()[0]

ValueError: supplied checkout_target does not appear to be a valid reference for this repository
TomNicholas commented 1 month ago

Is there supposed to be a branch called marbl_improvements_20240611? I don't see it here: https://github.com/dafyddstephenson/ucla-roms/branches

TomNicholas commented 1 month ago

Changing checkout_target to main does work.

We might consider improving this error message to list valid options (e.g. existing branches on that repo).

dafyddstephenson commented 1 month ago

Good catch, addressed in PR #16 . Agree an improved error message would be nice. Can you open a separate issue or re-format this one?