-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement API support to /jobs
endpoint
#26
Comments
Jobs must be run in new R process. We can start a new process using the package callr. The package provides basic functionality to interact with R process and can be used to build some dynamic fields of # Get all needed parameter to create a new API object
params <- api_params(api)
# params content:
# list(id = ..., title, description, backend_version, api_version, processes_file, collections)
# Create a new api object based on input parameters (to be run in **new process** side):
api <- api_from_params(params)
# This should be an openeocraft function
api_new_job <- function(api, req, res) {
user <- user_session(req)
p <- req$body
if ("process" %in% names(p))
p <- p$process
job <- job_create(api, p, user)
job_save(job) # user is a variable that identifies the current user
return(job)
} # Possible implementation of `job_start()`
job_start <- function(job) {
callr::r(function() {
api <- job_api(job)
p <- job_pgraph(job)
result <- run_pgraph(api, p)
job_save_result(job, result) # user workspace
})
}
The endpoint implementation ( #* @post /jobs
function(req, res) {
job <- api_new_job(api, req, res)
job_start(job)
return(job_info(job))
}
#* @get /jobs/<job_id>
function(req, res, job_id) {
job <- job_read(api, res, req, job_id)
return(job_info(job))
}
#* @delete /jobs/<job_id>
function(req, res, job_id) {
job <- job_delete(api, res, req, job_id) # inside job_delete: user <- user_session(req)
return(job_info(job))
}
Possible new functions:
This issue depends on #18 to be able to define workspace. |
|
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Links to #21, #18
Implement
api_jobs()
function to support/jobs
endpoint.Please, see OpenEO documentation on jobs endpoint.
The text was updated successfully, but these errors were encountered: