一句话:DockerizeMe 通过 PyPI 离线知识与图推断自动补全 Python 代码片段依赖并生成 Docker 配置。
Stack Overflow、GitHub gist 等平台大量分享 Python 代码片段,但约 75% 无法直接执行,超过 50% 的公开 gist 在干净环境中因缺少库的 import 错误而失败。为此,作者提出 DockerizeMe,一种为 Python 代码片段推断执行所需依赖的技术。该方法首先从 Python Package Index(PyPI)离线获取流行包的资源与依赖知识,然后通过基于图的推断过程构建 Docker 规范,以解析代码中的导入并补全依赖。在 Gistable 数据集近 3000 个 gist 上评估,对于 Gistable 基线方法无法找到并安装全部依赖的样本,DockerizeMe 成功修复了其中 892 个的 import 错误。
Platforms like Stack Overflow and GitHub's gist system promote the sharing of ideas and programming techniques via the distribution of code snippets designed to illustrate particular tasks. Python, a popular and fast-growing programming language, sees heavy use on both sites, with nearly one million questions asked on Stack Overflow and 400 thousand public gists on GitHub. Unfortunately, around 75% of the Python example code shared through these sites cannot be directly executed. When run in a clean environment, over 50% of public Python gists fail due to an import error for a missing library. We present DockerizeMe, a technique for inferring the dependencies needed to execute a Python code snippet without import error. DockerizeMe starts with offline knowledge acquisition of the resources and dependencies for popular Python packages from the Python Package Index (PyPI). It then builds Docker specifications using a graph-based inference procedure. Our inference procedure resolves import errors in 892 out of nearly 3,000 gists from the Gistable dataset for which Gistable's baseline approach could not find and install all dependencies.