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

🐛 Fix --version, add enter, parse-resources and version, and fix tests #29

Merged
merged 68 commits into from
Apr 20, 2022

Conversation

shnizzedy
Copy link
Member

@shnizzedy shnizzedy commented Mar 17, 2022

Fixes

Fixes #22 by @keithcdodd & @shnizzedy
Fixes shnizzedy/cpac#17 by @shnizzedy
Fixes shnizzedy/cpac#25 by @shnizzedy
Related to #26 by @gkiar
Related to #27 by @shnizzedy

Description

  • Fixes issue where cpac --version was returning the usage text instead of the version

While I was doing that ☝️, I fixed a few other things that I was touching anyway:

Technical details

  • In fixing the failing tests here, I discovered --tracking_opt-out isn't being applied to the config commandline utility in C-PAC, so there's some code here to set up the tracking config if it doesn't exist:
    def get_or_create_config(udir):
    """Function to create a Google Analytics tracking config file.
    Sourced from https://github.com/FCP-INDI/C-PAC/blob/80424468c7f4e59c102f446b05d4154ec1cd4b2d/CPAC/utils/ga.py#L19-L30
    """ # noqa: E501 # pylint: disable=line-too-long
    tracking_path = os.path.join(udir, '.cpac')
    cparser = configparser.ConfigParser()
    if os.path.exists(tracking_path):
    cparser.read(tracking_path)
    if not cparser.has_section('user'):
    cparser.read_dict(dict(user=dict(uid=uuid.uuid1().hex,
    track=True)))
    with open(tracking_path, 'w+') as fhandle:
    cparser.write(fhandle)
    return tracking_path
  • This update increases the minimum Python version from 3.6 to 3.7
  • 👷 Tests are failing in Singularity on GitHub Actions but passing locally #32

Tests

  • wrapper_version_string = f'cpac (convenience wrapper) version {__version__}'
    def startswith_cpac_version(captured):
    """Check if captured text starts with cpac version
    Parameters
    ----------
    captured : str
    Returns
    -------
    bool
    """
    return captured.out.strip().startswith(wrapper_version_string)
    @pytest.mark.parametrize('argsep', [' ', '='])
    def test_cpac_version(argsep, capsys, platform=None, tag=None):
    r"""Test `cpac version`"""
    def run_test(argv, platform):
    with mock.patch.object(sys, 'argv', argv):
    run()
    captured = capsys.readouterr()
    assert startswith_cpac_version(captured)
    assert 'C-PAC version ' in captured.out
    if platform is not None:
    assert platform.title() in captured.out
    else:
    assert 'Docker' in captured.out
    args = set_commandline_args(platform, tag, argsep)
    argv = 'version'
    def test_cpac__version(capsys):
    r"""Test `cpac --version`"""
    with mock.patch.object(sys, 'argv', ['cpac', '--version']):
    with pytest.raises(SystemExit):
    run()
    captured = capsys.readouterr()
    assert startswith_cpac_version(captured)
  • Updated all failing tests
  • I'm not sure how to write tests for enter ― that command opens an interactive prompt in a container.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I updated the changelog.
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

jarrodmillman and others added 30 commits July 15, 2009 19:55
- ✨ Add config and test-config tracking
- ⚕️ Handle tracking errors

Resolves #1025

Ref #1172

on-behalf-of: @FCP-INDI <http://fcp-indi.github.com>
- ✨ Add config and test-config tracking
- ⚕️ Handle tracking errors

Resolves #1025

Ref #1172

on-behalf-of: @FCP-INDI <http://fcp-indi.github.com>
- ✨ Add config and test-config tracking
- ⚕️ Handle tracking errors

Resolves #1025

Ref #1172

on-behalf-of: @FCP-INDI <http://fcp-indi.github.com>
Publish v1.7.1 to Master Branch
⚡️ Update memory and threading estimates
@shnizzedy shnizzedy marked this pull request as draft March 17, 2022 18:11
@shnizzedy shnizzedy force-pushed the fix/version branch 2 times, most recently from c07296c to 0b166d5 Compare April 13, 2022 17:04
@shnizzedy shnizzedy marked this pull request as ready for review April 13, 2022 17:53
@shnizzedy shnizzedy merged commit b3a1b6b into develop Apr 20, 2022
@shnizzedy shnizzedy deleted the fix/version branch April 20, 2022 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request support user-reported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants