KarthikRIyer / swiftplot

Swift library for Data Visualization :bar_chart:
Apache License 2.0
400 stars 39 forks source link

Support on Google Colab #132

Closed philipturner closed 2 years ago

philipturner commented 2 years ago

I just revived support for Swift on Google Colab and changed how it used SwiftPlot. Is there a more comprehensive test suite I can run besides the one example given on google/swift-jupyter?

KarthikRIyer commented 2 years ago

There's a test suite in swiftplot: https://github.com/KarthikRIyer/swiftplot/tree/master/Tests

To run it on colab, you'd need to modify each test to get a base64 image.

KarthikRIyer commented 2 years ago

Is the new mechanism coupled with swiftplot, that requires a comprehensive test suite for colab support?

philipturner commented 2 years ago

It isn’t much change. I just patched up EnableIPythonDisplay.swift. I didn’t add much content, and you can compare the files in Sources/SwiftColab/include to google/swift-jupyter. I just thought it would be a good idea to test out Swift on Colab, and it’s been so long that something might break naturally.

Sent from my iPhone

On Dec 30, 2021, at 10:10 PM, Karthik Ramesh Iyer @.***> wrote:

 Is the new mechanism coupled with swiftplot, that requires a comprehensive test suite for colab support?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

philipturner commented 2 years ago

Rather than Swift Package tests, I’m looking for a Colab notebook. You could call git clone on your repository to get files (%system commands), but I’m concerned with how stable the communication between SwiftPlot and IPythonDisplay is. In other words, I’d like to see more graphs than the 2 shown on swift-jupyter.

I’m not that familiar with SwiftPlot and don’t have the time to be, but I assume this isn’t too difficult of something for you to whip up. The Colab notebook will be used as a test suite similarly to the 3 Colab notebooks on Swift-Colab’s README that are translated from Python unit tests.

Sent from my iPhone

On Dec 30, 2021, at 11:10 PM, Philip Turner @.***> wrote:

It isn’t much change. I just patched up EnableIPythonDisplay.swift. I didn’t add much content, and you can compare the files in Sources/SwiftColab/include to google/swift-jupyter. I just thought it would be a good idea to test out Swift on Colab, and it’s been so long that something might break naturally.

Sent from my iPhone

On Dec 30, 2021, at 10:10 PM, Karthik Ramesh Iyer @.***> wrote:

 Is the new mechanism coupled with swiftplot, that requires a comprehensive test suite for colab support?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

philipturner commented 2 years ago

@KarthikRIyer any update on the Colab notebook?

philipturner commented 2 years ago

I really need a test suite like the ones posted on Swift-Colab's README. It should use a similar format and might come with image files of what each graph is expected to look like. This should be a long-term validation test of whether IPythonDisplay.swift is functioning correctly. Anyone in the data science community could create the test suite, assuming they've learned your graphing API.

To clarify once more, I am not asking for Swift package tests. I'm asking for a Google Colab notebook that imports SwiftPlot and other long-term maintained packages (if any).

KarthikRIyer commented 2 years ago

Apologies for the delayed response. I haven't been keeping well for a while.

I haven't had the bandwidth to work on swiftplot. And converting all the unit tests to tests on colab is a time consuming process. Porting a single test to colab shouldn't need a lot of familiarity with the API though. You just need to get the base64 image as shown in the AGGRenderer tests and use the display function.

philipturner commented 2 years ago

I don't need every single unit test. Just a subset of them. Even two would be fine. Look at the lengths of the Colab notebooks that already exist for testing. I made this comment today hoping that somebody besides you or me would see it and make the short test suite.

KarthikRIyer commented 2 years ago

Hi @philipturner Here's a colab file with a few more plots: https://colab.research.google.com/drive/1Rxs7OfuKIJ_hAm2gUQT2gWSuIcyaeZfz?usp=sharing

The subplots output isn't right. Seems like a bug in the function that returns the plot as base64. I didn't get the time to look into this yet. But it doesn't look like an issue with swift-colab. You could use these tests with all the plots at the default size for now.

philipturner commented 2 years ago

Thank you so much!!!! I can definitely patch up what you have and post it as a test! I didn’t expect that you would actually do this!

If possible, I could have you add the link to my final notebook in a PR. That would make you listed as a contributor to Swift-Colab.

Sent from my iPhone

On Jan 21, 2022, at 5:43 AM, Karthik Ramesh Iyer @.***> wrote:

 Hi @philipturner Here's a colab file with a few more plots: https://colab.research.google.com/drive/1Rxs7OfuKIJ_hAm2gUQT2gWSuIcyaeZfz?usp=sharing

The subplots output isn't right. Seems like a bug in the function that returns the plot as base64. I didn't get the time to look into this yet. But it doesn't look like an issue with swift-colab. You could use these tests with all the plots at the default size for now.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

KarthikRIyer commented 2 years ago

No problem! Thanks for being patient, and apologies for they delay.

I've opened a PR to add the test to the README.

philipturner commented 2 years ago

Again, thanks so much for doing this. I completely rewrote the mechanism for transferring base64 images between processes, and it might be faster now. Your notebook survived the makeover and produces the exact same results!