使实现ContentAI提取器更容易
contentaiextractor的Python项目详细描述
contentai extractor运行时python
这是一个python包,用于实现在ContentAI平台上运行的自定义提取器。在
https://pypi.org/project/contentaiextractor/
使用
pip install contentaiextractor^{pr2}$
API文档
ContentAIError Objects
^{pr 3}$represents a contentai error
Fields
- ^{
} - name of the extractor being run - ^{
} - current job id - ^{
} - URL of the content the extractor is run against - ^{
} - local path where the extractor can access the content - ^{
} - local path where the extractor should write the results - ^{
} - boolean set to ^{ }; useful for testing code locally - ^{
} - raw string (or ^{ } if not set) for active extractor run (also, see parsed metadata())
功能
下载_内容
download_content()
下载要在本地使用的内容
返回写入内容的本地路径
元数据
metadata()
返回包含输入元数据的dict
示例:
访问运行作业时提供的元数据
contentai run s3://bucket/video.mp4 -d '{ "input: "value" }'
input=contentai.metadata()["input"]
提取器
extractors()
获取针对此内容url执行的所有提取器的列表
返回字符串列表
["extractor1","extractor2"],
示例:
# get all data from all extractorsforextractorincontentai.extractors():forkeyincontentai.keys(extractor):data=contentai.get(extractor,key)
键
keys(extractor_name)
获取指定提取器的键列表
返回包含键列表的dict
["data.json","data.csv","data.txt,"]
示例:
keys=contentai.keys("azure_videoindexer")forkeyinkeys:data=contentai.get("azure_videoindexer",key)
获取
get(extractor_name,key)
获取特定密钥的内容
示例:
# get another extractor's outputdata=contentai.get("some_extractor","output.csv")
获取json
get_json(extractor_name,key)
获取特定键的json内容
示例:
# get another extractor's outputdata=contentai.get_json("some_extractor","data.json")
获取字节数
get_bytes(extractor_name,key)
获取以原始字节为单位的特定键的内容
示例:
# get another extractor's outputdata=contentai.get_bytes("some_extractor","output.bin")
设置
set(key,value)
设置此提取器的结果数据
可以用不同的键多次调用
值是字符串
示例:
^{pr21}$设置json
set_json(key,value)
设置此提取器的结果数据
可以用不同的键多次调用
价值可以是任何东西
示例:
data={}data["foo"]=barcontentai.set_json("output",data)
设置字节
set_bytes(key,value)
设置此提取器的结果数据
可以用不同的键多次调用
值为字节
示例:
some_file=open("some-file","rb")contentai.set_bytes("output",some_file.read())
保存结果
save_results()
立即保存结果,而不是等待进程退出
解析\u content\u url
parse_content_url()
从内容url提取详细信息
退货
source_bucket_name
-从content\u url派生的s3 bucket名称source_bucket_key
-从content\u url派生的s3 bucket密钥source_bucket_region
-从content\u url派生的s3 bucket区域
支持以下content url
格式:
- 简单(CLI)格式-
s3://{bucket}/{key}
- 虚拟托管格式-
https://{bucket}.s3.amazonaws.com/{key}
- 具有区域-
https://{bucket}.s3.{region}.amazonaws.com/{key}
的虚拟宿主格式
依赖关系
pip install -r requirements.txt
发展
Choose a make command to run
build build package
deploy upload package to pypi
docs generates api docs in markdown
释放
要向pypi发布新版本,请在setup.py
中增加版本号,标记提交并推送。在
变化
- 在
1.1.0款
- 添加
extractors()
- 添加
- 在
1.0.4款
- 更新的变更日志
- 在
1.0.3款
- {19>避免了问题
- 在
1.0.2款
- 为本地运行的设置检索添加安全性
- 文档更新
- 在
1.0.1款
- 发布到pypi的api文档
- 在
1.0.0款
- 初次发行
- 项目
标签: