设置spaceflights项目¶
本节展示如何使用Kedro spaceflights starter通过kedro new创建新项目,并安装项目依赖(使用pip install -r requirements.txt)。
创建新项目¶
设置Kedro 如果你还没有这样做。
重要
我们建议您使用与本教程最近测试时相同的Kedro版本(0.19.0)。要检查已安装的版本,请在终端窗口中输入kedro -V。
导航到您想要存储项目的文件夹。输入以下命令从Kedro spaceflights starter生成项目。该项目将填充一套完整的可运行示例代码:
kedro new --starter=spaceflights-pandas
当提示输入项目名称时,您应该接受默认选择(Spaceflights),因为本教程的其余部分都假定使用该项目名称。
在Kedro创建项目后,请导航至项目根目录:
cd spaceflights
安装项目依赖项¶
Kedro项目包含一个requirements.txt文件,用于指定项目依赖项,并通过确保Python包和版本的一致性来实现可共享的项目。
spaceflights项目的依赖项存储在requirements.txt中(您可能会发现具体版本号根据Kedro版本略有差异):
# code quality packages
ipython~=8.10; python_version >= '3.8'
ruff==0.1.8
# notebook tooling
jupyter~=1.0
jupyterlab_server>=2.11.1
jupyterlab~=3.0
# Pytest + useful extensions
pytest-cov~=3.0
pytest-mock>=1.7.1, <2.0
pytest~=7.2
# Kedro dependencies and datasets to work with different data formats (including CSV, Excel, and Parquet)
kedro~=0.19.0
kedro-datasets[pandas-csvdataset, pandas-exceldataset, pandas-parquetdataset]>=3.0
kedro-telemetry>=0.3.1
kedro-viz~=6.0 # Visualise pipelines
# For modeling in the data science pipeline
scikit-learn~=1.0
安装依赖项¶
要安装所有项目特定的依赖项,请从项目根目录运行以下命令:
pip install -r requirements.txt
可选:日志记录与配置¶
在这个工作流程阶段,您可能想要设置日志记录,但本教程中我们不会使用它。
如果项目使用的特定数据源需要用户名和密码等凭证,您可能还需要存储这些凭证。
为此,请将它们添加到conf/local/credentials.yml(该文件中包含了一些示例以供说明)。
避免泄露机密数据的最佳配置实践¶
不要将数据提交到版本控制中。
不要提交笔记本的输出单元格(如果不删除输出单元格,数据很容易混入笔记本中)。
不要在
conf/目录中提交凭证信息。对于访问凭证等敏感信息,请仅使用conf/local/文件夹。
您可以在配置文档中找到更多信息。