clarifai 9.7.1__py3-none-any.whl → 9.7.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- clarifai/auth/__init__.py +6 -0
- clarifai/auth/helper.py +35 -36
- clarifai/auth/register.py +23 -0
- clarifai/{client → auth}/stub.py +10 -10
- clarifai/client/__init__.py +1 -4
- clarifai/client/app.py +483 -0
- clarifai/client/auth/__init__.py +4 -0
- clarifai/client/{abc.py → auth/abc.py} +2 -2
- clarifai/client/auth/helper.py +377 -0
- clarifai/client/auth/register.py +23 -0
- {clarifai_utils/client → clarifai/client/auth}/stub.py +10 -10
- clarifai/client/base.py +112 -0
- clarifai/client/dataset.py +290 -0
- clarifai/client/input.py +730 -0
- clarifai/client/lister.py +41 -0
- clarifai/client/model.py +218 -0
- clarifai/client/module.py +82 -0
- clarifai/client/user.py +125 -0
- clarifai/client/workflow.py +194 -0
- clarifai/datasets/upload/base.py +66 -0
- clarifai/datasets/upload/examples/README.md +31 -0
- clarifai/datasets/upload/examples/image_classification/cifar10/dataset.py +42 -0
- clarifai/datasets/upload/examples/image_classification/food-101/dataset.py +39 -0
- clarifai/datasets/upload/examples/text_classification/imdb_dataset/dataset.py +37 -0
- clarifai/{data_upload/datasets → datasets/upload}/features.py +4 -12
- clarifai/datasets/upload/image.py +156 -0
- clarifai/datasets/upload/loaders/README.md +49 -0
- clarifai/{data_upload/datasets/zoo → datasets/upload/loaders}/coco_captions.py +24 -21
- {clarifai_utils/data_upload/datasets/zoo → clarifai/datasets/upload/loaders}/coco_detection.py +46 -42
- clarifai/datasets/upload/loaders/coco_segmentation.py +166 -0
- clarifai/{data_upload/datasets/zoo → datasets/upload/loaders}/imagenet_classification.py +22 -12
- clarifai/{data_upload/datasets/zoo → datasets/upload/loaders}/xview_detection.py +44 -53
- clarifai/datasets/upload/text.py +50 -0
- clarifai/datasets/upload/utils.py +62 -0
- clarifai/errors.py +90 -0
- clarifai/urls/helper.py +16 -17
- clarifai/utils/logging.py +40 -0
- clarifai/utils/misc.py +33 -0
- clarifai/versions.py +6 -0
- {clarifai-9.7.1.dist-info → clarifai-9.7.2.dist-info}/LICENSE +1 -1
- clarifai-9.7.2.dist-info/METADATA +179 -0
- clarifai-9.7.2.dist-info/RECORD +350 -0
- clarifai_utils/auth/__init__.py +6 -0
- clarifai_utils/auth/helper.py +35 -36
- clarifai_utils/auth/register.py +23 -0
- clarifai_utils/auth/stub.py +127 -0
- clarifai_utils/client/__init__.py +1 -4
- clarifai_utils/client/app.py +483 -0
- clarifai_utils/client/auth/__init__.py +4 -0
- clarifai_utils/client/{abc.py → auth/abc.py} +2 -2
- clarifai_utils/client/auth/helper.py +377 -0
- clarifai_utils/client/auth/register.py +23 -0
- clarifai_utils/client/auth/stub.py +127 -0
- clarifai_utils/client/base.py +112 -0
- clarifai_utils/client/dataset.py +290 -0
- clarifai_utils/client/input.py +730 -0
- clarifai_utils/client/lister.py +41 -0
- clarifai_utils/client/model.py +218 -0
- clarifai_utils/client/module.py +82 -0
- clarifai_utils/client/user.py +125 -0
- clarifai_utils/client/workflow.py +194 -0
- clarifai_utils/datasets/upload/base.py +66 -0
- clarifai_utils/datasets/upload/examples/README.md +31 -0
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/dataset.py +42 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/dataset.py +39 -0
- clarifai_utils/datasets/upload/examples/text_classification/imdb_dataset/dataset.py +37 -0
- clarifai_utils/{data_upload/datasets → datasets/upload}/features.py +4 -12
- clarifai_utils/datasets/upload/image.py +156 -0
- clarifai_utils/datasets/upload/loaders/README.md +49 -0
- clarifai_utils/{data_upload/datasets/zoo → datasets/upload/loaders}/coco_captions.py +24 -21
- {clarifai/data_upload/datasets/zoo → clarifai_utils/datasets/upload/loaders}/coco_detection.py +46 -42
- clarifai_utils/datasets/upload/loaders/coco_segmentation.py +166 -0
- clarifai_utils/{data_upload/datasets/zoo → datasets/upload/loaders}/imagenet_classification.py +22 -12
- clarifai_utils/{data_upload/datasets/zoo → datasets/upload/loaders}/xview_detection.py +44 -53
- clarifai_utils/datasets/upload/text.py +50 -0
- clarifai_utils/datasets/upload/utils.py +62 -0
- clarifai_utils/errors.py +90 -0
- clarifai_utils/urls/helper.py +16 -17
- clarifai_utils/utils/logging.py +40 -0
- clarifai_utils/utils/misc.py +33 -0
- clarifai_utils/versions.py +6 -0
- clarifai/data_upload/README.md +0 -63
- clarifai/data_upload/convert_csv.py +0 -182
- clarifai/data_upload/datasets/base.py +0 -87
- clarifai/data_upload/datasets/image.py +0 -253
- clarifai/data_upload/datasets/text.py +0 -60
- clarifai/data_upload/datasets/zoo/README.md +0 -55
- clarifai/data_upload/datasets/zoo/coco_segmentation.py +0 -160
- clarifai/data_upload/examples/README.md +0 -5
- clarifai/data_upload/examples/image_classification/cifar10/dataset.py +0 -40
- clarifai/data_upload/examples/image_classification/food-101/dataset.py +0 -39
- clarifai/data_upload/examples/image_classification/food-101/images/beignets/1036242.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/beignets/1114182.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/beignets/2012944.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/beignets/2464389.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/beignets/478632.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/hamburger/1061270.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/hamburger/1202261.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/hamburger/1381751.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/hamburger/3289634.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/hamburger/862025.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/prime_rib/102197.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/prime_rib/2749372.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/prime_rib/2938268.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/prime_rib/3590861.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/prime_rib/746716.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/ramen/2955110.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/ramen/3208966.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/ramen/3270629.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/ramen/3424562.jpg +0 -0
- clarifai/data_upload/examples/image_classification/food-101/images/ramen/544680.jpg +0 -0
- clarifai/data_upload/examples/image_detection/voc/annotations/2007_000464.xml +0 -39
- clarifai/data_upload/examples/image_detection/voc/annotations/2008_000853.xml +0 -28
- clarifai/data_upload/examples/image_detection/voc/annotations/2008_003182.xml +0 -54
- clarifai/data_upload/examples/image_detection/voc/annotations/2008_008526.xml +0 -67
- clarifai/data_upload/examples/image_detection/voc/annotations/2009_004315.xml +0 -28
- clarifai/data_upload/examples/image_detection/voc/annotations/2009_004382.xml +0 -28
- clarifai/data_upload/examples/image_detection/voc/annotations/2011_000430.xml +0 -28
- clarifai/data_upload/examples/image_detection/voc/annotations/2011_001610.xml +0 -46
- clarifai/data_upload/examples/image_detection/voc/annotations/2011_006412.xml +0 -99
- clarifai/data_upload/examples/image_detection/voc/annotations/2012_000690.xml +0 -43
- clarifai/data_upload/examples/image_detection/voc/dataset.py +0 -76
- clarifai/data_upload/examples/image_detection/voc/images/2007_000464.jpg +0 -0
- clarifai/data_upload/examples/image_detection/voc/images/2008_000853.jpg +0 -0
- clarifai/data_upload/examples/image_detection/voc/images/2008_003182.jpg +0 -0
- clarifai/data_upload/examples/image_detection/voc/images/2008_008526.jpg +0 -0
- clarifai/data_upload/examples/image_detection/voc/images/2009_004315.jpg +0 -0
- clarifai/data_upload/examples/image_detection/voc/images/2009_004382.jpg +0 -0
- clarifai/data_upload/examples/image_detection/voc/images/2011_000430.jpg +0 -0
- clarifai/data_upload/examples/image_detection/voc/images/2011_001610.jpg +0 -0
- clarifai/data_upload/examples/image_detection/voc/images/2011_006412.jpg +0 -0
- clarifai/data_upload/examples/image_detection/voc/images/2012_000690.jpg +0 -0
- clarifai/data_upload/examples/image_segmentation/coco/annotations/instances_val2017_subset.json +0 -5342
- clarifai/data_upload/examples/image_segmentation/coco/dataset.py +0 -107
- clarifai/data_upload/examples/image_segmentation/coco/images/000000074646.jpg +0 -0
- clarifai/data_upload/examples/image_segmentation/coco/images/000000086956.jpg +0 -0
- clarifai/data_upload/examples/image_segmentation/coco/images/000000166563.jpg +0 -0
- clarifai/data_upload/examples/image_segmentation/coco/images/000000176857.jpg +0 -0
- clarifai/data_upload/examples/image_segmentation/coco/images/000000182202.jpg +0 -0
- clarifai/data_upload/examples/image_segmentation/coco/images/000000193245.jpg +0 -0
- clarifai/data_upload/examples/image_segmentation/coco/images/000000384850.jpg +0 -0
- clarifai/data_upload/examples/image_segmentation/coco/images/000000409630.jpg +0 -0
- clarifai/data_upload/examples/image_segmentation/coco/images/000000424349.jpg +0 -0
- clarifai/data_upload/examples/image_segmentation/coco/images/000000573008.jpg +0 -0
- clarifai/data_upload/examples/text_classification/imdb_dataset/dataset.py +0 -40
- clarifai/data_upload/examples.py +0 -17
- clarifai/data_upload/upload.py +0 -356
- clarifai/dataset_export/dataset_export_inputs.py +0 -205
- clarifai/listing/concepts.py +0 -37
- clarifai/listing/datasets.py +0 -37
- clarifai/listing/inputs.py +0 -111
- clarifai/listing/installed_module_versions.py +0 -40
- clarifai/listing/lister.py +0 -200
- clarifai/listing/models.py +0 -46
- clarifai/listing/module_versions.py +0 -42
- clarifai/listing/modules.py +0 -36
- clarifai/runners/base.py +0 -140
- clarifai/runners/example.py +0 -36
- clarifai-9.7.1.dist-info/METADATA +0 -99
- clarifai-9.7.1.dist-info/RECORD +0 -456
- clarifai_utils/data_upload/README.md +0 -63
- clarifai_utils/data_upload/convert_csv.py +0 -182
- clarifai_utils/data_upload/datasets/base.py +0 -87
- clarifai_utils/data_upload/datasets/image.py +0 -253
- clarifai_utils/data_upload/datasets/text.py +0 -60
- clarifai_utils/data_upload/datasets/zoo/README.md +0 -55
- clarifai_utils/data_upload/datasets/zoo/coco_segmentation.py +0 -160
- clarifai_utils/data_upload/examples/README.md +0 -5
- clarifai_utils/data_upload/examples/image_classification/cifar10/dataset.py +0 -40
- clarifai_utils/data_upload/examples/image_classification/food-101/dataset.py +0 -39
- clarifai_utils/data_upload/examples/image_classification/food-101/images/beignets/1036242.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/beignets/1114182.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/beignets/2012944.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/beignets/2464389.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/beignets/478632.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/hamburger/1061270.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/hamburger/1202261.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/hamburger/1381751.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/hamburger/3289634.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/hamburger/862025.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/prime_rib/102197.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/prime_rib/2749372.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/prime_rib/2938268.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/prime_rib/3590861.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/prime_rib/746716.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/ramen/2955110.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/ramen/3208966.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/ramen/3270629.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/ramen/3424562.jpg +0 -0
- clarifai_utils/data_upload/examples/image_classification/food-101/images/ramen/544680.jpg +0 -0
- clarifai_utils/data_upload/examples/image_detection/__init__.py +0 -0
- clarifai_utils/data_upload/examples/image_detection/voc/__init__.py +0 -0
- clarifai_utils/data_upload/examples/image_detection/voc/annotations/2007_000464.xml +0 -39
- clarifai_utils/data_upload/examples/image_detection/voc/annotations/2008_000853.xml +0 -28
- clarifai_utils/data_upload/examples/image_detection/voc/annotations/2008_003182.xml +0 -54
- clarifai_utils/data_upload/examples/image_detection/voc/annotations/2008_008526.xml +0 -67
- clarifai_utils/data_upload/examples/image_detection/voc/annotations/2009_004315.xml +0 -28
- clarifai_utils/data_upload/examples/image_detection/voc/annotations/2009_004382.xml +0 -28
- clarifai_utils/data_upload/examples/image_detection/voc/annotations/2011_000430.xml +0 -28
- clarifai_utils/data_upload/examples/image_detection/voc/annotations/2011_001610.xml +0 -46
- clarifai_utils/data_upload/examples/image_detection/voc/annotations/2011_006412.xml +0 -99
- clarifai_utils/data_upload/examples/image_detection/voc/annotations/2012_000690.xml +0 -43
- clarifai_utils/data_upload/examples/image_detection/voc/dataset.py +0 -76
- clarifai_utils/data_upload/examples/image_detection/voc/images/2007_000464.jpg +0 -0
- clarifai_utils/data_upload/examples/image_detection/voc/images/2008_000853.jpg +0 -0
- clarifai_utils/data_upload/examples/image_detection/voc/images/2008_003182.jpg +0 -0
- clarifai_utils/data_upload/examples/image_detection/voc/images/2008_008526.jpg +0 -0
- clarifai_utils/data_upload/examples/image_detection/voc/images/2009_004315.jpg +0 -0
- clarifai_utils/data_upload/examples/image_detection/voc/images/2009_004382.jpg +0 -0
- clarifai_utils/data_upload/examples/image_detection/voc/images/2011_000430.jpg +0 -0
- clarifai_utils/data_upload/examples/image_detection/voc/images/2011_001610.jpg +0 -0
- clarifai_utils/data_upload/examples/image_detection/voc/images/2011_006412.jpg +0 -0
- clarifai_utils/data_upload/examples/image_detection/voc/images/2012_000690.jpg +0 -0
- clarifai_utils/data_upload/examples/image_segmentation/__init__.py +0 -0
- clarifai_utils/data_upload/examples/image_segmentation/coco/__init__.py +0 -0
- clarifai_utils/data_upload/examples/image_segmentation/coco/annotations/instances_val2017_subset.json +0 -5342
- clarifai_utils/data_upload/examples/image_segmentation/coco/dataset.py +0 -107
- clarifai_utils/data_upload/examples/image_segmentation/coco/images/000000074646.jpg +0 -0
- clarifai_utils/data_upload/examples/image_segmentation/coco/images/000000086956.jpg +0 -0
- clarifai_utils/data_upload/examples/image_segmentation/coco/images/000000166563.jpg +0 -0
- clarifai_utils/data_upload/examples/image_segmentation/coco/images/000000176857.jpg +0 -0
- clarifai_utils/data_upload/examples/image_segmentation/coco/images/000000182202.jpg +0 -0
- clarifai_utils/data_upload/examples/image_segmentation/coco/images/000000193245.jpg +0 -0
- clarifai_utils/data_upload/examples/image_segmentation/coco/images/000000384850.jpg +0 -0
- clarifai_utils/data_upload/examples/image_segmentation/coco/images/000000409630.jpg +0 -0
- clarifai_utils/data_upload/examples/image_segmentation/coco/images/000000424349.jpg +0 -0
- clarifai_utils/data_upload/examples/image_segmentation/coco/images/000000573008.jpg +0 -0
- clarifai_utils/data_upload/examples/text_classification/__init__.py +0 -0
- clarifai_utils/data_upload/examples/text_classification/imdb_dataset/__init__.py +0 -0
- clarifai_utils/data_upload/examples/text_classification/imdb_dataset/dataset.py +0 -40
- clarifai_utils/data_upload/examples.py +0 -17
- clarifai_utils/data_upload/upload.py +0 -356
- clarifai_utils/dataset_export/dataset_export_inputs.py +0 -205
- clarifai_utils/listing/__init__.py +0 -0
- clarifai_utils/listing/concepts.py +0 -37
- clarifai_utils/listing/datasets.py +0 -37
- clarifai_utils/listing/inputs.py +0 -111
- clarifai_utils/listing/installed_module_versions.py +0 -40
- clarifai_utils/listing/lister.py +0 -200
- clarifai_utils/listing/models.py +0 -46
- clarifai_utils/listing/module_versions.py +0 -42
- clarifai_utils/listing/modules.py +0 -36
- clarifai_utils/runners/__init__.py +0 -0
- clarifai_utils/runners/base.py +0 -140
- clarifai_utils/runners/example.py +0 -36
- /clarifai/{data_upload/__init__.py → cli.py} +0 -0
- /clarifai/{data_upload/datasets → datasets}/__init__.py +0 -0
- /clarifai/{data_upload/datasets/zoo → datasets/upload}/__init__.py +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/__init__.py +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/cifar10/__init__.py +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/cifar10/cifar_small_test.csv +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/cifar10/cifar_small_train.csv +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_700.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_701.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_702.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_703.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_704.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_705.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_706.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_707.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_708.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_709.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/__init__.py +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/beignets/1420783.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/beignets/3287885.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/beignets/3617075.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/beignets/38052.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/beignets/39147.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/hamburger/139558.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/hamburger/1636096.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/hamburger/2480925.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/hamburger/3385808.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/hamburger/3647386.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/prime_rib/1826869.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/prime_rib/2243245.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/prime_rib/259212.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/prime_rib/2842688.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/prime_rib/3035414.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/ramen/1545393.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/ramen/2427642.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/ramen/3520891.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/ramen/377566.jpg +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/image_classification/food-101/images/ramen/503504.jpg +0 -0
- /clarifai/{data_upload/examples/image_detection → datasets/upload/examples/text_classification}/__init__.py +0 -0
- /clarifai/{data_upload/examples/image_detection/voc → datasets/upload/examples/text_classification/imdb_dataset}/__init__.py +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/text_classification/imdb_dataset/test.csv +0 -0
- /clarifai/{data_upload → datasets/upload}/examples/text_classification/imdb_dataset/train.csv +0 -0
- /clarifai/{data_upload/examples/image_segmentation → datasets/upload/loaders}/__init__.py +0 -0
- /clarifai/{data_upload/examples/image_segmentation/coco → utils}/__init__.py +0 -0
- {clarifai-9.7.1.dist-info → clarifai-9.7.2.dist-info}/WHEEL +0 -0
- {clarifai-9.7.1.dist-info → clarifai-9.7.2.dist-info}/entry_points.txt +0 -0
- {clarifai-9.7.1.dist-info → clarifai-9.7.2.dist-info}/top_level.txt +0 -0
- /clarifai/data_upload/examples/text_classification/__init__.py → /clarifai_utils/cli.py +0 -0
- {clarifai/data_upload/examples/text_classification/imdb_dataset → clarifai_utils/datasets}/__init__.py +0 -0
- {clarifai/listing → clarifai_utils/datasets/upload}/__init__.py +0 -0
- {clarifai/runners → clarifai_utils/datasets/upload/examples/image_classification}/__init__.py +0 -0
- /clarifai_utils/{data_upload → datasets/upload/examples/image_classification/cifar10}/__init__.py +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/cifar10/cifar_small_test.csv +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/cifar10/cifar_small_train.csv +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_700.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_701.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_702.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_703.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_704.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_705.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_706.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_707.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_708.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/cifar10/images/test_batch_709.jpg +0 -0
- /clarifai_utils/{data_upload/datasets → datasets/upload/examples/image_classification/food-101}/__init__.py +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/beignets/1420783.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/beignets/3287885.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/beignets/3617075.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/beignets/38052.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/beignets/39147.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/hamburger/139558.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/hamburger/1636096.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/hamburger/2480925.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/hamburger/3385808.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/hamburger/3647386.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/prime_rib/1826869.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/prime_rib/2243245.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/prime_rib/259212.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/prime_rib/2842688.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/prime_rib/3035414.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/ramen/1545393.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/ramen/2427642.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/ramen/3520891.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/ramen/377566.jpg +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/image_classification/food-101/images/ramen/503504.jpg +0 -0
- /clarifai_utils/{data_upload/datasets/zoo → datasets/upload/examples/text_classification}/__init__.py +0 -0
- /clarifai_utils/{data_upload/examples/image_classification → datasets/upload/examples/text_classification/imdb_dataset}/__init__.py +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/text_classification/imdb_dataset/test.csv +0 -0
- /clarifai_utils/{data_upload → datasets/upload}/examples/text_classification/imdb_dataset/train.csv +0 -0
- /clarifai_utils/{data_upload/examples/image_classification/cifar10 → datasets/upload/loaders}/__init__.py +0 -0
- /clarifai_utils/{data_upload/examples/image_classification/food-101 → utils}/__init__.py +0 -0
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import tempfile
|
|
3
|
-
import zipfile
|
|
4
|
-
from io import BytesIO
|
|
5
|
-
|
|
6
|
-
import requests
|
|
7
|
-
from clarifai_grpc.grpc.api import resources_pb2
|
|
8
|
-
from google.protobuf.json_format import MessageToDict
|
|
9
|
-
from PIL import ImageFile
|
|
10
|
-
from tqdm import tqdm
|
|
11
|
-
|
|
12
|
-
from clarifai.auth.helper import ClarifaiAuthHelper
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class DatasetExportReader:
|
|
16
|
-
"""
|
|
17
|
-
Unpacks the zipfile from DatasetVersionExport
|
|
18
|
-
- Downloads the temp archive onto disk
|
|
19
|
-
- Reads DatasetVersionExports archive in memory without extracting all
|
|
20
|
-
- Yield each api.Input object.
|
|
21
|
-
"""
|
|
22
|
-
|
|
23
|
-
def __init__(self, session, archive_url=None, local_archive_path=None):
|
|
24
|
-
|
|
25
|
-
self.input_count = 0
|
|
26
|
-
self.temp_file = None
|
|
27
|
-
self.session = session
|
|
28
|
-
|
|
29
|
-
assert archive_url or local_archive_path, "Must use one input."
|
|
30
|
-
|
|
31
|
-
if archive_url:
|
|
32
|
-
print('url: %s' % archive_url)
|
|
33
|
-
self.temp_file = self._download_temp_archive(archive_url)
|
|
34
|
-
self.archive = zipfile.ZipFile(self.temp_file)
|
|
35
|
-
else:
|
|
36
|
-
print("path: %s" % local_archive_path)
|
|
37
|
-
self.archive = zipfile.ZipFile(local_archive_path)
|
|
38
|
-
|
|
39
|
-
self.file_name_list = self.archive.namelist()
|
|
40
|
-
assert "mimetype" in self.file_name_list, "Missing mimetype file in the dataset export archive."
|
|
41
|
-
assert self.archive.read("mimetype") == b"application/x.clarifai-data+protobuf"
|
|
42
|
-
self.file_name_list.remove("mimetype")
|
|
43
|
-
|
|
44
|
-
print("Obtained file name list. %d entries." % len(self.file_name_list))
|
|
45
|
-
self.split_dir = os.path.dirname(self.file_name_list[0]) if len(self.file_name_list) else ""
|
|
46
|
-
|
|
47
|
-
def _download_temp_archive(self, archive_url, chunk_size=128):
|
|
48
|
-
"""
|
|
49
|
-
Downloads the temp archive of InputBatches.
|
|
50
|
-
"""
|
|
51
|
-
r = self.session.get(archive_url, stream=True)
|
|
52
|
-
temp_file = tempfile.TemporaryFile()
|
|
53
|
-
for chunk in r.iter_content(chunk_size=chunk_size):
|
|
54
|
-
temp_file.write(chunk)
|
|
55
|
-
|
|
56
|
-
return temp_file
|
|
57
|
-
|
|
58
|
-
def __len__(self):
|
|
59
|
-
if not self.input_count:
|
|
60
|
-
if self.file_name_list is not None:
|
|
61
|
-
for filename in self.file_name_list:
|
|
62
|
-
self.input_count += int(filename.split('_n')[-1])
|
|
63
|
-
|
|
64
|
-
return self.input_count
|
|
65
|
-
|
|
66
|
-
def __iter__(self):
|
|
67
|
-
"""
|
|
68
|
-
Loops through all InputBatches in the DatasetVersionExport and yields every api.Input object
|
|
69
|
-
"""
|
|
70
|
-
if self.file_name_list is not None:
|
|
71
|
-
for filename in self.file_name_list:
|
|
72
|
-
db = resources_pb2.InputBatch().FromString(self.archive.read(filename))
|
|
73
|
-
for db_input in db.inputs:
|
|
74
|
-
yield db_input
|
|
75
|
-
print("DONE")
|
|
76
|
-
|
|
77
|
-
def __enter__(self):
|
|
78
|
-
return self
|
|
79
|
-
|
|
80
|
-
def __exit__(self, *args):
|
|
81
|
-
self.close()
|
|
82
|
-
|
|
83
|
-
def close(self):
|
|
84
|
-
print("closing file objects.")
|
|
85
|
-
self.archive.close()
|
|
86
|
-
if self.temp_file:
|
|
87
|
-
self.temp_file.close()
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
class InputDownloader:
|
|
91
|
-
"""
|
|
92
|
-
Takes an iterator or a list of api.Input instances as input,
|
|
93
|
-
and has a method for downloading all inputs (image/text/audio/video) of that data.
|
|
94
|
-
Has the ability of either writing to a new ZIP archive OR a filesystem directory.
|
|
95
|
-
"""
|
|
96
|
-
|
|
97
|
-
def __init__(self, session, input_iterator):
|
|
98
|
-
self.input_iterator = input_iterator
|
|
99
|
-
self.num_inputs = 0
|
|
100
|
-
self.split_prefix = None
|
|
101
|
-
self.session = session
|
|
102
|
-
self.input_ext = dict(image=".jpg", text=".txt", audio=".wav", video=".mp4")
|
|
103
|
-
if isinstance(self.input_iterator, DatasetExportReader):
|
|
104
|
-
self.split_prefix = self.input_iterator.split_dir
|
|
105
|
-
|
|
106
|
-
def _save_image_to_archive(self, new_archive, hosted_url, file_name):
|
|
107
|
-
"""
|
|
108
|
-
Use PIL ImageFile to return image parsed from the response bytestring (from requests) and append to zip file.
|
|
109
|
-
"""
|
|
110
|
-
p = ImageFile.Parser()
|
|
111
|
-
p.feed(self.session.get(hosted_url).content)
|
|
112
|
-
image = p.close()
|
|
113
|
-
image_file = BytesIO()
|
|
114
|
-
image.save(image_file, 'JPEG')
|
|
115
|
-
new_archive.writestr(file_name, image_file.getvalue())
|
|
116
|
-
|
|
117
|
-
def _save_text_to_archive(self, new_archive, hosted_url, file_name):
|
|
118
|
-
"""
|
|
119
|
-
Gets the text response bytestring (from requests) and append to zip file.
|
|
120
|
-
"""
|
|
121
|
-
text_content = self.session.get(hosted_url).content
|
|
122
|
-
new_archive.writestr(file_name, text_content)
|
|
123
|
-
|
|
124
|
-
def _save_audio_to_archive(self, new_archive, hosted_url, file_name):
|
|
125
|
-
"""
|
|
126
|
-
Gets the audio response bytestring (from requests) as chunks and append to zip file.
|
|
127
|
-
"""
|
|
128
|
-
audio_response = requests.get(hosted_url, stream=True)
|
|
129
|
-
audio_stream = BytesIO()
|
|
130
|
-
# Retrieve the audio content in chunks and write to the BytesIO object
|
|
131
|
-
for chunk in audio_response.iter_content(chunk_size=128):
|
|
132
|
-
audio_stream.write(chunk)
|
|
133
|
-
new_archive.writestr(file_name, audio_stream.getvalue())
|
|
134
|
-
|
|
135
|
-
def _save_video_to_archive(self, new_archive, hosted_url, file_name):
|
|
136
|
-
"""
|
|
137
|
-
Gets the video response bytestring (from requests) as chunks and append to zip file.
|
|
138
|
-
"""
|
|
139
|
-
video_response = self.session.get(hosted_url)
|
|
140
|
-
video_stream = BytesIO()
|
|
141
|
-
# Retrieve the video content in chunks and write to the BytesIO object
|
|
142
|
-
for chunk in video_response.iter_content(chunk_size=128):
|
|
143
|
-
video_stream.write(chunk)
|
|
144
|
-
new_archive.writestr(file_name, video_stream.getvalue())
|
|
145
|
-
|
|
146
|
-
def _write_input_archive(self, save_path, split):
|
|
147
|
-
"""
|
|
148
|
-
Writes the input archive into prefix dir.
|
|
149
|
-
"""
|
|
150
|
-
try:
|
|
151
|
-
total = len(self.input_iterator)
|
|
152
|
-
except TypeError:
|
|
153
|
-
total = None
|
|
154
|
-
with zipfile.ZipFile(save_path, "a") as new_archive:
|
|
155
|
-
for input_ in tqdm(self.input_iterator, desc="Writing input archive", total=total):
|
|
156
|
-
# checks for input
|
|
157
|
-
data_dict = MessageToDict(input_.data)
|
|
158
|
-
input_type = list(
|
|
159
|
-
filter(lambda x: x in list(data_dict.keys()), list(self.input_ext.keys())))[0]
|
|
160
|
-
hosted = getattr(input_.data, input_type).hosted
|
|
161
|
-
if hosted.prefix:
|
|
162
|
-
assert 'orig' in hosted.sizes
|
|
163
|
-
hosted_url = f"{hosted.prefix}/orig/{hosted.suffix}"
|
|
164
|
-
file_name = os.path.join(split, input_.id + self.input_ext[input_type])
|
|
165
|
-
if input_type == "image":
|
|
166
|
-
self._save_image_to_archive(new_archive, hosted_url, file_name)
|
|
167
|
-
elif input_type == "text":
|
|
168
|
-
self._save_text_to_archive(new_archive, hosted_url, file_name)
|
|
169
|
-
elif input_type == "audio":
|
|
170
|
-
self._save_audio_to_archive(new_archive, hosted_url, file_name)
|
|
171
|
-
elif input_type == "video":
|
|
172
|
-
self._save_video_to_archive(new_archive, hosted_url, file_name)
|
|
173
|
-
self.num_inputs += 1
|
|
174
|
-
|
|
175
|
-
def _check_output_archive(self, save_path):
|
|
176
|
-
try:
|
|
177
|
-
archive = zipfile.ZipFile(save_path, 'r')
|
|
178
|
-
except zipfile.BadZipFile as e:
|
|
179
|
-
raise e
|
|
180
|
-
assert len(
|
|
181
|
-
archive.namelist()) == self.num_inputs, "Archive has %d inputs | expecting %d inputs" % (
|
|
182
|
-
len(archive.namelist()), self.num_inputs)
|
|
183
|
-
|
|
184
|
-
def download_input_archive(self, save_path, split=None):
|
|
185
|
-
"""
|
|
186
|
-
Downloads the archive from the URL into an archive of inputs in the directory format {split}/{input_type}.
|
|
187
|
-
"""
|
|
188
|
-
self._write_input_archive(save_path, split=split or self.split_prefix)
|
|
189
|
-
self._check_output_archive(save_path)
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if __name__ == "__main__":
|
|
193
|
-
import sys
|
|
194
|
-
if len(sys.argv) < 2:
|
|
195
|
-
print(f"usage: {sys.argv[0]} <archive-url> [<save-path>]")
|
|
196
|
-
sys.exit(2)
|
|
197
|
-
archive_url = sys.argv[1]
|
|
198
|
-
save_path = sys.argv[2] if len(sys.argv) > 2 else "output.zip"
|
|
199
|
-
metadata = getattr(ClarifaiAuthHelper.from_env(), "metadata")[0]
|
|
200
|
-
# Create a session object and set auth header
|
|
201
|
-
session = requests.Session()
|
|
202
|
-
session.headers.update({'Authorization': metadata[1]})
|
|
203
|
-
|
|
204
|
-
with DatasetExportReader(session=session, archive_url=archive_url) as reader:
|
|
205
|
-
InputDownloader(session, reader).download_input_archive(save_path=save_path)
|
|
File without changes
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
from clarifai_grpc.grpc.api import resources_pb2, service_pb2
|
|
2
|
-
from clarifai_grpc.grpc.api.status import status_code_pb2
|
|
3
|
-
|
|
4
|
-
from clarifai.client import V2Stub
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def concepts_generator(stub: V2Stub, user_id: str, app_id: str, page_size: int = 64):
|
|
8
|
-
"""
|
|
9
|
-
Lists all the concept in the given userAppID user_id, app_id app.
|
|
10
|
-
|
|
11
|
-
Args:
|
|
12
|
-
stub: client stub.
|
|
13
|
-
user_id: the user to list from.
|
|
14
|
-
app_id: the app in the user_id account to list from.
|
|
15
|
-
page_size: the pagination size to use while iterating.
|
|
16
|
-
|
|
17
|
-
Returns:
|
|
18
|
-
concepts: a list of Concept protos for all the concepts in the app.
|
|
19
|
-
"""
|
|
20
|
-
userDataObject = resources_pb2.UserAppIDSet(user_id=user_id, app_id=app_id)
|
|
21
|
-
|
|
22
|
-
concept_success_status = {status_code_pb2.SUCCESS}
|
|
23
|
-
|
|
24
|
-
page = 1
|
|
25
|
-
while True:
|
|
26
|
-
response = stub.ListConcepts(
|
|
27
|
-
service_pb2.ListConceptsRequest(user_app_id=userDataObject, page=page, per_page=page_size),
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
if response.status.code not in concept_success_status:
|
|
31
|
-
raise Exception("ListConcepts failed with response %r" % response)
|
|
32
|
-
if len(response.concepts) == 0:
|
|
33
|
-
break
|
|
34
|
-
else:
|
|
35
|
-
for item in response.concepts:
|
|
36
|
-
yield item
|
|
37
|
-
page += 1
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
from clarifai_grpc.grpc.api import resources_pb2, service_pb2
|
|
2
|
-
from clarifai_grpc.grpc.api.status import status_code_pb2
|
|
3
|
-
|
|
4
|
-
from clarifai.client import V2Stub
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def datasets_generator(stub: V2Stub, user_id: str, app_id: str, page_size: int = 64):
|
|
8
|
-
"""
|
|
9
|
-
Lists all the datasets in an application given a userAppID user_id, app_id app.
|
|
10
|
-
|
|
11
|
-
Args:
|
|
12
|
-
stub: client stub.
|
|
13
|
-
user_id: the user to list from.
|
|
14
|
-
app_id: the app in the user_id account to list from.
|
|
15
|
-
page_size: the pagination size to use while iterating.
|
|
16
|
-
|
|
17
|
-
Returns:
|
|
18
|
-
datasets: a list of Datasets protos for all the Datasets in the app.
|
|
19
|
-
"""
|
|
20
|
-
userDataObject = resources_pb2.UserAppIDSet(user_id=user_id, app_id=app_id)
|
|
21
|
-
|
|
22
|
-
dataset_success_status = {status_code_pb2.SUCCESS}
|
|
23
|
-
|
|
24
|
-
page = 1
|
|
25
|
-
while True:
|
|
26
|
-
response = stub.ListDatasets(
|
|
27
|
-
service_pb2.ListDatasetsRequest(user_app_id=userDataObject, page=page, per_page=page_size),
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
if response.status.code not in dataset_success_status:
|
|
31
|
-
raise Exception("ListDatasets failed with response %r" % response)
|
|
32
|
-
if len(response.datasets) == 0:
|
|
33
|
-
break
|
|
34
|
-
else:
|
|
35
|
-
for item in response.datasets:
|
|
36
|
-
yield item
|
|
37
|
-
page += 1
|
clarifai_utils/listing/inputs.py
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
from clarifai_grpc.grpc.api import resources_pb2, service_pb2
|
|
2
|
-
from clarifai_grpc.grpc.api.status import status_code_pb2
|
|
3
|
-
|
|
4
|
-
from clarifai.client import V2Stub
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def generator_setup(user_id, app_id):
|
|
8
|
-
userDataObject = resources_pb2.UserAppIDSet(user_id=user_id, app_id=app_id)
|
|
9
|
-
|
|
10
|
-
input_success_status = {
|
|
11
|
-
status_code_pb2.INPUT_DOWNLOAD_SUCCESS,
|
|
12
|
-
status_code_pb2.INPUT_DOWNLOAD_PENDING,
|
|
13
|
-
status_code_pb2.INPUT_DOWNLOAD_IN_PROGRESS,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
response_success_status = {status_code_pb2.SUCCESS, status_code_pb2.MIXED_STATUS}
|
|
17
|
-
|
|
18
|
-
return (userDataObject, input_success_status, response_success_status)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def inputs_generator(
|
|
22
|
-
stub: V2Stub,
|
|
23
|
-
user_id: str,
|
|
24
|
-
app_id: str,
|
|
25
|
-
page_size: int = 64,
|
|
26
|
-
only_successful_inputs: bool = True,
|
|
27
|
-
):
|
|
28
|
-
"""
|
|
29
|
-
Lists all the inputs in the given userAppID user_id, app_id app. This uses the more efficient
|
|
30
|
-
streaming input listing technique.
|
|
31
|
-
|
|
32
|
-
Args:
|
|
33
|
-
stub: grpc client stub.
|
|
34
|
-
user_id: the user to list from.
|
|
35
|
-
app_id: the app in the user_id account to list from.
|
|
36
|
-
page_size: the pagination size to use while iterating.
|
|
37
|
-
only_successful_inputs: only accept inputs with non-failure statuses.
|
|
38
|
-
"""
|
|
39
|
-
userDataObject, input_success_status, response_success_status = generator_setup(
|
|
40
|
-
user_id=user_id, app_id=app_id)
|
|
41
|
-
|
|
42
|
-
# userDataObject = resources_pb2.UserAppIDSet(user_id=user_id, app_id=app_id)
|
|
43
|
-
|
|
44
|
-
# input_success_status = {
|
|
45
|
-
# status_code_pb2.INPUT_DOWNLOAD_SUCCESS,
|
|
46
|
-
# status_code_pb2.INPUT_DOWNLOAD_PENDING,
|
|
47
|
-
# status_code_pb2.INPUT_DOWNLOAD_IN_PROGRESS,
|
|
48
|
-
# }
|
|
49
|
-
|
|
50
|
-
# response_success_status = {status_code_pb2.SUCCESS, status_code_pb2.MIXED_STATUS}
|
|
51
|
-
|
|
52
|
-
last_id = ""
|
|
53
|
-
|
|
54
|
-
while True:
|
|
55
|
-
response = stub.StreamInputs(
|
|
56
|
-
service_pb2.StreamInputsRequest(
|
|
57
|
-
user_app_id=userDataObject, per_page=page_size, last_id=last_id),)
|
|
58
|
-
if response.status.code not in response_success_status:
|
|
59
|
-
raise Exception("Stream inputs failed with response %r" % response)
|
|
60
|
-
if len(response.inputs) == 0:
|
|
61
|
-
break
|
|
62
|
-
else:
|
|
63
|
-
for inp in response.inputs:
|
|
64
|
-
last_id = inp.id
|
|
65
|
-
if only_successful_inputs:
|
|
66
|
-
if inp.status.code in input_success_status:
|
|
67
|
-
yield inp
|
|
68
|
-
else:
|
|
69
|
-
yield inp
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def dataset_inputs_generator(
|
|
73
|
-
stub: V2Stub,
|
|
74
|
-
user_id: str,
|
|
75
|
-
app_id: str,
|
|
76
|
-
page_size: int = 64,
|
|
77
|
-
only_successful_inputs: bool = True,
|
|
78
|
-
dataset_id: str = None,
|
|
79
|
-
):
|
|
80
|
-
"""
|
|
81
|
-
Lists all the inputs in the given userAppID user_id, app_id app. This uses the more efficient
|
|
82
|
-
streaming input listing technique.
|
|
83
|
-
|
|
84
|
-
Args:
|
|
85
|
-
stub: grpc client stub.
|
|
86
|
-
user_id: the user to list from.
|
|
87
|
-
app_id: the app in the user_id account to list from.
|
|
88
|
-
page_size: the pagination size to use while iterating.
|
|
89
|
-
only_successful_inputs: only accept inputs with non-failure statuses.
|
|
90
|
-
"""
|
|
91
|
-
userDataObject, input_success_status, response_success_status = generator_setup(
|
|
92
|
-
user_id=user_id, app_id=app_id)
|
|
93
|
-
page = 1
|
|
94
|
-
|
|
95
|
-
while True:
|
|
96
|
-
response = stub.ListDatasetInputs(
|
|
97
|
-
service_pb2.ListDatasetInputsRequest(
|
|
98
|
-
user_app_id=userDataObject, per_page=page_size, page=page, dataset_id=dataset_id),)
|
|
99
|
-
if response.status.code not in response_success_status:
|
|
100
|
-
raise Exception("List Dataset inputs failed with response %r" % response)
|
|
101
|
-
if len(response.dataset_inputs) == 0:
|
|
102
|
-
break
|
|
103
|
-
else:
|
|
104
|
-
if only_successful_inputs:
|
|
105
|
-
for inp in response.dataset_inputs:
|
|
106
|
-
if inp.input.status.code in input_success_status:
|
|
107
|
-
yield inp.input
|
|
108
|
-
else:
|
|
109
|
-
for inp in response.dataset_inputs:
|
|
110
|
-
yield inp.input
|
|
111
|
-
page += 1
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
from clarifai_grpc.grpc.api import resources_pb2, service_pb2
|
|
2
|
-
from clarifai_grpc.grpc.api.status import status_code_pb2
|
|
3
|
-
|
|
4
|
-
from clarifai.client import V2Stub
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def installed_module_versions_generator(stub: V2Stub,
|
|
8
|
-
user_id: str,
|
|
9
|
-
app_id: str,
|
|
10
|
-
page_size: int = 64):
|
|
11
|
-
"""
|
|
12
|
-
Lists all the installed module versions in the given userAppID user_id, app_id app.
|
|
13
|
-
|
|
14
|
-
Args:
|
|
15
|
-
stub: client stub.
|
|
16
|
-
user_id: the user to list from.
|
|
17
|
-
app_id: the app in the user_id account to list from.
|
|
18
|
-
page_size: the pagination size to use while iterating.
|
|
19
|
-
|
|
20
|
-
Returns:
|
|
21
|
-
imvs: a list of InstalledModuleVersion protos for all the installed modules versions in the app.
|
|
22
|
-
"""
|
|
23
|
-
userDataObject = resources_pb2.UserAppIDSet(user_id=user_id, app_id=app_id)
|
|
24
|
-
|
|
25
|
-
imv_success_status = {status_code_pb2.SUCCESS}
|
|
26
|
-
|
|
27
|
-
page = 1
|
|
28
|
-
while True:
|
|
29
|
-
response = stub.ListInstalledModuleVersions(
|
|
30
|
-
service_pb2.ListInstalledModuleVersionsRequest(
|
|
31
|
-
user_app_id=userDataObject, page=page, per_page=page_size),)
|
|
32
|
-
|
|
33
|
-
if response.status.code not in imv_success_status:
|
|
34
|
-
raise Exception("ListInstalledModuleVersions failed with response %r" % response)
|
|
35
|
-
for item in response.installed_module_versions:
|
|
36
|
-
yield item
|
|
37
|
-
page += 1
|
|
38
|
-
# if we don't get a full page back we know we're done.
|
|
39
|
-
if len(response.installed_module_versions) < page_size:
|
|
40
|
-
break
|
clarifai_utils/listing/lister.py
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
from clarifai_grpc.grpc.api import resources_pb2
|
|
2
|
-
|
|
3
|
-
from clarifai.client import V2Stub
|
|
4
|
-
from clarifai.listing.concepts import concepts_generator
|
|
5
|
-
from clarifai.listing.datasets import datasets_generator
|
|
6
|
-
from clarifai.listing.inputs import dataset_inputs_generator, inputs_generator
|
|
7
|
-
from clarifai.listing.installed_module_versions import installed_module_versions_generator
|
|
8
|
-
from clarifai.listing.models import models_generator
|
|
9
|
-
from clarifai.listing.module_versions import module_versions_generator
|
|
10
|
-
from clarifai.listing.modules import modules_generator
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class ClarifaiResourceLister(object):
|
|
14
|
-
|
|
15
|
-
def __init__(self, stub: V2Stub, user_id: str, app_id: str, page_size: int = 16):
|
|
16
|
-
"""
|
|
17
|
-
Helper class for common listing of resources in an Clarifai App.
|
|
18
|
-
|
|
19
|
-
Args:
|
|
20
|
-
stub: grpc client V2Strub for our API.
|
|
21
|
-
user_id: the user to list from.
|
|
22
|
-
app_id: the app in the user_id account to list from.
|
|
23
|
-
page_size: the pagination size to use while iterating.
|
|
24
|
-
"""
|
|
25
|
-
self.stub = stub
|
|
26
|
-
self.user_id = user_id
|
|
27
|
-
self.app_id = app_id
|
|
28
|
-
self.user_app_id_proto = resources_pb2.UserAppIDSet(user_id=user_id, app_id=app_id)
|
|
29
|
-
self.default_page_size = page_size
|
|
30
|
-
|
|
31
|
-
def list_all_models(self, page_size: int = None, only_in_app: bool = False):
|
|
32
|
-
"""
|
|
33
|
-
This lists all the Models accessible in app. Not recommended for large apps.
|
|
34
|
-
|
|
35
|
-
Params:
|
|
36
|
-
page_size: how many elements per page to fetch
|
|
37
|
-
only_in_app: if only models created in the app should be returned
|
|
38
|
-
|
|
39
|
-
Returns:
|
|
40
|
-
inputs: a list of Model protos for all the inputs in the app.
|
|
41
|
-
"""
|
|
42
|
-
return [item for item in self.models_generator(page_size, only_in_app)]
|
|
43
|
-
|
|
44
|
-
def models_generator(self, page_size: int = None, only_in_app: bool = False):
|
|
45
|
-
"""
|
|
46
|
-
This lists all the models in an app. Not recommended for large apps.
|
|
47
|
-
|
|
48
|
-
Params:
|
|
49
|
-
page_size: how many elements per page to fetch
|
|
50
|
-
only_in_app: if only models created in the app should be returned
|
|
51
|
-
|
|
52
|
-
Returns:
|
|
53
|
-
gen: a generator that yields a single Model proto at a time.
|
|
54
|
-
"""
|
|
55
|
-
page_size = self.default_page_size if page_size is None else page_size
|
|
56
|
-
return models_generator(self.stub, self.user_id, self.app_id, page_size, only_in_app)
|
|
57
|
-
|
|
58
|
-
def list_all_datasets(self, page_size: int = None):
|
|
59
|
-
"""
|
|
60
|
-
This lists all Datasets in app. Not recommended for large apps.
|
|
61
|
-
|
|
62
|
-
Params:
|
|
63
|
-
page_size: how many elements per page to fetch
|
|
64
|
-
|
|
65
|
-
Returns:
|
|
66
|
-
inputs: a list of Dataset protos for all the inputs in the app.
|
|
67
|
-
"""
|
|
68
|
-
return [item for item in self.datasets_generator(page_size)]
|
|
69
|
-
|
|
70
|
-
def datasets_generator(self, page_size: int = None):
|
|
71
|
-
"""
|
|
72
|
-
This lists all the Datasets in an app. Not recommended for large apps.
|
|
73
|
-
|
|
74
|
-
Params:
|
|
75
|
-
page_size: how many elements per page to fetch
|
|
76
|
-
|
|
77
|
-
Returns:
|
|
78
|
-
gen: a generator that yields a single Dataset proto at a time.
|
|
79
|
-
"""
|
|
80
|
-
page_size = self.default_page_size if page_size is None else page_size
|
|
81
|
-
return datasets_generator(self.stub, self.user_id, self.app_id, page_size)
|
|
82
|
-
|
|
83
|
-
def list_all_concepts(self, page_size: int = None):
|
|
84
|
-
"""
|
|
85
|
-
This lists all the concepts in an app. Not recommended for large apps.
|
|
86
|
-
|
|
87
|
-
Returns:
|
|
88
|
-
concepts: a list of Concept protos for all the concepts in the app.
|
|
89
|
-
"""
|
|
90
|
-
return [item for item in self.concepts_generator(page_size)]
|
|
91
|
-
|
|
92
|
-
def concepts_generator(self, page_size: int = None):
|
|
93
|
-
"""
|
|
94
|
-
This lists all the concepts in an app. Not recommended for large apps.
|
|
95
|
-
|
|
96
|
-
Returns:
|
|
97
|
-
gen: a generator that yields a single Concept proto at a time.
|
|
98
|
-
"""
|
|
99
|
-
page_size = self.default_page_size if page_size is None else page_size
|
|
100
|
-
return concepts_generator(self.stub, self.user_id, self.app_id, page_size)
|
|
101
|
-
|
|
102
|
-
def list_all_inputs(self, page_size: int = None):
|
|
103
|
-
"""
|
|
104
|
-
This lists all the inputs in an app. Not recommended for large apps.
|
|
105
|
-
|
|
106
|
-
Returns:
|
|
107
|
-
inputs: a list of Input protos for all the inputs in the app.
|
|
108
|
-
"""
|
|
109
|
-
return [item for item in self.inputs_generator(page_size)]
|
|
110
|
-
|
|
111
|
-
def inputs_generator(self, page_size: int = None):
|
|
112
|
-
"""
|
|
113
|
-
This lists all the inputs in an app. Not recommended for large apps.
|
|
114
|
-
|
|
115
|
-
Returns:
|
|
116
|
-
gen: a generator that yields a single Input proto at a time.
|
|
117
|
-
"""
|
|
118
|
-
page_size = self.default_page_size if page_size is None else page_size
|
|
119
|
-
return inputs_generator(self.stub, self.user_id, self.app_id, page_size)
|
|
120
|
-
|
|
121
|
-
def list_all_dataset_inputs(self, page_size: int = None, dataset_id: str = None):
|
|
122
|
-
"""
|
|
123
|
-
This lists all the inputs in a dataset. Not recommended for large datasets.
|
|
124
|
-
|
|
125
|
-
Returns:
|
|
126
|
-
inputs: a list of Input protos for all the inputs in the app.
|
|
127
|
-
"""
|
|
128
|
-
return [item for item in self.dataset_inputs_generator(page_size, dataset_id)]
|
|
129
|
-
|
|
130
|
-
def dataset_inputs_generator(self, page_size: int = None, dataset_id: str = None):
|
|
131
|
-
"""
|
|
132
|
-
This lists all the inputs in a dataset. Not recommended for large datasets.
|
|
133
|
-
|
|
134
|
-
Returns:
|
|
135
|
-
gen: a generator that yields a single Input proto at a time.
|
|
136
|
-
"""
|
|
137
|
-
page_size = self.default_page_size if page_size is None else page_size
|
|
138
|
-
return dataset_inputs_generator(
|
|
139
|
-
stub=self.stub,
|
|
140
|
-
user_id=self.user_id,
|
|
141
|
-
app_id=self.app_id,
|
|
142
|
-
page_size=page_size,
|
|
143
|
-
dataset_id=dataset_id)
|
|
144
|
-
|
|
145
|
-
def list_all_installed_module_versions(self, page_size: int = None):
|
|
146
|
-
"""
|
|
147
|
-
This lists all the installed_module_versions in an app. Not recommended for large apps.
|
|
148
|
-
|
|
149
|
-
Returns:
|
|
150
|
-
installed_module_versions: a list of InstalledModuleVersion protos for all the installed_module_versions in the app.
|
|
151
|
-
"""
|
|
152
|
-
return [item for item in self.installed_module_versions_generator(page_size)]
|
|
153
|
-
|
|
154
|
-
def installed_module_versions_generator(self, page_size: int = None):
|
|
155
|
-
"""
|
|
156
|
-
This lists all the installed_module_versions in an app. Not recommended for large apps.
|
|
157
|
-
|
|
158
|
-
Returns:
|
|
159
|
-
gen: a generator that yields a single InstalledModuleVersion proto at a time.
|
|
160
|
-
"""
|
|
161
|
-
page_size = self.default_page_size if page_size is None else page_size
|
|
162
|
-
return installed_module_versions_generator(self.stub, self.user_id, self.app_id, page_size)
|
|
163
|
-
|
|
164
|
-
def list_all_modules(self, page_size: int = None):
|
|
165
|
-
"""
|
|
166
|
-
This lists all the modules in an app. Not recommended for large apps.
|
|
167
|
-
|
|
168
|
-
Returns:
|
|
169
|
-
modules: a list of Module protos for all the modules in the app.
|
|
170
|
-
"""
|
|
171
|
-
return [item for item in self.module_generator(page_size)]
|
|
172
|
-
|
|
173
|
-
def module_generator(self, page_size: int = None):
|
|
174
|
-
"""
|
|
175
|
-
This lists all the module in an app. Not recommended for large apps.
|
|
176
|
-
|
|
177
|
-
Returns:
|
|
178
|
-
gen: a generator that yields a single Module proto at a time.
|
|
179
|
-
"""
|
|
180
|
-
page_size = self.default_page_size if page_size is None else page_size
|
|
181
|
-
return modules_generator(self.stub, self.user_id, self.app_id, page_size)
|
|
182
|
-
|
|
183
|
-
def list_all_module_versions(self, module_id: str, page_size: int = None):
|
|
184
|
-
"""
|
|
185
|
-
This lists all the module_versions in an app. Not recommended for large apps.
|
|
186
|
-
|
|
187
|
-
Returns:
|
|
188
|
-
module_versions: a list of ModuleVersion protos for all the module_versions in the app.
|
|
189
|
-
"""
|
|
190
|
-
return [item for item in self.module_versions_generator(module_id, page_size)]
|
|
191
|
-
|
|
192
|
-
def module_versions_generator(self, module_id: str, page_size: int = None):
|
|
193
|
-
"""
|
|
194
|
-
This lists all the module_versions in an app. Not recommended for large apps.
|
|
195
|
-
|
|
196
|
-
Returns:
|
|
197
|
-
gen: a generator that yields a single ModuleVersion proto at a time.
|
|
198
|
-
"""
|
|
199
|
-
page_size = self.default_page_size if page_size is None else page_size
|
|
200
|
-
return module_versions_generator(self.stub, self.user_id, self.app_id, module_id, page_size)
|
clarifai_utils/listing/models.py
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
from clarifai_grpc.grpc.api import resources_pb2, service_pb2
|
|
2
|
-
from clarifai_grpc.grpc.api.status import status_code_pb2
|
|
3
|
-
|
|
4
|
-
from clarifai.client import V2Stub
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def models_generator(stub: V2Stub,
|
|
8
|
-
user_id: str,
|
|
9
|
-
app_id: str,
|
|
10
|
-
page_size: int = 64,
|
|
11
|
-
only_in_app: bool = False):
|
|
12
|
-
"""
|
|
13
|
-
Lists all the models accessible in an application given a userAppID user_id, app_id app.
|
|
14
|
-
|
|
15
|
-
Args:
|
|
16
|
-
stub: client stub.
|
|
17
|
-
user_id: the user to list from.
|
|
18
|
-
app_id: the app in the user_id account to list from.
|
|
19
|
-
page_size: the pagination size to use while iterating.
|
|
20
|
-
only_in_app: if the models returned should only be ones that have been created in the app
|
|
21
|
-
|
|
22
|
-
Returns:
|
|
23
|
-
models: a list of Model protos for all the models in the app.
|
|
24
|
-
"""
|
|
25
|
-
userDataObject = resources_pb2.UserAppIDSet(user_id=user_id, app_id=app_id)
|
|
26
|
-
|
|
27
|
-
model_success_status = {status_code_pb2.SUCCESS}
|
|
28
|
-
|
|
29
|
-
page = 1
|
|
30
|
-
while True:
|
|
31
|
-
response = stub.ListModels(
|
|
32
|
-
service_pb2.ListModelsRequest(user_app_id=userDataObject, page=page, per_page=page_size),)
|
|
33
|
-
|
|
34
|
-
if response.status.code not in model_success_status:
|
|
35
|
-
raise Exception("ListModels failed with response %r" % response)
|
|
36
|
-
if len(response.models) == 0:
|
|
37
|
-
break
|
|
38
|
-
else:
|
|
39
|
-
if only_in_app:
|
|
40
|
-
for item in response.models:
|
|
41
|
-
if item.app_id == app_id:
|
|
42
|
-
yield item
|
|
43
|
-
else:
|
|
44
|
-
for item in response.models:
|
|
45
|
-
yield item
|
|
46
|
-
page += 1
|