spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From junyangq <...@git.apache.org>
Subject [GitHub] spark pull request #14258: [Spark-16579][SparkR] add install_spark function
Date Thu, 21 Jul 2016 18:28:27 GMT
Github user junyangq commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14258#discussion_r71760571
  
    --- Diff: R/pkg/R/install.R ---
    @@ -0,0 +1,160 @@
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#    http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +
    +# Functions to install Spark in case the user directly downloads SparkR
    +# from CRAN.
    +
    +#' Download and Install Spark Core to Local Directory
    +#' 
    +#' \code{install_spark} downloads and installs Spark to local directory if
    +#' it is not found. The Spark version we use is 2.0.0 (preview). Users can
    +#' specify a desired Hadoop version, the remote site, and the directory where
    +#' the package is installed locally.
    +#'
    +#' @param hadoop_version Version of Hadoop to install, 2.4, 2.6,
    +#'        2.7 (default) and without
    +#' @param mirror_url the base URL of the repositories to use
    +#' @param local_dir local directory that Spark is installed to
    +#' @return \code{install_spark} returns the local directory 
    +#'         where Spark is found or installed
    +#' @rdname install_spark
    +#' @name install_spark
    +#' @export
    +#' @examples
    +#'\dontrun{
    +#' install_spark()
    +#'}
    +#' @note install_spark since 2.1.0
    +install_spark <- function(hadoop_version = NULL, mirror_url = NULL,
    +                          local_dir = NULL) {
    +  version <- paste0("spark-", spark_version_default())
    +  hadoop_version <- match.arg(hadoop_version, supported_versions_hadoop())
    +  packageName <- ifelse(hadoop_version == "without",
    +                        paste0(version, "-bin-without-hadoop"),
    +                        paste0(version, "-bin-hadoop", hadoop_version))
    +  if (is.null(local_dir)) {
    +    local_dir <- getOption("spark.install.dir", spark_cache_path())
    +  } else {
    +    local_dir <- normalizePath(local_dir)
    +  }
    +
    +  packageLocalDir <- file.path(local_dir, packageName)
    +
    +  if (dir.exists(packageLocalDir)) {
    +    fmt <- "Spark %s for Hadoop %s has been installed."
    +    msg <- sprintf(fmt, version, hadoop_version)
    +    message(msg)
    +    return(invisible(packageLocalDir))
    +  }
    +
    +  packageLocalPath <- paste0(packageLocalDir, ".tgz")
    +  tarExists <- file.exists(packageLocalPath)
    +
    +  if (tarExists) {
    +    message("Tar file found. Installing...")
    +  } else {
    +    dir.create(packageLocalDir, recursive = TRUE)
    +    if (is.null(mirror_url)) {
    +      message("Remote URL not provided. Use Apache default.")
    +      mirror_url <- mirror_url_default()
    +    }
    +    # This is temporary, should be removed when released
    +    version <- "spark-releases/spark-2.0.0-rc4-bin"
    --- End diff --
    
    We did this temporarily only because the current `sparkR.session()` uses some methods
that are not in the 2.0 preview version available from apache website, and so we try to download
the rc4 version instead. We have to hardcoded some part of the url since it has different
pattern from those for other versions.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message