pybamm-team/pybamm-cookie

Issues when trying the template

Closed this issue ยท 11 comments

I tried copying the template using copier (in WSL, Python 3.11) and I have spotted the following issues:

  • User name needs to be passed between quotation marks, but this is not specified. Probably we could keep things as they are an pass the quotation marks ourselves when calling the git config user.name command.
  • When calling nox (either generated-project-tests or dev) I get the following error:
nox > Running session dev
nox > Creating virtual environment (virtualenv) using python3.11 in .nox/dev
nox > python -m pip install virtualenv
nox > virtualenv /home/brosaplanella/LTES/encapsulated_LTES/venv
nox > /home/brosaplanella/LTES/encapsulated_LTES/venv/bin/python -m pip install -e '.[dev]'
nox > Warning: /home/brosaplanella/LTES/encapsulated_LTES/venv/bin/python is not installed into the virtualenv, it is located at /home/brosaplanella/LTES/encapsulated_LTES/venv/bin/python. This might cause issues! Pass external=True into run() to silence this message.
Obtaining file:///home/brosaplanella/LTES/encapsulated_LTES
ERROR: Exception:
Traceback (most recent call last):
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/cli/base_command.py", line 179, in exc_logging_wrapper
    status = run_func(*args)
             ^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/cli/req_command.py", line 67, in wrapper
    return func(self, options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/commands/install.py", line 377, in run
    requirement_set = resolver.resolve(
                      ^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 76, in resolve
    collected = self.factory.collect_root_requirements(root_reqs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 538, in collect_root_requirements
    reqs = list(
           ^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 494, in _make_requirements_from_install_req
    cand = self._make_base_candidate_from_link(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 210, in _make_base_candidate_from_link
    self._editable_candidate_cache[link] = EditableCandidate(
                                           ^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 328, in __init__
    super().__init__(
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 158, in __init__
    self.dist = self._prepare()
                ^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 235, in _prepare
    dist = self._prepare_distribution()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 338, in _prepare_distribution
    return self._factory.preparer.prepare_editable_requirement(self._ireq)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/operations/prepare.py", line 698, in prepare_editable_requirement
    dist = _get_prepared_distribution(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/operations/prepare.py", line 72, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/distributions/sdist.py", line 39, in prepare_distribution_metadata
    self.req.load_pyproject_toml()
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/req/req_install.py", line 511, in load_pyproject_toml
    pyproject_toml_data = load_pyproject_toml(
                          ^^^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_internal/pyproject.py", line 64, in load_pyproject_toml
    pp_toml = tomli.loads(f.read())
              ^^^^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_vendor/tomli/_parser.py", line 102, in loads
    pos = key_value_rule(src, pos, out, header, parse_float)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_vendor/tomli/_parser.py", line 326, in key_value_rule
    pos, key, value = parse_key_value_pair(src, pos, parse_float)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_vendor/tomli/_parser.py", line 369, in parse_key_value_pair
    pos, value = parse_value(src, pos, parse_float)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_vendor/tomli/_parser.py", line 616, in parse_value
    return parse_array(src, pos, parse_float)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_vendor/tomli/_parser.py", line 420, in parse_array
    pos, val = parse_value(src, pos, parse_float)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_vendor/tomli/_parser.py", line 620, in parse_value
    return parse_inline_table(src, pos, parse_float)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brosaplanella/LTES/encapsulated_LTES/venv/lib/python3.11/site-packages/pip/_vendor/tomli/_parser.py", line 461, in parse_inline_table
    raise suffixed_err(src, pos, "Unclosed inline table")
pip._vendor.tomli.TOMLDecodeError: Unclosed inline table (at line 10, column 14)
  • The issue above was caused because in the pyproject.toml we already include quotation marks, so adding them again as I suggested earlier ended up with double quotation marks which upsetted nox. I removed them manually and now it works, so it seems both issues are related.
  • The README does not mention that the user needs to manually create and push to the Github repo. Pretty obvious, but given that we ask people the name of the repo when generating the project it is a bit misleading.

Might add more issues later if I find more (edit, previous issue went away when upgrading nox, we should require most recent version or later in the docs).

At least for validating the nox version, setting nox.needs_version = <required nox version here> in noxfile.py will emit a friendly error message if the version doesn't comply with the requirement.

Maybe we could add the supported versions of the dependencies in pyproject.toml as these kinds of errors would be caught beforehand in the CI, especially with the build-backend as well. As for the GitHub thing, maybe we could also configure the upstream URL with git? That would then just take one git push command to push it to the Github repo given they already have a github repo created, or we might as well just mention them in the docs on how to set it up.

BTW, @FW-Coding tried the template and did not encounter the name issue. Could it be that it was because his full name is two words while mine is three words, and that caused the code to crash?

I tried to reproduce this error on my local machine and it does give me an error when I use your full name, it seems the problem was with the copier subtask, more precisely a bug. I fixed it now by wrapping the {{full_name}} in quotations in the _tasks key. I will quickly make a PR now, thank you for the report Ferran!

I am putting these issues faced by @brosaplanella at mmsg-warwick/electrode-coating/pull/4 here to keep track of them and resolve them.

  • Install setuptools in the docs session, without it fails.
  • Create _static directory to prevent warning
  • Add refs.bib
  • Add some entries to conf.py
  • Perform doctests inside the generated projects

#39

I think these documentation issues arise because we are not performing any doctests for the generated projects. Should add that as well in the above list.

@brosaplanella do we close this issue or we keep this as a tracker for future bugs?

If all the issues here are addressed I would close it and we can report new bugs as separate issues.

If all the issues here are addressed I would close it and we can report new bugs as separate issues.

Now that we have completely removed the git config procedures from the template I guess this issue is irrelevant, other than that the problems of doctests inside the generated project were resolved 3 weeks ago so I think we should be good to close this issue.

  • The README does not mention that the user needs to manually create and push to the Github repo. Pretty obvious, but given that we ask people the name of the repo when generating the project it is a bit misleading.

Do we mention this in README? maybe just add a link to the documentation on how to push a local repo to GitHub?

Yes, sounds good.