I’m seeking assistance for an issue I encountered while developing scripts for Darktable. Specifically, I’m facing an error with the darktable.gui.create_job function that I can’t seem to figure out.
local dt = require "darktable"
local obj = {"Value 1", "Value 2", "Value 3"}
local do_job = function(obj)
-- Add debugging output to indicate the start of the function
dt.print_error("Starting do_job function")
local job = dt.gui.create_job {
"Do something", -- String
}
-- Add debugging output to indicate the start of the job
dt.print_error("Job created, beginning processing of objects...")
for _, value in ipairs(obj) do
-- Add debugging output to indicate the current value
dt.print_error("Current value:", value)
end
-- Add debugging output to indicate the end of the function
dt.print_error("End of do_job function")
job = nil
end
-- Test the do_job function
do_job(obj)
--[[ output:
2.4613 LUA ERROR Starting do_job function
2.4614 LUA ERROR: dtutils.lua: prequire: 224: Error loading myscripts/dp_lua_test
2.4614 LUA ERROR: dtutils.lua: prequire: 225: Error returned is /home/yves/.config/darktable/lua/myscripts/dp_lua_test.lua:9: bad argument #1 to 'create_job' (string expected, got table)
2.4615 LUA ERROR: script_manager.lua: activate: 408: Error loading myscripts/dp_lua_test
2.4615 LUA ERROR: script_manager.lua: activate: 409: Error message: /home/yves/.config/darktable/lua/myscripts/dp_lua_test.lua:9: bad argument #1 to 'create_job' (string expected, got table)
]]
The error occurs when calling the darktable.gui.create_job function, indicating that a table is being passed instead of a string. However, I’ve verified that I’m explicitly passing a string.
Interestingly, the code is derived from a working script that also uses the darktable.gui.create_job function:
What affects there? I have no idea. I use Darktable 4.6.1 on Ubuntu 22.04
I would appreciate any assistance or guidance on resolving this issue and successfully running my script.
jobs are used to provide user feedback that something is happening. Let’s say that you process 10 images in a loop and the whole process takes .1 sec. To the user it takes no time at all. Now let’s say it’s 1000 images and it takes 10 seconds. The use sits there wondering what is happening. If I wrap that loop in a job and move the slider every 100 images then the user understands that something is happening and they can track the progress.
Thank you. So a pure GUI element. Then I will try to make the process secure by watching darktable.control.ending so that my log will be written at the end as well.
Maybe I’m doing something wrong, but for me, the output of darktable -d lua is so long that I can’t find anything without using grep.