Skip to content

The check for internal types in RewriteArrayExprs - #6753

Merged
sklam merged 3 commits into
numba:masterfrom
Alexander-Makaryev:fix-rewrite-arrayexprs-external-types
Mar 4, 2021
Merged

sklam merged 3 commits into
numba:masterfrom
Alexander-Makaryev:fix-rewrite-arrayexprs-external-types

Conversation

@Alexander-Makaryev

Copy link
Copy Markdown
Contributor

Fixes #5157

Please look at issue for more details.

The implementation is based on comment from @stuartarchibald :
#5157 (comment)

Comment thread numba/tests/test_array_exprs.py Outdated
""" Tests RewriteArrayExprs with external (user defined) types,
see #5157"""

source_lines = """

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.

would suggest to use textwrap.dedent for better code alignment here: https://docs.python.org/3/library/textwrap.html#textwrap.dedent

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.

done
thanks

@sklam sklam added the 4 - Waiting on author Waiting for author to respond to review label Feb 24, 2021
@stuartarchibald stuartarchibald added the Effort - short Short size effort needed label Feb 24, 2021
@Alexander-Makaryev

Copy link
Copy Markdown
Contributor Author

@stuartarchibald
Looks like that we got some failure in CI tests that are not related to this PR.
Previous run of CI was green (https://dev.azure.com/numba/numba/_build/results?buildId=8051&view=results) and there are no significant changes in commits since that time.
What should I do? Do I need to report it somehow or restart tests in this PR?

@sklam sklam added 4 - Waiting on reviewer Waiting for reviewer to respond to author and removed 4 - Waiting on author Waiting for author to respond to review labels Mar 1, 2021
@stuartarchibald

Copy link
Copy Markdown
Contributor

/AzurePipelines run

@azure-pipelines

Copy link
Copy Markdown
Contributor
Azure Pipelines successfully started running 1 pipeline(s).

@stuartarchibald

Copy link
Copy Markdown
Contributor

@Alexander-Makaryev I've restarted the build, and am working on a fix, it's not this PR at fault. Once a fix for it makes it into mainline the CI builders will pick it up and it shouldn't happen again (at least for this particular issue).

@stuartarchibald stuartarchibald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the patch and for fixing this issue, just one minor comment to resolve else looks good.

Comment thread numba/np/ufunc/array_exprs.py Outdated
Comment on lines +660 to +684
# copied from test_types
@contextlib.contextmanager
def create_temp_module(self, source_lines=None, **jit_options):
# Use try/finally so cleanup happens even when an exception is raised
try:
if source_lines is None:
source_lines = self.source_lines
tempdir = temp_directory('test_extension_type')
# Generate random module name
temp_module_name = 'test_extension_type_{}'.format(
str(uuid.uuid4()).replace('-', '_'))
temp_module_path = os.path.join(tempdir, temp_module_name + '.py')

with open(temp_module_path, 'w') as f:
lines = source_lines.format(jit_options=jit_options)
f.write(lines)
# Add test_module to sys.path so it can be imported
sys.path.insert(0, tempdir)
test_module = importlib.import_module(temp_module_name)
yield test_module
finally:
sys.modules.pop(temp_module_name, None)
sys.path.remove(tempdir)
shutil.rmtree(tempdir)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It'd be nice to refactor this into numba.tests.support, but perhaps not for this PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

#6778 tracks

Co-authored-by: stuartarchibald <stuartarchibald@users.noreply.github.com>

@stuartarchibald stuartarchibald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix @Alexander-Makaryev, looks good.

@stuartarchibald stuartarchibald added 4 - Waiting on CI Review etc done, waiting for CI to finish and removed 4 - Waiting on reviewer Waiting for reviewer to respond to author labels Mar 1, 2021
@stuartarchibald

Copy link
Copy Markdown
Contributor

/AzurePipelines run

@azure-pipelines

Copy link
Copy Markdown
Contributor
Azure Pipelines successfully started running 1 pipeline(s).

@stuartarchibald

Copy link
Copy Markdown
Contributor

/AzurePipelines run

@azure-pipelines

Copy link
Copy Markdown
Contributor
Azure Pipelines successfully started running 1 pipeline(s).

@stuartarchibald stuartarchibald added 5 - Ready to merge Review and testing done, is ready to merge and removed 4 - Waiting on CI Review etc done, waiting for CI to finish labels Mar 3, 2021
@sklam
sklam merged commit 7a4b7f8 into numba:master Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 - Ready to merge Review and testing done, is ready to merge Effort - short Short size effort needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RewriteArrayExprs pass incorrectly rewrites all Array-returning operations

4 participants