R/DSJobModel.r

# Dkube api server
#
# No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
#
# OpenAPI spec version: 2.2.1.11
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' DSJobModel Class
#'
#' @field executor 
#' @field datums 
#' @field featuresets 
#' @field tags 
#' @field hptuning 
#' @field hyperparams 
#' @field nworkers 
#' @field ngpus 
#' @field rdma 
#' @field gpus_override 
#' @field view 
#' @field cluster 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
DSJobModel <- R6::R6Class(
  'DSJobModel',
  public = list(
    `executor` = NULL,
    `datums` = NULL,
    `featuresets` = NULL,
    `tags` = NULL,
    `hptuning` = NULL,
    `hyperparams` = NULL,
    `nworkers` = NULL,
    `ngpus` = NULL,
    `rdma` = NULL,
    `gpus_override` = NULL,
    `view` = NULL,
    `cluster` = NULL,
    initialize = function(`executor`, `datums`, `featuresets`, `tags`, `hptuning`, `hyperparams`, `nworkers`, `ngpus`, `rdma`, `gpus_override`, `view`, `cluster`){
      if (!missing(`executor`)) {
        stopifnot(R6::is.R6(`executor`))
        self$`executor` <- `executor`
      }
      if (!missing(`datums`)) {
        stopifnot(R6::is.R6(`datums`))
        self$`datums` <- `datums`
      }
      if (!missing(`featuresets`)) {
        stopifnot(R6::is.R6(`featuresets`))
        self$`featuresets` <- `featuresets`
      }
      if (!missing(`tags`)) {
        stopifnot(is.list(`tags`), length(`tags`) != 0)
        lapply(`tags`, function(x) stopifnot(is.character(x)))
        self$`tags` <- `tags`
      }
      if (!missing(`hptuning`)) {
        stopifnot(R6::is.R6(`hptuning`))
        self$`hptuning` <- `hptuning`
      }
      if (!missing(`hyperparams`)) {
        stopifnot(R6::is.R6(`hyperparams`))
        self$`hyperparams` <- `hyperparams`
      }
      if (!missing(`nworkers`)) {
        stopifnot(is.numeric(`nworkers`), length(`nworkers`) == 1)
        self$`nworkers` <- `nworkers`
      }
      if (!missing(`ngpus`)) {
        stopifnot(is.numeric(`ngpus`), length(`ngpus`) == 1)
        self$`ngpus` <- `ngpus`
      }
      if (!missing(`rdma`)) {
        self$`rdma` <- `rdma`
      }
      if (!missing(`gpus_override`)) {
        self$`gpus_override` <- `gpus_override`
      }
      if (!missing(`view`)) {
        stopifnot(R6::is.R6(`view`))
        self$`view` <- `view`
      }
      if (!missing(`cluster`)) {
        stopifnot(R6::is.R6(`cluster`))
        self$`cluster` <- `cluster`
      }
    },
    toJSON = function() {
      DSJobModelObject <- list()
      if (!is.null(self$`executor`)) {
        DSJobModelObject[['executor']] <- self$`executor`$toJSON()
      }
      if (!is.null(self$`datums`)) {
        DSJobModelObject[['datums']] <- self$`datums`$toJSON()
      }
      if (!is.null(self$`featuresets`)) {
        DSJobModelObject[['featuresets']] <- self$`featuresets`$toJSON()
      }
      if (!is.null(self$`tags`)) {
        DSJobModelObject[['tags']] <- self$`tags`
      }
      if (!is.null(self$`hptuning`)) {
        DSJobModelObject[['hptuning']] <- self$`hptuning`$toJSON()
      }
      if (!is.null(self$`hyperparams`)) {
        DSJobModelObject[['hyperparams']] <- self$`hyperparams`$toJSON()
      }
      if (!is.null(self$`nworkers`)) {
        DSJobModelObject[['nworkers']] <- self$`nworkers`
      }
      if (!is.null(self$`ngpus`)) {
        DSJobModelObject[['ngpus']] <- self$`ngpus`
      }
      if (!is.null(self$`rdma`)) {
        DSJobModelObject[['rdma']] <- self$`rdma`
      }
      if (!is.null(self$`gpus_override`)) {
        DSJobModelObject[['gpus_override']] <- self$`gpus_override`
      }
      if (!is.null(self$`view`)) {
        DSJobModelObject[['view']] <- self$`view`$toJSON()
      }
      if (!is.null(self$`cluster`)) {
        DSJobModelObject[['cluster']] <- self$`cluster`$toJSON()
      }

      DSJobModelObject
    },
    fromJSON = function(DSJobModelJson) {
      DSJobModelObject <- jsonlite::fromJSON(DSJobModelJson)
      if (!is.null(DSJobModelObject$`executor`)) {
        executorObject <- DSJobModelExecutor$new()
        executorObject$fromJSON(jsonlite::toJSON(DSJobModelObject$executor, auto_unbox = TRUE))
        self$`executor` <- executorObject
      }
      if (!is.null(DSJobModelObject$`datums`)) {
        datumsObject <- JobDatumModel$new()
        datumsObject$fromJSON(jsonlite::toJSON(DSJobModelObject$datums, auto_unbox = TRUE))
        self$`datums` <- datumsObject
      }
      if (!is.null(DSJobModelObject$`featuresets`)) {
        featuresetsObject <- JobFeaturesetModel$new()
        featuresetsObject$fromJSON(jsonlite::toJSON(DSJobModelObject$featuresets, auto_unbox = TRUE))
        self$`featuresets` <- featuresetsObject
      }
      if (!is.null(DSJobModelObject$`tags`)) {
        self$`tags` <- DSJobModelObject$`tags`
      }
      if (!is.null(DSJobModelObject$`hptuning`)) {
        hptuningObject <- DSJobModelHptuning$new()
        hptuningObject$fromJSON(jsonlite::toJSON(DSJobModelObject$hptuning, auto_unbox = TRUE))
        self$`hptuning` <- hptuningObject
      }
      if (!is.null(DSJobModelObject$`hyperparams`)) {
        hyperparamsObject <- DSJobModelHyperparams$new()
        hyperparamsObject$fromJSON(jsonlite::toJSON(DSJobModelObject$hyperparams, auto_unbox = TRUE))
        self$`hyperparams` <- hyperparamsObject
      }
      if (!is.null(DSJobModelObject$`nworkers`)) {
        self$`nworkers` <- DSJobModelObject$`nworkers`
      }
      if (!is.null(DSJobModelObject$`ngpus`)) {
        self$`ngpus` <- DSJobModelObject$`ngpus`
      }
      if (!is.null(DSJobModelObject$`rdma`)) {
        self$`rdma` <- DSJobModelObject$`rdma`
      }
      if (!is.null(DSJobModelObject$`gpus_override`)) {
        self$`gpus_override` <- DSJobModelObject$`gpus_override`
      }
      if (!is.null(DSJobModelObject$`view`)) {
        viewObject <- DSJobModelView$new()
        viewObject$fromJSON(jsonlite::toJSON(DSJobModelObject$view, auto_unbox = TRUE))
        self$`view` <- viewObject
      }
      if (!is.null(DSJobModelObject$`cluster`)) {
        clusterObject <- JobClusterModel$new()
        clusterObject$fromJSON(jsonlite::toJSON(DSJobModelObject$cluster, auto_unbox = TRUE))
        self$`cluster` <- clusterObject
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "executor": %s,
           "datums": %s,
           "featuresets": %s,
           "tags": [%s],
           "hptuning": %s,
           "hyperparams": %s,
           "nworkers": %d,
           "ngpus": %d,
           "rdma": %s,
           "gpus_override": %s,
           "view": %s,
           "cluster": %s
        }',
        self$`executor`$toJSON(),
        self$`datums`$toJSON(),
        self$`featuresets`$toJSON(),
        lapply(self$`tags`, function(x) paste(paste0('"', x, '"'), sep=",")),
        self$`hptuning`$toJSON(),
        self$`hyperparams`$toJSON(),
        self$`nworkers`,
        self$`ngpus`,
        self$`rdma`,
        self$`gpus_override`,
        self$`view`$toJSON(),
        self$`cluster`$toJSON()
      )
    },
    fromJSONString = function(DSJobModelJson) {
      DSJobModelObject <- jsonlite::fromJSON(DSJobModelJson)
      DSJobModelExecutorObject <- DSJobModelExecutor$new()
      self$`executor` <- DSJobModelExecutorObject$fromJSON(jsonlite::toJSON(DSJobModelObject$executor, auto_unbox = TRUE))
      JobDatumModelObject <- JobDatumModel$new()
      self$`datums` <- JobDatumModelObject$fromJSON(jsonlite::toJSON(DSJobModelObject$datums, auto_unbox = TRUE))
      JobFeaturesetModelObject <- JobFeaturesetModel$new()
      self$`featuresets` <- JobFeaturesetModelObject$fromJSON(jsonlite::toJSON(DSJobModelObject$featuresets, auto_unbox = TRUE))
      self$`tags` <- DSJobModelObject$`tags`
      DSJobModelHptuningObject <- DSJobModelHptuning$new()
      self$`hptuning` <- DSJobModelHptuningObject$fromJSON(jsonlite::toJSON(DSJobModelObject$hptuning, auto_unbox = TRUE))
      DSJobModelHyperparamsObject <- DSJobModelHyperparams$new()
      self$`hyperparams` <- DSJobModelHyperparamsObject$fromJSON(jsonlite::toJSON(DSJobModelObject$hyperparams, auto_unbox = TRUE))
      self$`nworkers` <- DSJobModelObject$`nworkers`
      self$`ngpus` <- DSJobModelObject$`ngpus`
      self$`rdma` <- DSJobModelObject$`rdma`
      self$`gpus_override` <- DSJobModelObject$`gpus_override`
      DSJobModelViewObject <- DSJobModelView$new()
      self$`view` <- DSJobModelViewObject$fromJSON(jsonlite::toJSON(DSJobModelObject$view, auto_unbox = TRUE))
      JobClusterModelObject <- JobClusterModel$new()
      self$`cluster` <- JobClusterModelObject$fromJSON(jsonlite::toJSON(DSJobModelObject$cluster, auto_unbox = TRUE))
    }
  )
)
riteshkarvaloc/dkubeR documentation built on Feb. 25, 2021, 9:28 p.m.