Skip to content

Enabled file magic support for xeus-cpp-lite #261

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

Merged
merged 4 commits into from
Feb 27, 2025

Conversation

kr-2003
Copy link
Contributor

@kr-2003 kr-2003 commented Feb 27, 2025

Description

Enabled %file magic for xeus-cpp-lite.

Key Changes

  1. Included src/xmagics/os.cpp while compiling for EMSCRIPTEN in CMakeLists.txt.
  2. Registered file in preamble_manager["magics"].

Screenrecord

file-magic-working-pr.mp4

Type of change

  • New feature

@codecov-commenter
Copy link

codecov-commenter commented Feb 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.72%. Comparing base (74902e7) to head (5632eda).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #261   +/-   ##
=======================================
  Coverage   80.72%   80.72%           
=======================================
  Files          19       19           
  Lines         970      970           
  Branches       93       93           
=======================================
  Hits          783      783           
  Misses        187      187           
Files with missing lines Coverage Δ
src/xinterpreter.cpp 91.20% <100.00%> (ø)
Files with missing lines Coverage Δ
src/xinterpreter.cpp 91.20% <100.00%> (ø)

@anutosh491
Copy link
Collaborator

anutosh491 commented Feb 27, 2025

Hey @tharun571,

This is exactly what we were talking about yesterday and you might be interesting in how this works

  1. The file magic works for xeus-cpp
  2. We were able to do all sort of file read/write/open/close operations through xeus-cpp-lite. So something like this worked and we could manually create a file already
#include <iostream>
#include <fstream>

std::ofstream outfile ("test.txt");

outfile << "Hello World" << std::endl;

outfile.close();

image

  1. Which gave me enough confidence that, if we just enable this magic while building for emscripten, things would work right off the bat without any changes

So yeah I just asked Abhinav to check if it works and I think it does work. This is great actually

@anutosh491
Copy link
Collaborator

@kr-2003 what I observe is that both our example notebooks (for xeus-cpp and xeus-cpp-lite lack any sort of examples for the %%file magic)

Would you like to update the notebooks and add something for the both of them ?

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@anutosh491
Copy link
Collaborator

That being said, Tharun do we have any sort of example notebooks for the LLM work ? Not sure I remember, if no maybe we should add one. Probably you can help us address this !

@kr-2003
Copy link
Contributor Author

kr-2003 commented Feb 27, 2025

@kr-2003 what I observe is that both our example notebooks (for xeus-cpp and xeus-cpp-lite lack any sort of examples for the %%file magic)

Would you like to update the notebooks and add something for the both of them ?

Yeah. I will do that.

@tharun571
Copy link
Contributor

@anutosh491 this makes sense. I tested out XAssist in emscripten but it not seem to work due to the curl functions. Maybe I will test out again. The example is present in the documentation but I will raise a notebook example for general xassist usage as well.

@anutosh491
Copy link
Collaborator

anutosh491 commented Feb 27, 2025

I tested out XAssist in emscripten but it not seem to work due to the curl functions. Maybe I will test out again.

So yeah unfortunately this is bound to fail cause libcurl has been marked as "won't work" with emscripten (to my knowledge this means it can be done but involves making changes in emscripten that does not aligns with the roadmap the maintainers have). So yeah unfortunately this way might not work. But that being said JupyterLite/AI is up and we might want to think of a way to connect our magic with this !

The example is present in the documentation but I will raise a notebook example for general xassist usage as well.

Ahh yess, I forgot about it. If we have it documentated at one place, let's skip populating the notebook for now. @kr-2003 rather what you can do is ..... you can do something similar, just update these docs https://xeus-cpp.readthedocs.io/en/latest/magics.html on magics adding whatever examples and stating the magic works both on xeus-cpp and lite !

Once done, I can approve the PR and take it in.

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@vgvassilev
Copy link
Contributor

This PR needs tests.

Copy link
Collaborator

@anutosh491 anutosh491 left a comment

Choose a reason for hiding this comment

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

Looks good

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Contributor

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

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

@anutosh491, convinced me offline to move forward with this pull request given it has no tests this one time. We should open an issue to remind us we to add tests at our earlier convenience. We should do no more exceptions in landing code with no tests from this point on.

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@anutosh491 anutosh491 merged commit 56b72e0 into compiler-research:main Feb 27, 2025
16 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.

5 participants