Genie Discord forum

Author Avataryakir12
8/29/2023, 12:19:58 PM

I wrote a module, placed in the lib folder, and used by the controllers. In order to simplify it a bit, I cutout a part of its code to a separate .jl file, and left a include("file.jl") in the module. Now I get weird errors that seem to indicate that the included code in the file is evaluated before the code in the module...? I even tried Base.include(MyModule, "file.jl") but to no avail...

It's weird cause everything seems to actually work, except I get an error:

julia> using GenieFramework; Genie.loadapp(); up()

 ██████╗ ███████╗███╗   ██╗██╗███████╗    ███████╗
██╔════╝ ██╔════╝████╗  ██║██║██╔════╝    ██╔════╝
██║  ███╗█████╗  ██╔██╗ ██║██║█████╗      ███████╗
██║   ██║██╔══╝  ██║╚██╗██║██║██╔══╝      ╚════██║
╚██████╔╝███████╗██║ ╚████║██║███████╗    ███████║
 ╚═════╝ ╚══════╝╚═╝  ╚═══╝╚═╝╚══════╝    ╚══════╝

| Website
| GitHub
| Docs
| Discord
| Twitter

Active env: DEV

Loading libsERROR: UndefVarError: `SVector` not defined
 [1] top-level scope
   @ ~/new_projects/dancing queen/project/app/lib/detection.jl:1
in expression starting at /home/yakir/new_projects/dancing queen/project/app/lib/detection.jl:1
[ Info: 2023-08-29 14:09:23 Watching ["/home/yakir/new_projects/dancing queen/project/app"]


┌ Info: 2023-08-29 14:09:27 
└ Web Server starting at 
Genie.Server.ServersCollection(Task (runnable) @0x00007f8be6c7d780, nothing)

julia> [ Info: 2023-08-29 14:09:27 Listening on:, thread id: 3

and here are the first few lines in my module:

module Cameras

using Dates, LinearAlgebra
using Observables, AprilTags, StaticArrays
using VideoIO # remove

Base.include(Cameras, "detection.jl") # or include("detection.jl")

Note the using ... **StaticArrays** before the include("detection.jl")

Author AvatarPere
8/29/2023, 1:27:08 PM

Does it work if you manually include your app with include("app.jl")and start the server with up()?

Author AvatarPere
8/29/2023, 1:40:26 PM

Then this is be a conflict with Genie's automatic loading of files in the "/lib" folder

I usually include files manually , but it's true that with loadapp() the lib/ folder is automatically available and you can just do using .MyModule

Author Avataryakir12
8/29/2023, 1:43:15 PM

ok, I'll stick to include("app.jl") from now on then, and avoid loadapp

Author AvatarPere
8/29/2023, 1:50:12 PM

Best way would be to fix the imports in the module. loadapp enables features like logging and hot reloading which are pretty useful

Author Avataryakir12
8/29/2023, 2:02:25 PM

"fix the imports in the module" but how? The link only explains how to include a module into the app, which I'm already doing and it works. But I want to include a file with some code into a module that is already included into the app. and that doesn't work.

Author Avataryakir12
8/30/2023, 7:23:40 AM

Forgive me, I reread my response here and it comes through as quite harsh. It was unintended, sorry.

Author Avataryakir12
8/30/2023, 7:26:43 AM

Following is an illustration of what I mean:

├── app.jl
├── controllers
│   └── ...
├── lib
│   ├── MyModule.jl
│   └── file.jl
├── Manifest.toml
├── pages
│   └── ...
└── Project.toml

and in MyModule.jl I have:

module MyModule

and file.jl is just:

fun(x) = 2x
Author AvatarPere
9/4/2023, 1:20:13 PM

That's okay @yakir12 🙂

There's an autoloadfunction that can be set to watch files in a folder with Revise.jl. This is automatically set for lib/. I suppose this is a Reviselimitation, as code imported via a standard includecannot be hot reloaded

Another possiblity is that this is due to the order in which the modules are loaded. It is possible to change this order, so that you could load first the .jl file and then the module

Author Avataryakir12
9/5/2023, 1:34:14 PM

Awesome! From your link I learned about .autoload_ignore, so I just plumped a .autoload_ignore file in the lib folder and now

julia> using GenieFramework; Genie.loadapp(); up()

just works! Thank you.