Hail 0.2Hail 0.2
La grêle est une bibliothèque basée sur Apache Spark pour l’analyse de jeux de données génomique volumineux.Hail is a library built on Apache Spark for analyzing large genomic datasets.
Créer un cluster HailCreate a Hail cluster
Vous pouvez installer la fonction de grêle avec un script init.You can install Hail with an init script.
Créez le répertoire de base dans lequel vous souhaitez placer le script init.Create the base directory in which you want to put the init script. L'exemple suivant utilise
dbfs:/databricks/scripts
.The following example usesdbfs:/databricks/scripts
.Enregistrez le script init à l’aide de cet extrait de code :Save the init script using this snippet:
dbutils.fs.put( '/databricks/scripts/install-hail.sh', ''' #!/bin/bash set -ex # Pick up user-provided environment variables, specifically HAIL_VERSION source /databricks/spark/conf/spark-env.sh /databricks/python/bin/pip install -U hail==$HAIL_VERSION hail_jar_path=$(find /databricks/python3 -name 'hail-all-spark.jar') cp $hail_jar_path /databricks/jars # Note: This configuration takes precedence since configurations are # applied in reverse-lexicographic order. cat <<HERE >/databricks/driver/conf/00-hail.conf [driver] { "spark.kryo.registrator" = "is.hail.kryo.HailKryoRegistrator" "spark.serializer" = "org.apache.spark.serializer.KryoSerializer" } HERE echo $? ''', overwrite = True )
Créez un cluster avec Databricks Runtime 6,4, le script initet une variable d’environnement pour indiquer la version de l’arraisonnement :Create a cluster with Databricks Runtime 6.4, the init script, and an environment variable to indicate the Hail version:
HAIL_VERSION=0.2.61
Utiliser Hail dans un notebookUse Hail in a notebook
Dans la plupart des cas, le code de grêle 0,2 dans Azure Databricks fonctionne de la même façon que la documentation de la grêle.For the most part, Hail 0.2 code in Azure Databricks works identically to the Hail documentation. Toutefois, certaines modifications sont nécessaires pour l’environnement de Azure Databricks.However, there are a few modifications that are necessary for the Azure Databricks environment.
Initialiser la grêleInitialize Hail
Lors de l’initialisation de la grêle, transmettez le créé au préalable SparkContext
et marquez l’initialisation comme idempotent.When initializing Hail, pass in the pre-created SparkContext
and mark the initialization as idempotent. Ce paramètre permet à plusieurs blocs-notes Azure Databricks d’utiliser le même contexte de grêle.This setting enables multiple Azure Databricks notebooks to use the same Hail context.
Notes
Permet skip_logging_configuration
à d’enregistrer les journaux dans la sortie log4j du pilote enchaîné.Enable skip_logging_configuration
to save logs to the rolling driver log4j output. Ce paramètre est pris en charge uniquement dans les 0.2.39 de la grêle et versions ultérieures.This setting is supported only in Hail 0.2.39 and above.
import hail as hl
hl.init(sc, idempotent=True, quiet=True, skip_logging_configuration=True)
Afficher les tracés bokehDisplay Bokeh plots
La grêle utilise la bibliothèque bokeh pour créer des tracés.Hail uses the Bokeh library to create plots. La show
fonction intégrée à bokeh ne fonctionne pas dans Azure Databricks.The show
function built into Bokeh does not work in Azure Databricks. Pour afficher un tracé bokeh généré par la grêle, vous pouvez exécuter une commande comme :To display a Bokeh plot generated by Hail, you can run a command like:
from bokeh.embed import components, file_html
from bokeh.resources import CDN
plot = hl.plot.histogram(mt.DP, range=(0,30), bins=30, title='DP Histogram', legend='DP')
html = file_html(plot, CDN, "Chart")
displayHTML(html)
Pour plus d’informations, consultez bokeh .See Bokeh for more information.