Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting mepo clone in non-git fixtures? #311

Open
mathomp4 opened this issue Aug 13, 2024 · 2 comments
Open

Supporting mepo clone in non-git fixtures? #311

mathomp4 opened this issue Aug 13, 2024 · 2 comments
Assignees

Comments

@mathomp4
Copy link
Member

In trying test builds of GEOSgcm with spack, I tried the:

version("11.6.1", sha256="f77a6e292726322b8726d13d7eb67282caaf01f3fe30cba744da6010d6554fef", preferred=True)

which in the end downloads the tar.gz asset:

https://github.com/GEOS-ESM/GEOSgcm/archive/refs/tags/v11.6.1.tar.gz

So spack is trying to do:

wget https://github.com/GEOS-ESM/GEOSgcm/archive/refs/tags/v11.6.1.tar.gz
tar -xf v11.6.1.tar.gz
cd GEOSgcm-v11.6.1
mepo clone

and that last step fails:

❯ mepo clone                                                                                                                                                                                                         at 14:47:04
Found partial clone type [blobless] in .mepoconfig
fatal: not a git repository (or any of the parent directories): .git

Traceback (most recent call last):
  File "/Users/mathomp4/.homebrew/brew/Cellar/mepo/2.0.0/libexec/lib/python3.12/site-packages/mepo/command/clone.py", line 81, in run
    allcomps = MepoState.read_state()
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mathomp4/.homebrew/brew/Cellar/mepo/2.0.0/libexec/lib/python3.12/site-packages/mepo/state.py", line 127, in read_state
    raise StateDoesNotExistError("Error! mepo state does not exist")
mepo.utilities.exceptions.StateDoesNotExistError: Error! mepo state does not exist

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/mathomp4/.homebrew/brew/bin/mepo", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/mathomp4/.homebrew/brew/Cellar/mepo/2.0.0/libexec/lib/python3.12/site-packages/mepo/__main__.py", line 15, in main
    cmd_module.run(args)
  File "/Users/mathomp4/.homebrew/brew/Cellar/mepo/2.0.0/libexec/lib/python3.12/site-packages/mepo/command/clone.py", line 83, in run
    mepo_init_run(args)
  File "/Users/mathomp4/.homebrew/brew/Cellar/mepo/2.0.0/libexec/lib/python3.12/site-packages/mepo/command/init.py", line 20, in run
    _ = MepoState.initialize(args.registry, style)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mathomp4/.homebrew/brew/Cellar/mepo/2.0.0/libexec/lib/python3.12/site-packages/mepo/state.py", line 74, in initialize
    MepoComponent().registry_to_component(name, comp, directory_style)
  File "/Users/mathomp4/.homebrew/brew/Cellar/mepo/2.0.0/libexec/lib/python3.12/site-packages/mepo/component.py", line 109, in registry_to_component
    repo_url = get_current_remote_url()
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mathomp4/.homebrew/brew/Cellar/mepo/2.0.0/libexec/lib/python3.12/site-packages/mepo/component.py", line 209, in get_current_remote_url
    output = shellcmd.run(shlex.split(cmd), output=True).strip()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mathomp4/.homebrew/brew/Cellar/mepo/2.0.0/libexec/lib/python3.12/site-packages/mepo/utilities/shellcmd.py", line 16, in run
    result.check_returncode()
  File "/Users/mathomp4/.homebrew/brew/Cellar/[email protected]/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 502, in check_returncode
    raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '['git', 'remote', 'get-url', 'origin']' returned non-zero exit status 128.

The reason it fails is because of the components.yaml:

GEOSgcm:
  fixture: true
  develop: main

env:
  local: ./@env
  remote: ../ESMA_env.git
  tag: v4.29.0
  develop: main
...

We use relative URLs in the subrepos, so to figure out what that URL is relative to it runs:

git remote get-url origin

in the fixture. But the tarfile Github assets ARE NOT GIT REPOS:

❯ git remote get-url origin
fatal: not a git repository (or any of the parent directories): .git

GitHub strips out the .git/ directory.

So the question is: should we support this? I think it would be "simple" to add an option a la:

mepo clone --remote https://github.com/GEOS-ESM/GEOSgcm.git

(and something similar to mepo init) where if --remote is passed in, we override the get-url call and just says "This is our fixture URL"

@pchakraborty
Copy link
Collaborator

pchakraborty commented Aug 14, 2024

So, we need three versions of mepo clone

  1. mepo clone -b <version> <url> [<directory>]
  2. mepo clone
  3. mepo clone --remote <remote-name>

I'm going to leave mepo init be for the time being, and look at #282 later.

@pchakraborty
Copy link
Collaborator

@mathomp4 I took a stab at this: see feature/pchakrab/#311-non-git-fixture

This is a very hacky solution that gets the clone working, but there are obvious issues - many commands, including mepo status will fail. I'm not sure if we should support this - let's discuss that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants