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

Sourcefile does not have a filepath #177

Merged
merged 3 commits into from
Nov 8, 2023

Conversation

joscao
Copy link
Contributor

@joscao joscao commented Oct 23, 2023

  • sourcefile has a source not a filepath

- sourcefile has a source not a filename
@joscao joscao changed the title Sourcefile does not have a filepatj Sourcefile does not have a filepath Oct 23, 2023
@codecov
Copy link

codecov bot commented Oct 23, 2023

Codecov Report

Merging #177 (87bc181) into main (af8ec9f) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #177   +/-   ##
=======================================
  Coverage   92.14%   92.14%           
=======================================
  Files          90       90           
  Lines       16690    16690           
=======================================
  Hits        15379    15379           
  Misses       1311     1311           
Flag Coverage Δ
lint_rules 96.22% <ø> (ø)
loki 92.11% <ø> (ø)
transformations 91.40% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Collaborator

@reuterbal reuterbal left a comment

Choose a reason for hiding this comment

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

Thanks, that's a nice find. Any chance we could test this behaviour in a test, since it's clearly not covered at the moment?

Also, I think the property to be used is Sourcefile.path rather than source.

@@ -71,7 +71,7 @@ def jit_compile(source, filepath=None, objname=None):
Return a specific object (module or subroutine) in :attr:`source`
"""
if isinstance(source, Sourcefile):
filepath = source.filepath if filepath is None else Path(filepath)
filepath = source.source if filepath is None else Path(filepath)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I disagree, Sourcefile.source is an object of type Source rather than a path. However, the current implementation is also wrong, it should be using source.path rather than source.filepath:

self.path = Path(path) if path is not None else path

Copy link
Contributor Author

@joscao joscao Oct 23, 2023

Choose a reason for hiding this comment

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

Used path instead of source. bc8f27b

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discovered that filepath can still be empty, therefore is starting to write in ".", avoid this by using tempdir
87bc181

@joscao joscao requested a review from reuterbal October 23, 2023 16:48
Copy link
Collaborator

@reuterbal reuterbal left a comment

Choose a reason for hiding this comment

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

Thanks, also for the added handling of empty filepaths. Looks great now!

@reuterbal reuterbal merged commit 200343d into ecmwf-ifs:main Nov 8, 2023
7 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants