abjad in Google Colab

148 views
Skip to first unread message

padovani

unread,
Apr 19, 2021, 9:47:18 AM4/19/21
to abjad...@googlegroups.com
Hi,

I have managed to run Abjad in Google Colab, as I think it can be very useful in class situations to start working with students that may have any troubles installing abjad in the first classes/meetings.

Do you have any suggestions on how to change the ipython show code to automatically find/show the generated svg file (i.e., the same behaviour expected when one runs "abjad.show()" in a regular python notebook? 

By now I'm using an ls command, but it is clearly not the best way to deal with it.

My test notebook is here:

Any tips/suggestions are appreciated,

Thanks in advance,

José H.

padovani

unread,
Apr 19, 2021, 10:56:06 AM4/19/21
to abjad...@googlegroups.com

Trevor Bača

unread,
Apr 19, 2021, 11:27:46 AM4/19/21
to abjad...@googlegroups.com
Hi José,

My initial response is that I'm reluctant to endorse this way of working, only because I don't use Abjad in Google Colab myself. And so I worry about inadvertently creating a future support burden on this mailing list. ("Hi, why doesn't --- in Abjad work when I run it Google Colab?" I'm definitely never going to be answering those questions.)

To be honest, I somewhat regret that Abjad offers IPython support at all. The Mathematica notebook interface that IPython copies is a great interface for teaching and presentation. But it's the wrong interface for composing real-world scores: the fact that notebook cells can be evaluated out of order is, for a first example, truly lethal when you start building up a real score.

Learning to compose in Abjad means learning to program in Python, and at some point new users are going to have to learn how to install Abjad on their own computers. My fear is that IPython forestalls that effort of learning. And Google Colab even more so.

Trevor.



--
You received this message because you are subscribed to the Google Groups "abjad-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to abjad-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/abjad-user/CA%2BZFxkFjRXk7mFf1sZG8QALP4M2of0k3Shn4PO63Eeo25osn-Q%40mail.gmail.com.


--

padovani

unread,
Apr 19, 2021, 12:52:39 PM4/19/21
to abjad...@googlegroups.com
Hi Trevor,

Thank you for your quick response. I understand your opinion/position and, from an strictly individual point of view, I tend to agree: I also don't frequently use ipython notebooks (neither Colab). 

However, as a teacher my main focus is making the first step into creative practices with computer tools as easy and wide as possible, and, for this purpose, notebooks and Colab are very handy. I have students with very different degrees of programming skills, including some that frequently have problems configuring environments that are much simpler than Python (Pure Data, for instance). Also, some do not have their own computer (and share the computer with other family members) or attend to classes using tablets / phones. That is to say that I do have to take the idiosyncrasies of my social/educational environment in mind, particularly living/working in Brazil and specially teaching remotely as I have been doing in the last months (and probably, giving our tragic reality, many more months ahead).

Additionally, I would like to stress that my question *is not* a feature request or something like that. What I'm exploring here are possibilities/alternatives of use that may help students to engage with Python/abjad.

cheers,
josé

Tsz Kiu Pang

unread,
Apr 24, 2021, 9:23:51 PM4/24/21
to abjad-user
Hi José,

That is very strange indeed.
The `abjad.show()` method works fine in my jupyter notebook, but you are right, it does not seem to work in the Colab notebook.

Since we are probably not going to support ipython, not to say ipython in Colab, you might want to find a workaround instead.
From the top of my head, maybe you could define a method that writes the `staff` to a tmp.ly file using `abjad.lilypond(staff)`, then you could call lilypond to render the file.
Finally, you can use the `IPython.display` method to display the rendered music.

Hope this helps.

Cheers,
Tsz Kiu

Davi Raubach Tuchtenhagen

unread,
May 3, 2021, 1:57:36 PM5/3/21
to abjad...@googlegroups.com
Hey, I just remembered to tell you, if you don’t know it yet, about https://hacklily.org (online sheet-music editor and publishing tool).
It would be also an easy option to compile lilypond code you generate in google collab.
Just in case…
http://lilybin.com also does the same.

Davi Raubach

padovani

unread,
May 5, 2021, 5:40:55 PM5/5/21
to abjad...@googlegroups.com
Hi! 

Thanks for the feedback! I had a very wonderful zoom meeting with Trevor another day (thank you again Trevor!) and I'm currently structuring my own paths to introduce abjad to students without Colab (I will keep it as last option: for sure, it is not the ideal environment).

In any case, I hope that we continue to have an ipython extension (wish I was able to help with this). Even if it is not the best way to use abjad in larger projects, I see ipython as a very useful tool in education situations (specially to introduce "code" based music tools to students who are used to languages based on patches and similar graphical interfaces).

I thank you all again for the tips and the feedback!

josé

Adam McCartney

unread,
May 8, 2021, 11:44:59 AM5/8/21
to abjad-user
hi josé, trevor & all

is the main issue the overhead created by setting up the development environment on a host of different machines?
I recently spent a couple of years teaching a bunch of computer music classes at a community college without
any proper facilities and was faced with a similar problem. My own experience as a student was always in a college
with a dedicated computer room with a bunch of desktops that had pre-installed software and it meant that we could
focus on music related computer stuff, rather than spending half the semester trying to figure out how to set up a particular
environment.

I'm not sure what sort of solutions yourself and Trevor have already discussed, but I was wondering if it might
be possible to set up a cloud based solution to your problem? Setting up a container for abjad development
would be an interesting little exercise, and it shouldn't be a huge stretch to get this running on a server where
users could access using ssh. You could use a fresh container image per cohort or whatever, so it would be
easy enough from an admin perspective for you to manage the server.
The fact that abjad outputs pdfs to its root directory by default is also pretty handy, because it means that any
sort of a simple socketserver running in this directory would make the pdfs directly accessibly through the browser.

Also, I don't know if part of the discussion was whether or not maintaining ipython support was a bit of a crick in the neck.
I imagine that possibly replacing this with a single docker image and then encouraging users to pursue a modular workflow
might be less work?

Let me know what y'all think!

regards,
Adam
Reply all
Reply to author
Forward
0 new messages