跳转到主要内容

Apache Spark和Scala的Jupyter元内核

项目描述

# spylon-kernel
[![构建状态](https://travis-ci.org/maxpoint/spylon-kernel.svg?branch=master)](https://travis-ci.org/maxpoint/spylon-kernel)
[![codecov](https://codecov.io/gh/maxpoint/spylon-kernel/branch/master/graph/badge.svg)](https://codecov.io/gh/maxpoint/spylon-kernel)

一个使用[metakernel](https://github.com/Calysto/metakernel)和[py4j](https://www.py4j.org/)结合的Scala [Jupyter内核](https://jupyter-docs.pythonlang.cn/en/latest/projects/kernels.html)。

## 先决条件

* 编译为Scala 2.11的Apache Spark 2.1.1
* Jupyter Notebook
* Python 3.5+

## 安装

您可以使用`pip`或`conda`安装spylon-kernel包。

```bash
pip install spylon-kernel
# 或
conda install -c conda-forge spylon-kernel
```

## 作为Scala内核使用

您可以将spylon-kernel用作Jupyter Notebook的Scala内核。当您想要
在Scala中使用一些Python代码混合工作时,请这样做。

通过运行以下命令创建Jupyter笔记本的内核规范

```bash
python -m spylon_kernel install
```

启动`jupyter notebook`,您应该在*新建*下拉菜单中看到`spylon-kernel`选项


查看[基本示例笔记本](./examples/basic_example.ipynb)获取信息
有关如何初始化一个Spark会话以及如何在Scala和Python中使用它的信息。

## 作为IPython魔法的使用

您还可以将spylon-kernel作为IPython笔记本中的一个魔法。当您
想将一点Scala混合到您的以Python为主的笔记本中时,这样做。

```python
from spylon_kernel import register_ipython_magics
register_ipython_magics()
```

```scala
%%scala
val x = 8
x
```

## 作为库的使用

最后,您可以将spylon-kernel作为Python库使用。当您
想在Python脚本或shell中评估一段Scala代码时,这样做。

```python
from spylon_kernel import get_scala_interpreter

interp = get_scala_interpreter()

# 评估Scala代码块的结果。
interp.interpret("""
val x = 8
x
""")

interp.last_result()
```

## 发布流程

推送一个标签并将源分发布送到PyPI。

```
git commit -m 'REL: 0.2.1' --allow-empty
git tag -a 0.2.1 # 并输入与提交相同的消息
git push origin master # 或发送一个PR

## 如果一切构建/测试干净,则发布到pypi
make release
```

然后更新 https://github.com/conda-forge/spylon-kernel-feedstock。

项目详情


下载文件

下载适用于您的平台文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

spylon-kernel-0.4.1.tar.gz (33.5 kB 查看哈希值)

上传时间

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面