Git Product home page Git Product logo

Comments (3)

rolfsimoes avatar rolfsimoes commented on August 9, 2024

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 jobs endpoint response.

# 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 (plumber.R) could be:

#* @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:

  • job_save_result()
  • job_api()
  • job_save()
  • job_read()
  • job_delete()
  • job_create()
  • job_api_params()
  • job_start()
  • job_info()

This issue depends on #18 to be able to define workspace.

from openeocraft.

rolfsimoes avatar rolfsimoes commented on August 9, 2024

image

from openeocraft.

PondiB avatar PondiB commented on August 9, 2024

Possible new functions:

  • job_save_result()
  • job_api()
  • job_save()
  • job_read()
  • job_delete()
  • job_create()
  • job_api_params()
  • job_start()
  • job_info()
  • job_update()
  • job_get_results()
  • jobs_list_all()

from openeocraft.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.