smarr / ReBench

Execute and document benchmarks reproducibly.
MIT License
85 stars 24 forks source link

rebench crashes if git isn't installed #243

Closed vext01 closed 4 months ago

vext01 commented 4 months ago

Hi Stefan! Long time no see.

I'm trying out rebench for the first time and I think I've found some bugs. I'll file them, but if it's user error then I apologise in advance :)

I've noticed that if you run rebench on a system without git installed (I was using a very minimal docker container for a CI system), then you get an error like:

+ /home/ci/.local/bin/rebench --no-denoise -c rebench.conf -q
Traceback (most recent call last):
  File "/home/ci/.local/bin/rebench", line 8, in <module>
    sys.exit(main_func())
             ^^^^^^^^^^^
  File "/home/ci/.local/pipx/venvs/rebench/lib/python3.11/site-packages/rebench/rebench.py", line 313, in main_func
    return 0 if rebench.run() else -1
                ^^^^^^^^^^^^^
  File "/home/ci/.local/pipx/venvs/rebench/lib/python3.11/site-packages/rebench/rebench.py", line 251, in run
    self._config = Configurator(config, data_store, self.ui, args,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ci/.local/pipx/venvs/rebench/lib/python3.11/site-packages/rebench/configurator.py", line 226, in __init__
    self._experiments = self._compile_experiments(experiments)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ci/.local/pipx/venvs/rebench/lib/python3.11/site-packages/rebench/configurator.py", line 336, in _compile_experiments
    results[exp_name] = self._compile_experiment(exp_name, experiments[exp_name])
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ci/.local/pipx/venvs/rebench/lib/python3.11/site-packages/rebench/configurator.py", line 347, in _compile_experiment
    return Experiment.compile(exp_name, experiment, self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ci/.local/pipx/venvs/rebench/lib/python3.11/site-packages/rebench/model/experiment.py", line 51, in compile
    return Experiment(name, description or desc, action, env, data_file, reporting,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ci/.local/pipx/venvs/rebench/lib/python3.11/site-packages/rebench/model/experiment.py", line 66, in __init__
    self._persistence = self._data_store.get(data_file, configurator, action)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ci/.local/pipx/venvs/rebench/lib/python3.11/site-packages/rebench/persistence.py", line 54, in get
    source = determine_source_details(configurator)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ci/.local/pipx/venvs/rebench/lib/python3.11/site-packages/rebench/environment.py", line 57, in determine_source_details
    is_git_repo = _exec(git_cmd + ['rev-parse']) is not None
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ci/.local/pipx/venvs/rebench/lib/python3.11/site-packages/rebench/environment.py", line 22, in _exec
    out = subprocess.check_output(cmd, stderr=dev_null_f)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1901, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'git'

I'm not sure if git is a hard dependency of rebench, but it might be an idea to print a better error message like "git is required" instead of a stack trace.

Cheers

smarr commented 4 months ago

Hi @vext01 :)

Hm, yeah, I guess that's expected to break. But only in the sense that this isn't something I have tested for.

Should be an easy fix...

smarr commented 4 months ago

Could you give https://github.com/smarr/ReBench/pull/245 a go? I should probably see whether I can run tests in an empty docker container, too. Though, if you happen to have a corresponding Dockerfile, that's probably a better start than me trying to do it from scratch.

Thanks!

vext01 commented 4 months ago

Sorry for the delay. Took me a while to figure out how to install a branch using pipx!

You've made it so git is a not a dependency at all, right?

Using this Dockerfile (without git installed) and this build script I'm able to run rebench just fine!

CI output here if you are curious.

Thanks

smarr commented 4 months ago

You've made it so git is a not a dependency at all, right?

Well, technically, no. Technically, I thought I had tried that already in the past here: https://github.com/smarr/ReBench/blob/a158176c9e6ffab7c363b36aaed9d34b63f557a6/rebench/environment.py#L39 But practically, there seem to be different failure modes. I guess, I could just try to catch everything... but being not sure what else might be missed, I'd rather not catch too much.

Using this Dockerfile (without git installed) and this build script I'm able to run rebench just fine!

Thanks. It would probably be sensible to add something like this to the CI, but not today. Let's go with the quick fix in #245 for now, and then reconsider if something else crops up.

Thanks!

smarr commented 4 months ago

Closing with #245 being merged. Thanks!