Closed ccarouge closed 6 months ago
@SeanBryan51 any views on this? I found it using the branch for #234 but it is possible it is also occurring with the main branch (not tested). So we need to add a case to our integration test...
If I give a name to a realisation (eg. toto) checking out the main branch of the CABLE repository, the path for the repo should be src/toto instead it is set to src/toto/main.
That is strange, is the toto
directory is being created before the git clone? That would cause it to clone it in the subdirectory src/toto/main
. See here:
https://github.com/CABLE-LSM/benchcab/blob/af43dad820811bc0b5e56161957ca374aeeb704e/benchcab/utils/repo.py#L74-L77
I've tested your integration test case for the main branch and it seems to be working as expected:
$ ls $SCRATCH/benchcab/integration/src/toto
documentation License.md README.md requirements.txt src src_pop
@SeanBryan51 The checkout and compilation work absolutely fine and are using src/toto
, but that's because src/toto
directory doesn't exist yet.
The only problem I had was in the PBS log file, when it is trying to get the revision/version "number" to write in the netcdf files. It's when calling add_provenance_info
from fluxsite.py and get_revision
from repo.py. That's the only place where I see a failure. It's because at this point we call _get_models
again and the GitRepo() gets recreated. But now, the src/toto
directory exists, so it adds the branch name to it when defining path
.
Yep, I've reproduced the error in the PBS logs. The logic in the constructor is definitely broken for the case you described. I guess one way we could solve this is to check if the path points to an existing git repository, and set the path correctly in that case?
So if path is git repo -> path = path, else path = path / branch ?
How do you propose to check if it's a git repo? Is there anything in gitpython? Or just checking for a .git/ subfolder?
This does also bring up an issue I have with the design of the Repo
object which is that the state of the object does not necessarily reflect the state of the cloned repository on the file system (this issue is an example of this). Perhaps a better approach is to do what gitpython
does in the sense that a git.Repo
object can only be instantiated if you give it a path to an existing git repository on the file system, or you create one via git.Repo.clone_from()
which clones the repository, that way the state of the object always reflects the state of the git repository on the file system.
So if path is git repo -> path = path, else path = path / branch ?
Something like that yep.
Maybe relevant: https://github.com/gitpython-developers/GitPython/issues/715
Description
If I give a name to a realisation (eg.
toto
) checking out themain
branch of the CABLE repository, thepath
for the repo should besrc/toto
instead it is set tosrc/toto/main
. That is using branch234-clean-parsing-optional
.Then this crashes in
add_revision
which is about the only place that is using therepo.path
variable.Solution
If we don't want to change too many things, the simpler is in
GitRepo.__init__()
andSVNRepo.__init()
, replace:with
But considering
create_repo
is called with:this seems heavy...
Should we instead pass
name
to repo._init__() and then have:How to reproduce
In
integration.sh
use:Output
In the PBS log file: