Skip to content

Conversation

@pont-us
Copy link
Member

@pont-us pont-us commented Apr 8, 2025

Parameter detection now uses a Python exporter to convert notebook code in the parameter cell and the setup cells that precede it, rather than (as previously) just extracting the code directly from the cell.

Also, a code snippet is prepended to the exported user code (both during parameter extraction and in the final exported script) which defines get_ipython() as a MagicMock, effectively turning all magic commands (which wouldn't work outside IPython) into no-ops.

Closes #14 .

Parameter detection now uses a Python exporter to convert
notebook code in the parameter cell and the setup cells
that precede it, rather than (as previously) just extracting
the code directly from the cell.

Also, a code snippet is prepended to the exported user code
which defines get_ipython() as a MagicMock, effectively
turning all magic commands (which wouldn't work outside
IPython) into no-ops.

Addresses Issue 14.
@codecov
Copy link

codecov bot commented Apr 8, 2025

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.21%. Comparing base (5f8af15) to head (889e2b7).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
xcengine/core.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #16      +/-   ##
==========================================
+ Coverage   74.09%   74.21%   +0.11%     
==========================================
  Files           6        6              
  Lines         471      477       +6     
  Branches       55       55              
==========================================
+ Hits          349      354       +5     
- Misses        115      116       +1     
  Partials        7        7              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

pont-us added 2 commits April 8, 2025 15:23
This was already done during parameter extraction, but
this commit also adds the mock to the final script output,
making the script runnable (in principle) outside an IPython
environment.

This commit also fixes a minor unittest import problem.
@pont-us pont-us changed the title Make parameter extraction more robust Make parameter extraction more robust and ignore magic Apr 8, 2025
@pont-us pont-us marked this pull request as ready for review April 8, 2025 13:32
@pont-us pont-us merged commit 2aa8157 into main Apr 8, 2025
8 checks passed
@pont-us pont-us deleted the pont-14-handle-magic branch May 9, 2025 16:31
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.

Handle ipython magic commands

2 participants