Engee documentation

Working with Genie at Engee

Engee provides the opportunity to develop your own applications directly in your environment using the Genie framework. This allows users to create their own applications, web interfaces, and various integration solutions without leaving the Engee workspace.

Engee is a ready—made and customized environment for running applications created using the Genie framework. Engee also provides basic functionality for their modification. Next, the article shows the basic principles of working with Genie, knowing which, you can adapt ready-made applications to your needs.

Genie is a framework for developing web applications for Julia. Read more about the framework at official website.

Genie has already been written and is fully functional Digital Filter Editor, Radar Equation Calculate and Calculation of power grid modes.

The Engee environment is optimized for working with the Genie framework and, despite full support for Julia and Python kernels, it is not recommended to use any other frameworks.

Using Genie

To create your own application in Engee, follow the instructions below. The application can be represented as .a jl script or directory with the 'app.jl` file. These applications are placed within the /user directory. The basic steps for launching, managing, and working with Genie-based applications are described below.

  1. Application placement — the created application must be placed in the /user directory. If the application is a directory, make sure that it contains the app.jl file. Example of placement:

    /user/apps/MyGenieApp/
        app.jl
        public/
        src/
  2. Launching the application — To launch the application, run the following command:

    engee.genie.start("/user/apps/MyGenieApp", devel=true, log_file="/user/apps/MyGenieApp")

    here:

    • devel: optional parameter, enables development mode, which allows you to see changes without restarting.

    • `log_file': the path for saving application logs. It is not necessary to specify.

      If a relative path is specified, the command searches for the application relative to the current directory.

  3. Stopping the application — to stop the running application, run:

    engee.genie.stop("/user/apps/MyGenieApp")

    The path can be set relative or absolute.

  4. List of running applications — to check which applications are currently running, run the command:

    engee.genie.list()
  5. Transfer data from the application to the session — the engee' function.genie.send(wsVarName, value) is used to transfer the value from the Genie application to the Engee workspace. The first argument wsVarName sets the variable name as a string. The second argument, `value', is the value that is stored in the variable. If there is no variable with that name, it is created automatically. Use this function to save intermediate results and user data in general. For example:

    engee.genie.send("a", 42)
    engee.genie.send("message", "Hello")
  6. Getting data from a session to an application is the engee' function.genie.recv(wsVarName; context=…​) allows you to get the value of a variable from the Engee environment during application execution on Genie. The wsVarName argument specifies the name of the variable. If the variable is defined in another module, the context parameter is used to specify which namespace to look for it in. This is necessary if the variable is pre-defined outside the scope of the main application module. For example:

    engee.genie.recv("a")
    engee.genie.recv("message")
    engee.genie.recv("value"; context=MyModule)
  7. Code execution in the workspace is the engee' function.genie.eval(code::AbstractString) allows you to execute arbitrary code on Julia in the Engee workspace directly from the Genie application. It is used to run individual expressions, debug, or dynamically execute code without having to restart the application.

    engee.genie.eval("x = 10")
    engee.genie.eval("println(\"Value of x: \$x\")")

    The passed string code::AbstractString is executed in the global scope of the current Engee session. This way, you can control variables or logic from the outside by passing commands from the Genie application inside the Engee session.

  8. View application logs — to get logs of a running application, use the command:

    engee.genie.logs("/user/apps/MyGenieApp")

    If the log_file parameter was not specified when launching the application, the command will still output the current logs.

Using third-party packages in the application

You can use third-party packages in the application. To do this, download the Project.toml file and run the command:

engee.genie.pkg_instantiate("/path/to/app")

At the same time:

  • The files app.jl and Project.toml must be located in the directory `/path/to/app'.

  • Project.toml should not contain Engee packages, but they will still be available for Genie.


Additional commands for working with packages:

Viewing the list of installed packages

To list all the packages used in the application, run the command:

engee.genie.pkg_status("/path/to/app")
Installing new packages

To install one or more packages, use:

engee.genie.pkg_add("/path/to/app", "SomePackage")

or

engee.genie.pkg_add("/path/to/app", ["SomePackage1", "SomePackage2"])
Removing packages

To remove one or more packages, run:

engee.genie.pkg_rm("/path/to/app", "SomePackage")

or

engee.genie.pkg_rm("/path/to/app", ["SomePackage1", "SomePackage2"])

Limitations and features of use

In Genie, arrays are indexed from zero, unlike Julia, where indexing starts from one.
  • It is not possible to install new packages that are not included in the Engee build. However, you can use the following command to view the available packages:

    print(read("/usr/local/genie/environments/v1.10/Project.toml",String))
  • An application presented as a directory with the app.jl file is considered standard. This is the recommended way to organize a project.

A detailed description of the public methods of software management "genie" is presented in the article. Genie’s Public Software Management Methods.

An example of creating an application

Create the app.jl file in the /user directory file browser file browser 7:

genie app 2 engenie app 3 en

In the app.jl' file, add the application code written using the Genie framework:

module App
using GenieFramework
@genietools

@app begin
    @in N = 0
    @out squared = 0
    @onchange N begin
        squared = N^2
    end
end

function ui()
    [
        cell([
            p("Enter a number to calculate its square:")
        ]),
        cell([
            textfield("N", :N)
        ]),
        cell([
            bignumber("The square of the number is:", :squared)
        ])
    ]
end

@page("/", ui)
end
Detailed description of the application code
  1. Creating a module:

    module App

    This is the beginning of the App module. In Julia, modules are used to organize code and isolate it. All the application code will be inside this module.

  2. Connecting the 'GenieFramework` library:

    using GenieFramework
    @genietools

    here:

    • `using GenieFramework': Connecting the library to work with web applications;

    • '@genietools': A macro that prepares the environment for the application, including the connection of necessary resources (such as icons and styles).

  3. Declaring a Reactive app:

    @app begin
        @in N = 0
        @out squared = 0

    here:

    • @app: The beginning of the application’s reactive code block;

    • @in N = 0: Declaring a reactive variable N that will store a custom value;

    • @out squared = 0: Declaration of the reactive variable squared, which will contain the square of the number. This variable is read-only.

  4. Reactive logic:

    @onchange N begin
            squared = N^2
    end

    here:

    • @onchange N: Indicates that when the value of the variable N is changed, the following code block is executed;

    • squared = N^2: Updating the value of the `squared' variable (squaring the entered number).

  5. Defining the user interface:

    function ui()
        [
            cell([
                p("Enter a number to calculate its square:")
            ]),
            cell([
                textfield("N", :N)
            ]),
            cell([
                bignumber("The square of the number is:", :squared)
            ])
        ]
    end

    here:

    • function ui(): Defines the function that creates the application interface;

    • cell([…​]): Packing interface elements into a structural block:

      • The first block cell([]): Displays the text with the instruction: "Enter a number to calculate its square";

      • Second block cell([]): Number input field (textfield("N", :N));

        • "N": Input field signature;

        • :N: The relation of the field to the variable N;

      • The third block is cell([])': Displaying the result (the square of the number) using 'bignumber;

        • "The square of the number is:": Caption;

        • :squared: Relationship to the squared variable.

  6. Creating a route and closing the module

    @page("/", ui)
    end

    here:

    • @page("/"): Defines the route for the main page of the application (/);

    • ui: Indicates that the page content will be generated by the ui function;

    • end: The end of the App module.

Next, save the application file app.jl with the changes made:

genie app 4 en

And run the application with the command:

engee.genie.start("/user/app.jl")

This application allows you to square the entered number, demonstrating how you can create your own applications right in the Engee workspace.

genie app 1

If the Engee session has been completed and the application remains open, the system will issue an error.:

genie app 5