Skip to content

Implement CVS fetcher#23212

Merged
scheibelp merged 57 commits intospack:developfrom
eschnett:eschnett/cvs
Jun 22, 2021
Merged

Implement CVS fetcher#23212
scheibelp merged 57 commits intospack:developfrom
eschnett:eschnett/cvs

Conversation

@eschnett
Copy link
Copy Markdown
Contributor

No description provided.

@eschnett
Copy link
Copy Markdown
Contributor Author

The CVS fetcher isn't covered by self-tests. Where/how should I add them? Should I?

@adamjstewart
Copy link
Copy Markdown
Member

I think tests would be good, see lib/spack/spack/test/(git|hg|svn)_fetch.py for examples. Note that these tests are skipped if the dependencies aren't installed, so you'll need to install cvs in .github/workflows/unit_tests.yaml to actually get coverage.

Docs would also be good. They can be added here: https://spack.readthedocs.io/en/latest/packaging_guide.html#fetching-from-code-repositories

@eschnett
Copy link
Copy Markdown
Contributor Author

eschnett commented Apr 23, 2021

The error is:

2021-04-23T20:57:43.3020151Z   >> 1226    Bus error (core dumped)
2021-04-23T20:57:43.3020728Z      1227    make: *** [Makefile:604: sharedmods] Error 135
2021-04-23T20:57:43.3021347Z      1228    make: *** Waiting for unfinished jobs....

while installing Python. That's unrelated to my pull request.

@eschnett
Copy link
Copy Markdown
Contributor Author

The last remaining error is from codecov, complaining that part of the code is not covered by tests. That's not true – these lines are definitively executed when running the unit tests. (I recall having to correct errors in some of these lines.)

@eschnett
Copy link
Copy Markdown
Contributor Author

This is ready to be reviewed, btw. Docs and tests are there as well.

@eschnett
Copy link
Copy Markdown
Contributor Author

Ping?

@adamjstewart adamjstewart requested a review from becker33 April 30, 2021 13:56
@eschnett
Copy link
Copy Markdown
Contributor Author

eschnett commented May 7, 2021

Ping?

Copy link
Copy Markdown
Member

@adamjstewart adamjstewart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing we aren't getting coverage because CVS isn't installed on the OS the GitHub Actions are running on.

@eschnett eschnett marked this pull request as draft June 16, 2021 14:53
@eschnett
Copy link
Copy Markdown
Contributor Author

@scheibelp There has been a development after your review...

It turns out that CVS uses different date formats on different systems. Parsing with strptime doesn't work, and I'm using the python-dateutils package instead. This works fine, but this package is not available for Python 2.6. That leaves three options:

  • Develop my own general date parsing function (I don't want to do this)
  • Find a similar package that supports Python 2.6 (I couldn't find one)
  • Disable testing "checkout by date" on Python 2.6

Note that this only affects testing, CVS support itself doesn't require this package.

I've implemented the third with a few if statements. See the beginning of conftest.py:

if sys.version_info >= (2, 7):
    # This package does not exist for Python <2.7. That means that we cannot
    # test checkouts "by date" for CVS respositories. (We can still use CVS
    # repos with all features, only our tests break.)
    from dateutil.parser import parse as parse_date
else:
    def parse_date(string):
        return None

Please let me know whether this is fine.

@eschnett
Copy link
Copy Markdown
Contributor Author

I've converted this to a draft since I didn't want this to be merged automatically.

@scheibelp
Copy link
Copy Markdown
Member

I also prefer option 3 of #23212 (comment), although my preference is that this be implemented with pytest.mark.skipif on the test itself (if that's hard to do as a decorator because of parameterization, I think git_fetch has an example of pytest.skip inside of the unit test.

On the other hand, that separates the skip from the reason (i.e. the construction in the fixture in conftest, so I'm wondering if you could conditionally define a parse_date that looks like:

def parse_date(string):
    pytest.skip("Not available for Python 2.6")

And it also occurs to me it might be worth mentioning that CVS outputs different date formats for different systems in a comment related to this logic.

@eschnett eschnett marked this pull request as ready for review June 17, 2021 19:35
@scheibelp
Copy link
Copy Markdown
Member

Closing/reopening to restart pipeline

@scheibelp scheibelp closed this Jun 22, 2021
@scheibelp scheibelp reopened this Jun 22, 2021
@scheibelp scheibelp merged commit e3b220f into spack:develop Jun 22, 2021
@scheibelp
Copy link
Copy Markdown
Member

Thanks!

@eschnett
Copy link
Copy Markdown
Contributor Author

eschnett commented Jun 22, 2021 via email

import tempfile
import xml.etree.ElementTree

if sys.version_info >= (2, 7):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eschnett according to https://github.com/spack/spack/pull/24471/checks?check_run_id=2887741511 this is also not supported for Python 2.7 either (at least on our CI systems). I'm not sure why but that didn't get caught in the CI for this PR, but I think this statement will have to skip import of dateutil for all Python 2.x. Do you have a minute to update this? I'm trying to get time ASAP but won't be able to for another hour or so.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made an attempt at this at #24473

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still see errors like the one above (e.g. at https://github.com/spack/spack/pull/24388/checks?check_run_id=2890513500). I don't think this is related to Python 2.7, because it's not the CVS-related code that is failing.

I think what is going on is the following: As part of the test suite, there is an analysis stage (related to external/_pytest) which analyzes the Python code. This analysis stage comes across the import dateutil statement and cannot handle it.

I don't know what external/_pytest does, or what analysis stage that is. But maybe it would suffice to tell this stage that dateutil is now a fine package to be imported, and to not worry about it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised: at least one PR submitted since #24473 has passed CI (#24481) so I'm wondering if there is an issue where PRs that failed due to this are difficult to correct (for the PR you linked, it hit this problem, and you pushed additional commits after it was corrected, but I see the CI fails in both cases).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posting a detail that I noticed on a PR of mine #24398 that is being hit by the same issue. When the error happens it seems Spack picks Python 3.8 as the interpreter, even if it is in the Python 2.7 CI job. See here for the log of the failure.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this uncovered some kind of subtle bug where package only PRs are running on Python 3.8 when in the Python 2.7 CI job

@alalazo
Copy link
Copy Markdown
Member

alalazo commented Jun 23, 2021

I see this PR introduced a dependency on python-dateutil at least to run tests, but if I am not missing something it doesn't vendor the corresponding package. This means that before this PR one could git clone Spack and run:

$ spack unit-test

while after this PR we need to:

$ pip install python-dateutil

before running any unit test locally. Is this wanted?

alalazo added a commit to alalazo/spack that referenced this pull request Jun 23, 2021
Before spack#23212 people could clone spack and run
```
spack unit-tests
```
while now this is not possible, since python-dateutil is
a required but not vendored dependency. This change makes
it not a hard requirement, i.e. it will be used if found
in the current interpreter.
alalazo added a commit to alalazo/spack that referenced this pull request Jun 23, 2021
Before spack#23212 people could clone spack and run
```
spack unit-tests
```
while now this is not possible, since python-dateutil is
a required but not vendored dependency. This change makes
it not a hard requirement, i.e. it will be used if found
in the current interpreter.
sethrj pushed a commit that referenced this pull request Jun 23, 2021
…ed (#24484)

* Force the Python interpreter with an env variable

This commit forces the Python interpreter with an
environment variable, to ensure that the Python set
by the "setup-python" action is the one being used.

Due to the policy adopted by Spack to prefer python3
over python we may end up picking a Python 3.X
interpreter where Python 2.7 was meant to be used.

* Revert "Update conftest.py (#24473)"

This reverts commit 477c8ce.

* Make python-dateutil a soft dependency for unit tests

Before #23212 people could clone spack and run
```
spack unit-tests
```
while now this is not possible, since python-dateutil is
a required but not vendored dependency. This change makes
it not a hard requirement, i.e. it will be used if found
in the current interpreter.

* Workaround mypy complaint
@eschnett
Copy link
Copy Markdown
Contributor Author

@alalazo I don't know what "to vendor" means.

Yes, one now needs to install python-dateutils as well – I didn't realize that this could lead to trouble. I guess it would be possible to test whether this package is installed, and if not, skip the respective tests with a warning?

@alalazo
Copy link
Copy Markdown
Member

alalazo commented Jun 23, 2021

I don't know what "to vendor" means.

That's a good definition of what I mean by "vendor". We have a few 3rd party libraries shipped with Spack in lib/spack/spack/external.

I guess it would be possible to test whether this package is installed, and if not, skip the respective tests with a warning?

Should be hopefully solved by #24484 thanks!

bollig pushed a commit to bollig/spack that referenced this pull request Jun 29, 2021
Spack packages can now fetch versions from CVS repositories. Note
this fetch mechanism is unsafe unless using :extssh:. Most public
CVS repositories use an insecure protocol implemented as part of CVS.
bollig pushed a commit to bollig/spack that referenced this pull request Jun 29, 2021
…ed (spack#24484)

* Force the Python interpreter with an env variable

This commit forces the Python interpreter with an
environment variable, to ensure that the Python set
by the "setup-python" action is the one being used.

Due to the policy adopted by Spack to prefer python3
over python we may end up picking a Python 3.X
interpreter where Python 2.7 was meant to be used.

* Revert "Update conftest.py (spack#24473)"

This reverts commit 477c8ce.

* Make python-dateutil a soft dependency for unit tests

Before spack#23212 people could clone spack and run
```
spack unit-tests
```
while now this is not possible, since python-dateutil is
a required but not vendored dependency. This change makes
it not a hard requirement, i.e. it will be used if found
in the current interpreter.

* Workaround mypy complaint
@eschnett eschnett deleted the eschnett/cvs branch July 12, 2021 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants