LiaScript / CodeRunner-Elixir

A WebServer that can be used to compile and execute code remotely... Or use our setup to make your LiaScript courses interactive...
https://liascript.github.io/course/?https://github.com/liascript/CodeRunner
7 stars 2 forks source link

[FR] Add julia #10

Open BeastyBlacksmith opened 1 year ago

BeastyBlacksmith commented 1 year ago

Would it be possible to add the ability to execute julia code?

andre-dietrich commented 1 year ago

@BeastyBlacksmith Yes, It might take a while, since I wanted to update the Elixir implementation a bit, but it shouldn't be problematic ... When do you need it? ;-)

BeastyBlacksmith commented 1 year ago

By end of September would be nice. If I can help with the julia related part, you can ping me anytime.

andre-dietrich commented 1 year ago

@BeastyBlacksmith It took some time ... sorry ... within the next week we will migrate from heroku, I could not update the original version the process somehow failed due to firejail ... However, there is a new version, this time developed with Python

https://github.com/LiaScript/CodeRunner2

Julia is also installed, you can try it from here:

https://liascript.github.io/course/?https://raw.githubusercontent.com/LiaScript/CodeRunner2/master/README.md#16

BeastyBlacksmith commented 1 year ago

Lovely, thank you for that. Do I understand it correctly that each code block is executed in a separate julia session?

It would be nice to have a way to start a julia session at the first execution and then evaluate new code blocks in that session.

Another nice addition would be to be able to specify the environment the code is executed in. Julia povides Project.toml files for that that one would pass to the julia process with e.g. julia --project=<path_to_file> or julia --project=@. to use the one in the current directory and the default environment if there is no file found.

andre-dietrich commented 1 year ago

Yes, at the moment it is one process per script-environment. You can define custom commands, if I got you right. If you take a look at the dotnet example, there is also a project-file used. If there is no space between two codesnippets then they are interpreted as one project:

```csharp
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>

@LIA.eval(["Program.cs", "project.csproj"], dotnet build -nologo, dotnet run)


The first parameter of `@LIA.eval` is a list of your filenames, the second one the build-command and the third one the run command. You can use your own configuration or create your own macro like:

```` markdown
<!--
@dotnet: @LIA.eval(`["Program.cs", "project.csproj"]`, `dotnet build -nologo`, `dotnet run`)
-->

# Title

```csharp
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>

@dotnet


----

concerning the session ... you can also use:

...

@LIA.eval(`["main.jl"]`, `none`, `julia`) 

this will create a file main.jl within a temporary folder, not use a compiler, and simply start the julia terminal ... stdin and out is active ... At the moment, the session will timeout after 60s, I increased this now to 5 minutes. This will then be online tomorrow ...

By the way, if you create diagrams and store them within the current folder as images then, they will be displayed at the end of the session, as presented in the R example ...