python包用户的常见任务(例如复制示例、获取数据等)
pyct的Python项目详细描述
Pyct
一个实用程序包,包括:
pyct.cmd:使其他命令可用 包装。(目前没有成熟的插件系统,只是一个尝试 导入/在其他包中除外。)相同的命令是 可从python中获得。可以将新子命令添加到 如果模块具有现有的,则存在现有的基于ARGARSE的命令 命令,如果模块没有 现有命令。目前,有用于复制的命令 示例和获取数据。请参见
pyct.build:提供各种命令来帮助打包 建筑,主要是为了方便项目维护人员。
pyct.cmd
使用pyct.cmd所需的依赖项安装pyct:pip install pyct[cmd]
或conda install -c pyviz pyct
。
如何在项目中使用的示例: https://github.com/ioam/geoviews/blob/master/geoviews/__main__.py
添加后,用户可以复制包的示例并下载
使用examples
命令需要的数据:
$ datashader examples --help
usage: datashader examples [-h] [--path PATH] [-v] [--force] [--use-test-data]
optional arguments:
-h, --help show this help message and exit
--path PATH location to place examples and data
-v, --verbose
--force if PATH already exists, force overwrite existing examples
if older than source examples. ALSO force any existing data
files to be replaced
--use-test-data Use data's test files, if any, instead of fetching full
data. If test file not in '.data_stubs', fall back to
fetching full data.
要复制示例,例如datashader,但不下载数据,
有一个copy-examples
命令:
usage: datashader copy-examples [-h] [--path PATH] [-v] [--force]
optional arguments:
-h, --help show this help message and exit
--path PATH where to copy examples
-v, --verbose
--force if PATH already exists, force overwrite existing files if
older than source files
要仅下载数据,请使用fetch-data
命令:
usage: datashader fetch-data [-h] [--path PATH] [--datasets DATASETS] [-v]
[--force] [--use-test-data]
optional arguments:
-h, --help show this help message and exit
--path PATH where to put data
--datasets DATASETS *name* of datasets file; must exist either in path
specified by --path or in package/examples/
-v, --verbose
--force Force any existing data files to be replaced
--use-test-data Use data's test files, if any, instead of fetching full
data. If test file not in '.data_stubs', fall back to
fetching full data.
可以指定不同的“数据集”文件:
$ cat earthsim-examples/test.yml
---
data:
- url: http://s3.amazonaws.com/datashader-data/Chesapeake_and_Delaware_Bays.zip
title: 'Depth data for the Chesapeake and Delaware Bay region of the USA'
files:
- Chesapeake_and_Delaware_Bays.3dm
$ earthsim fetch-data --path earthsim-examples --datasets-filename test.yml
Downloading data defined in /tmp/earthsim-examples/test.yml to /tmp/earthsim-examples/data
Skipping Depth data for the Chesapeake and Delaware Bay region of the USA
通过使用--use-test-data
标志,可以使用较小的文件而不是较大的文件
在examples/data/.data_stubs
:
$ tree examples/data -a
examples/data
├── .data_stubs
│ └── nyc_taxi_wide.parq
└── diamonds.csv
$ cat examples/dataset.yml
data:
- url: http://s3.amazonaws.com/datashader-data/nyc_taxi_wide.parq
title: 'NYC Taxi Data'
files:
- nyc_taxi_wide.parq
- url: http://s3.amazonaws.com/datashader-data/maccdc2012_graph.zip
title: 'National CyberWatch Mid-Atlantic Collegiate Cyber Defense Competition'
files:
- maccdc2012_nodes.parq
- maccdc2012_edges.parq
- maccdc2012_full_nodes.parq
- maccdc2012_full_edges.parq
$ pyviz fetch-data --path=examples --use-test-data
Fetching data defined in /tmp/pyviz/examples/datasets.yml and placing in /tmp/pyviz/examples/data
Copying test data file '/tmp/pyviz/examples/data/.data_stubs/nyc_taxi_wide.parq' to '/tmp/pyviz/examples/data/nyc_taxi_wide.parq'
No test file found for: /tmp/pyviz/examples/data/.data_stubs/maccdc2012_nodes.parq. Using regular file instead
Downloading National CyberWatch Mid-Atlantic Collegiate Cyber Defense Competition 1 of 1
[################################] 59/59 - 00:00:00
要清除任何伪装成真实数据的潜在测试文件,请使用clean-data
:
usage: pyviz clean-data [-h] [--path PATH]
optional arguments:
-h, --help show this help message and exit
--path PATH where to clean data
pyct.build
当前提供了一种将示例与项目打包的方法,方法是 每当 setup.py已运行。这种工作方式在不久的将来可能会改变 未来,但这是我们迈向未来的第一步 统一/简化一些PYVIZ项目的维护。