Skip to content

Fix an import in the tests that doesn’t seem to work as intended#612

Merged
alanking merged 1 commit into
irods:mainfrom
musicinmybrain:helpers-import
Aug 23, 2024
Merged

Fix an import in the tests that doesn’t seem to work as intended#612
alanking merged 1 commit into
irods:mainfrom
musicinmybrain:helpers-import

Conversation

@musicinmybrain
Copy link
Copy Markdown
Contributor

I’m considering packaging this in Fedora Linux. I don’t have the ability to test this with a real iRODS grid, so I’m using an import-only “smoke test” as a sanity check. I found that irods.test.resource_test fails to import, at least on Python 3.13, with an ImportError like the following:

  File "/builddir/build/BUILD/python-python-irodsclient-2.1.0-build/BUILDROOT/usr/lib/python3.13/site-packages/irods/test/resource_test.py", line 14, in TestResource
    from helpers import create_simple_resc_hierarchy, create_simple_resc
ModuleNotFoundError: No module named 'helpers'

Maybe this works on older Python interpreters – I’m not sure – but this PR fixes the problem in a way that should be compatible with all Pythons.

@alanking alanking requested a review from d-w-moore August 23, 2024 13:30
Copy link
Copy Markdown
Contributor

@alanking alanking left a comment

Choose a reason for hiding this comment

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

Seems fine to me. What say you, @d-w-moore?

We will need to attach an issue number to this, per our contribution process. Please create an issue describing the problem (what you've said already can just be copied as it captures it nicely) and make the commit message look like this:

[#XXX] Fix an import in the tests that doesn’t seem to work as intended

If you're feeling really nice, omit the # until this is approved at which point the commit message should be amended to include the # and force-pushed.

We can also do this for you, if you'd like. Up to you.

Thanks!

@musicinmybrain
Copy link
Copy Markdown
Contributor Author

Thanks! I filed an issue, #613, and adjusted the commit message as requested.

Copy link
Copy Markdown
Collaborator

@d-w-moore d-w-moore left a comment

Choose a reason for hiding this comment

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

On the surface it seems fine, and I agree it probably doesn't break anything for older Python.

Copy link
Copy Markdown
Contributor

@alanking alanking left a comment

Choose a reason for hiding this comment

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

Excellent. @musicinmybrain - Please amend the commit message to include the # and we will get this in. Thanks!

@trel
Copy link
Copy Markdown
Member

trel commented Aug 23, 2024

this is an interesting fix. do we not have this from helpers import ... elsewhere in the codebase?

@alanking
Copy link
Copy Markdown
Contributor

this is an interesting fix. do we not have this from helpers import ... elsewhere in the codebase?

This is the only place in the codebase where this occurs. It may have to do with the fact that the helpers package is itself an alias and we are attempting to import stuff from that:

import irods.test.helpers as helpers

@trel
Copy link
Copy Markdown
Member

trel commented Aug 23, 2024

ah, yes, i bet that's it.

@musicinmybrain
Copy link
Copy Markdown
Contributor Author

Right, the full context is,

import irods.test.helpers as helpers

class TestResource(unittest.TestCase)::
    from helpers import create_simple_resc_hierarchy, create_simple_resc

to get a reference to irods.test.helpers.create_simple_resc_hierarchy as TestResource.create_simple_resc_hierarchy and a reference to irods.test.helpers.create_simple_resc_hierarchy as TestResource.create_simple_resc. But:

  • The fact there is a module-scope variable helpers that happens to be an imported module doesn’t imply that there is a helpers on the Python path available for use as an absolute import. Current versions of Python are correct to raise an ImportError here.
  • The intent is better expressed as assignment anyway; the module containing the functions was already imported.

Although I could have missed something, I didn’t find a similar situation elsewhere in a quick search of the code.

@musicinmybrain
Copy link
Copy Markdown
Contributor Author

Excellent. @musicinmybrain - Please amend the commit message to include the # and we will get this in. Thanks!

Done – and thanks for the quick review!

@trel
Copy link
Copy Markdown
Member

trel commented Aug 23, 2024

sounds great. thanks for the attention!

@alanking alanking merged commit 2a441e7 into irods:main Aug 23, 2024
@trel
Copy link
Copy Markdown
Member

trel commented Aug 23, 2024

did a request come in to package this for fedora? or was this 'self-assigned'?

@musicinmybrain
Copy link
Copy Markdown
Contributor Author

Snakemake has been packaged in Fedora as part of the NeuroFedora special-interest group for a while, and since Snakemake 8 switched to a modular, plugin-based design, I’ve been gradually working through the Snakemake Plugins Catalog to try to get as much of it packaged in Fedora as I can reasonably manage – especially the “official”/“first-party” plugins developed by the Snakemake team – since Snakemake 8 is not necessarily very useful without a reasonably extensive plugin collection. Packaging python-irodsclient would allow me to package https://github.com/snakemake/snakemake-storage-plugin-irods. I haven’t seen anyone asking for that plugin (or any other plugin) in Fedora in particular, just general sentiment that we should definitely keep maintaining Snakemake in Fedora.

@trel
Copy link
Copy Markdown
Member

trel commented Aug 23, 2024

oh nice. didn't know about that plugin. hi @stsnel!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants