unstructured-ingest 0.0.0__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.
Potentially problematic release.
This version of unstructured-ingest might be problematic. Click here for more details.
- unstructured_ingest/__init__.py +1 -0
- unstructured_ingest/__version__.py +1 -0
- unstructured_ingest/cli/__init__.py +14 -0
- unstructured_ingest/cli/base/__init__.py +0 -0
- unstructured_ingest/cli/base/cmd.py +19 -0
- unstructured_ingest/cli/base/dest.py +87 -0
- unstructured_ingest/cli/base/src.py +57 -0
- unstructured_ingest/cli/cli.py +32 -0
- unstructured_ingest/cli/cmd_factory.py +12 -0
- unstructured_ingest/cli/cmds/__init__.py +145 -0
- unstructured_ingest/cli/cmds/airtable.py +69 -0
- unstructured_ingest/cli/cmds/astra.py +99 -0
- unstructured_ingest/cli/cmds/azure_cognitive_search.py +65 -0
- unstructured_ingest/cli/cmds/biomed.py +52 -0
- unstructured_ingest/cli/cmds/chroma.py +104 -0
- unstructured_ingest/cli/cmds/clarifai.py +71 -0
- unstructured_ingest/cli/cmds/confluence.py +69 -0
- unstructured_ingest/cli/cmds/databricks_volumes.py +163 -0
- unstructured_ingest/cli/cmds/delta_table.py +94 -0
- unstructured_ingest/cli/cmds/discord.py +47 -0
- unstructured_ingest/cli/cmds/elasticsearch.py +133 -0
- unstructured_ingest/cli/cmds/fsspec/__init__.py +0 -0
- unstructured_ingest/cli/cmds/fsspec/azure.py +94 -0
- unstructured_ingest/cli/cmds/fsspec/box.py +48 -0
- unstructured_ingest/cli/cmds/fsspec/dropbox.py +51 -0
- unstructured_ingest/cli/cmds/fsspec/fsspec.py +15 -0
- unstructured_ingest/cli/cmds/fsspec/gcs.py +71 -0
- unstructured_ingest/cli/cmds/fsspec/s3.py +74 -0
- unstructured_ingest/cli/cmds/fsspec/sftp.py +58 -0
- unstructured_ingest/cli/cmds/github.py +54 -0
- unstructured_ingest/cli/cmds/gitlab.py +54 -0
- unstructured_ingest/cli/cmds/google_drive.py +49 -0
- unstructured_ingest/cli/cmds/hubspot.py +70 -0
- unstructured_ingest/cli/cmds/jira.py +71 -0
- unstructured_ingest/cli/cmds/kafka.py +102 -0
- unstructured_ingest/cli/cmds/local.py +43 -0
- unstructured_ingest/cli/cmds/mongodb.py +72 -0
- unstructured_ingest/cli/cmds/notion.py +48 -0
- unstructured_ingest/cli/cmds/onedrive.py +66 -0
- unstructured_ingest/cli/cmds/opensearch.py +117 -0
- unstructured_ingest/cli/cmds/outlook.py +67 -0
- unstructured_ingest/cli/cmds/pinecone.py +71 -0
- unstructured_ingest/cli/cmds/qdrant.py +124 -0
- unstructured_ingest/cli/cmds/reddit.py +67 -0
- unstructured_ingest/cli/cmds/salesforce.py +58 -0
- unstructured_ingest/cli/cmds/sharepoint.py +66 -0
- unstructured_ingest/cli/cmds/slack.py +56 -0
- unstructured_ingest/cli/cmds/sql.py +66 -0
- unstructured_ingest/cli/cmds/vectara.py +66 -0
- unstructured_ingest/cli/cmds/weaviate.py +98 -0
- unstructured_ingest/cli/cmds/wikipedia.py +40 -0
- unstructured_ingest/cli/common.py +7 -0
- unstructured_ingest/cli/interfaces.py +656 -0
- unstructured_ingest/cli/utils.py +205 -0
- unstructured_ingest/connector/__init__.py +0 -0
- unstructured_ingest/connector/airtable.py +309 -0
- unstructured_ingest/connector/astra.py +237 -0
- unstructured_ingest/connector/azure_cognitive_search.py +144 -0
- unstructured_ingest/connector/biomed.py +313 -0
- unstructured_ingest/connector/chroma.py +158 -0
- unstructured_ingest/connector/clarifai.py +122 -0
- unstructured_ingest/connector/confluence.py +285 -0
- unstructured_ingest/connector/databricks_volumes.py +137 -0
- unstructured_ingest/connector/delta_table.py +203 -0
- unstructured_ingest/connector/discord.py +180 -0
- unstructured_ingest/connector/elasticsearch.py +396 -0
- unstructured_ingest/connector/fsspec/__init__.py +0 -0
- unstructured_ingest/connector/fsspec/azure.py +78 -0
- unstructured_ingest/connector/fsspec/box.py +109 -0
- unstructured_ingest/connector/fsspec/dropbox.py +160 -0
- unstructured_ingest/connector/fsspec/fsspec.py +359 -0
- unstructured_ingest/connector/fsspec/gcs.py +82 -0
- unstructured_ingest/connector/fsspec/s3.py +62 -0
- unstructured_ingest/connector/fsspec/sftp.py +81 -0
- unstructured_ingest/connector/git.py +124 -0
- unstructured_ingest/connector/github.py +173 -0
- unstructured_ingest/connector/gitlab.py +142 -0
- unstructured_ingest/connector/google_drive.py +349 -0
- unstructured_ingest/connector/hubspot.py +278 -0
- unstructured_ingest/connector/jira.py +469 -0
- unstructured_ingest/connector/kafka.py +294 -0
- unstructured_ingest/connector/local.py +139 -0
- unstructured_ingest/connector/mongodb.py +285 -0
- unstructured_ingest/connector/notion/__init__.py +0 -0
- unstructured_ingest/connector/notion/client.py +233 -0
- unstructured_ingest/connector/notion/connector.py +468 -0
- unstructured_ingest/connector/notion/helpers.py +584 -0
- unstructured_ingest/connector/notion/interfaces.py +32 -0
- unstructured_ingest/connector/notion/types/__init__.py +0 -0
- unstructured_ingest/connector/notion/types/block.py +95 -0
- unstructured_ingest/connector/notion/types/blocks/__init__.py +63 -0
- unstructured_ingest/connector/notion/types/blocks/bookmark.py +40 -0
- unstructured_ingest/connector/notion/types/blocks/breadcrumb.py +21 -0
- unstructured_ingest/connector/notion/types/blocks/bulleted_list_item.py +31 -0
- unstructured_ingest/connector/notion/types/blocks/callout.py +94 -0
- unstructured_ingest/connector/notion/types/blocks/child_database.py +23 -0
- unstructured_ingest/connector/notion/types/blocks/child_page.py +23 -0
- unstructured_ingest/connector/notion/types/blocks/code.py +43 -0
- unstructured_ingest/connector/notion/types/blocks/column_list.py +35 -0
- unstructured_ingest/connector/notion/types/blocks/divider.py +22 -0
- unstructured_ingest/connector/notion/types/blocks/embed.py +36 -0
- unstructured_ingest/connector/notion/types/blocks/equation.py +23 -0
- unstructured_ingest/connector/notion/types/blocks/file.py +49 -0
- unstructured_ingest/connector/notion/types/blocks/heading.py +37 -0
- unstructured_ingest/connector/notion/types/blocks/image.py +21 -0
- unstructured_ingest/connector/notion/types/blocks/link_preview.py +24 -0
- unstructured_ingest/connector/notion/types/blocks/link_to_page.py +29 -0
- unstructured_ingest/connector/notion/types/blocks/numbered_list.py +29 -0
- unstructured_ingest/connector/notion/types/blocks/paragraph.py +31 -0
- unstructured_ingest/connector/notion/types/blocks/pdf.py +49 -0
- unstructured_ingest/connector/notion/types/blocks/quote.py +37 -0
- unstructured_ingest/connector/notion/types/blocks/synced_block.py +57 -0
- unstructured_ingest/connector/notion/types/blocks/table.py +63 -0
- unstructured_ingest/connector/notion/types/blocks/table_of_contents.py +23 -0
- unstructured_ingest/connector/notion/types/blocks/template.py +30 -0
- unstructured_ingest/connector/notion/types/blocks/todo.py +42 -0
- unstructured_ingest/connector/notion/types/blocks/toggle.py +37 -0
- unstructured_ingest/connector/notion/types/blocks/unsupported.py +20 -0
- unstructured_ingest/connector/notion/types/blocks/video.py +22 -0
- unstructured_ingest/connector/notion/types/database.py +72 -0
- unstructured_ingest/connector/notion/types/database_properties/__init__.py +106 -0
- unstructured_ingest/connector/notion/types/database_properties/checkbox.py +38 -0
- unstructured_ingest/connector/notion/types/database_properties/created_by.py +35 -0
- unstructured_ingest/connector/notion/types/database_properties/created_time.py +34 -0
- unstructured_ingest/connector/notion/types/database_properties/date.py +41 -0
- unstructured_ingest/connector/notion/types/database_properties/email.py +36 -0
- unstructured_ingest/connector/notion/types/database_properties/files.py +37 -0
- unstructured_ingest/connector/notion/types/database_properties/formula.py +49 -0
- unstructured_ingest/connector/notion/types/database_properties/last_edited_by.py +34 -0
- unstructured_ingest/connector/notion/types/database_properties/last_edited_time.py +34 -0
- unstructured_ingest/connector/notion/types/database_properties/multiselect.py +73 -0
- unstructured_ingest/connector/notion/types/database_properties/number.py +49 -0
- unstructured_ingest/connector/notion/types/database_properties/people.py +40 -0
- unstructured_ingest/connector/notion/types/database_properties/phone_number.py +36 -0
- unstructured_ingest/connector/notion/types/database_properties/relation.py +67 -0
- unstructured_ingest/connector/notion/types/database_properties/rich_text.py +43 -0
- unstructured_ingest/connector/notion/types/database_properties/rollup.py +56 -0
- unstructured_ingest/connector/notion/types/database_properties/select.py +68 -0
- unstructured_ingest/connector/notion/types/database_properties/status.py +80 -0
- unstructured_ingest/connector/notion/types/database_properties/title.py +37 -0
- unstructured_ingest/connector/notion/types/database_properties/unique_id.py +50 -0
- unstructured_ingest/connector/notion/types/database_properties/url.py +37 -0
- unstructured_ingest/connector/notion/types/database_properties/verification.py +78 -0
- unstructured_ingest/connector/notion/types/date.py +26 -0
- unstructured_ingest/connector/notion/types/file.py +51 -0
- unstructured_ingest/connector/notion/types/page.py +44 -0
- unstructured_ingest/connector/notion/types/parent.py +66 -0
- unstructured_ingest/connector/notion/types/rich_text.py +189 -0
- unstructured_ingest/connector/notion/types/user.py +76 -0
- unstructured_ingest/connector/onedrive.py +232 -0
- unstructured_ingest/connector/opensearch.py +218 -0
- unstructured_ingest/connector/outlook.py +285 -0
- unstructured_ingest/connector/pinecone.py +140 -0
- unstructured_ingest/connector/qdrant.py +144 -0
- unstructured_ingest/connector/reddit.py +166 -0
- unstructured_ingest/connector/registry.py +109 -0
- unstructured_ingest/connector/salesforce.py +301 -0
- unstructured_ingest/connector/sharepoint.py +573 -0
- unstructured_ingest/connector/slack.py +224 -0
- unstructured_ingest/connector/sql.py +199 -0
- unstructured_ingest/connector/vectara.py +248 -0
- unstructured_ingest/connector/weaviate.py +190 -0
- unstructured_ingest/connector/wikipedia.py +208 -0
- unstructured_ingest/enhanced_dataclass/__init__.py +4 -0
- unstructured_ingest/enhanced_dataclass/core.py +99 -0
- unstructured_ingest/enhanced_dataclass/dataclasses.py +54 -0
- unstructured_ingest/enhanced_dataclass/json_mixin.py +125 -0
- unstructured_ingest/error.py +49 -0
- unstructured_ingest/evaluate.py +338 -0
- unstructured_ingest/ingest_backoff/__init__.py +3 -0
- unstructured_ingest/ingest_backoff/_common.py +102 -0
- unstructured_ingest/ingest_backoff/_wrapper.py +122 -0
- unstructured_ingest/interfaces.py +838 -0
- unstructured_ingest/logger.py +130 -0
- unstructured_ingest/main.py +11 -0
- unstructured_ingest/pipeline/__init__.py +22 -0
- unstructured_ingest/pipeline/copy.py +19 -0
- unstructured_ingest/pipeline/doc_factory.py +12 -0
- unstructured_ingest/pipeline/interfaces.py +265 -0
- unstructured_ingest/pipeline/partition.py +60 -0
- unstructured_ingest/pipeline/permissions.py +12 -0
- unstructured_ingest/pipeline/pipeline.py +117 -0
- unstructured_ingest/pipeline/reformat/__init__.py +0 -0
- unstructured_ingest/pipeline/reformat/chunking.py +130 -0
- unstructured_ingest/pipeline/reformat/embedding.py +66 -0
- unstructured_ingest/pipeline/source.py +77 -0
- unstructured_ingest/pipeline/utils.py +6 -0
- unstructured_ingest/pipeline/write.py +18 -0
- unstructured_ingest/processor.py +93 -0
- unstructured_ingest/runner/__init__.py +104 -0
- unstructured_ingest/runner/airtable.py +35 -0
- unstructured_ingest/runner/astra.py +34 -0
- unstructured_ingest/runner/base_runner.py +89 -0
- unstructured_ingest/runner/biomed.py +45 -0
- unstructured_ingest/runner/confluence.py +35 -0
- unstructured_ingest/runner/delta_table.py +34 -0
- unstructured_ingest/runner/discord.py +35 -0
- unstructured_ingest/runner/elasticsearch.py +40 -0
- unstructured_ingest/runner/fsspec/__init__.py +0 -0
- unstructured_ingest/runner/fsspec/azure.py +30 -0
- unstructured_ingest/runner/fsspec/box.py +28 -0
- unstructured_ingest/runner/fsspec/dropbox.py +30 -0
- unstructured_ingest/runner/fsspec/fsspec.py +40 -0
- unstructured_ingest/runner/fsspec/gcs.py +28 -0
- unstructured_ingest/runner/fsspec/s3.py +28 -0
- unstructured_ingest/runner/fsspec/sftp.py +28 -0
- unstructured_ingest/runner/github.py +37 -0
- unstructured_ingest/runner/gitlab.py +37 -0
- unstructured_ingest/runner/google_drive.py +35 -0
- unstructured_ingest/runner/hubspot.py +35 -0
- unstructured_ingest/runner/jira.py +35 -0
- unstructured_ingest/runner/kafka.py +34 -0
- unstructured_ingest/runner/local.py +23 -0
- unstructured_ingest/runner/mongodb.py +34 -0
- unstructured_ingest/runner/notion.py +61 -0
- unstructured_ingest/runner/onedrive.py +35 -0
- unstructured_ingest/runner/opensearch.py +40 -0
- unstructured_ingest/runner/outlook.py +33 -0
- unstructured_ingest/runner/reddit.py +35 -0
- unstructured_ingest/runner/salesforce.py +33 -0
- unstructured_ingest/runner/sharepoint.py +35 -0
- unstructured_ingest/runner/slack.py +33 -0
- unstructured_ingest/runner/utils.py +47 -0
- unstructured_ingest/runner/wikipedia.py +35 -0
- unstructured_ingest/runner/writers/__init__.py +48 -0
- unstructured_ingest/runner/writers/astra.py +22 -0
- unstructured_ingest/runner/writers/azure_cognitive_search.py +24 -0
- unstructured_ingest/runner/writers/base_writer.py +26 -0
- unstructured_ingest/runner/writers/chroma.py +22 -0
- unstructured_ingest/runner/writers/clarifai.py +19 -0
- unstructured_ingest/runner/writers/databricks_volumes.py +25 -0
- unstructured_ingest/runner/writers/delta_table.py +24 -0
- unstructured_ingest/runner/writers/elasticsearch.py +24 -0
- unstructured_ingest/runner/writers/fsspec/__init__.py +0 -0
- unstructured_ingest/runner/writers/fsspec/azure.py +24 -0
- unstructured_ingest/runner/writers/fsspec/box.py +21 -0
- unstructured_ingest/runner/writers/fsspec/dropbox.py +21 -0
- unstructured_ingest/runner/writers/fsspec/gcs.py +19 -0
- unstructured_ingest/runner/writers/fsspec/s3.py +21 -0
- unstructured_ingest/runner/writers/kafka.py +21 -0
- unstructured_ingest/runner/writers/mongodb.py +21 -0
- unstructured_ingest/runner/writers/opensearch.py +26 -0
- unstructured_ingest/runner/writers/pinecone.py +21 -0
- unstructured_ingest/runner/writers/qdrant.py +19 -0
- unstructured_ingest/runner/writers/sql.py +22 -0
- unstructured_ingest/runner/writers/vectara.py +22 -0
- unstructured_ingest/runner/writers/weaviate.py +21 -0
- unstructured_ingest/utils/__init__.py +0 -0
- unstructured_ingest/utils/compression.py +117 -0
- unstructured_ingest/utils/data_prep.py +112 -0
- unstructured_ingest/utils/dep_check.py +66 -0
- unstructured_ingest/utils/string_and_date_utils.py +39 -0
- unstructured_ingest/utils/table.py +73 -0
- unstructured_ingest/v2/__init__.py +1 -0
- unstructured_ingest/v2/cli/__init__.py +0 -0
- unstructured_ingest/v2/cli/base/__init__.py +4 -0
- unstructured_ingest/v2/cli/base/cmd.py +215 -0
- unstructured_ingest/v2/cli/base/dest.py +76 -0
- unstructured_ingest/v2/cli/base/importer.py +34 -0
- unstructured_ingest/v2/cli/base/src.py +70 -0
- unstructured_ingest/v2/cli/cli.py +24 -0
- unstructured_ingest/v2/cli/cmds/__init__.py +87 -0
- unstructured_ingest/v2/cli/cmds/astra.py +85 -0
- unstructured_ingest/v2/cli/cmds/azure_cognitive_search.py +72 -0
- unstructured_ingest/v2/cli/cmds/chroma.py +108 -0
- unstructured_ingest/v2/cli/cmds/databricks_volumes.py +161 -0
- unstructured_ingest/v2/cli/cmds/elasticsearch.py +159 -0
- unstructured_ingest/v2/cli/cmds/fsspec/__init__.py +0 -0
- unstructured_ingest/v2/cli/cmds/fsspec/azure.py +84 -0
- unstructured_ingest/v2/cli/cmds/fsspec/box.py +58 -0
- unstructured_ingest/v2/cli/cmds/fsspec/dropbox.py +58 -0
- unstructured_ingest/v2/cli/cmds/fsspec/fsspec.py +77 -0
- unstructured_ingest/v2/cli/cmds/fsspec/gcs.py +81 -0
- unstructured_ingest/v2/cli/cmds/fsspec/s3.py +84 -0
- unstructured_ingest/v2/cli/cmds/fsspec/sftp.py +80 -0
- unstructured_ingest/v2/cli/cmds/google_drive.py +74 -0
- unstructured_ingest/v2/cli/cmds/local.py +60 -0
- unstructured_ingest/v2/cli/cmds/mongodb.py +62 -0
- unstructured_ingest/v2/cli/cmds/onedrive.py +91 -0
- unstructured_ingest/v2/cli/cmds/opensearch.py +93 -0
- unstructured_ingest/v2/cli/cmds/pinecone.py +62 -0
- unstructured_ingest/v2/cli/cmds/salesforce.py +79 -0
- unstructured_ingest/v2/cli/cmds/sharepoint.py +112 -0
- unstructured_ingest/v2/cli/cmds/singlestore.py +96 -0
- unstructured_ingest/v2/cli/cmds/sql.py +84 -0
- unstructured_ingest/v2/cli/cmds/weaviate.py +100 -0
- unstructured_ingest/v2/cli/configs/__init__.py +6 -0
- unstructured_ingest/v2/cli/configs/chunk.py +89 -0
- unstructured_ingest/v2/cli/configs/embed.py +74 -0
- unstructured_ingest/v2/cli/configs/partition.py +99 -0
- unstructured_ingest/v2/cli/configs/processor.py +88 -0
- unstructured_ingest/v2/cli/interfaces.py +27 -0
- unstructured_ingest/v2/cli/utils.py +240 -0
- unstructured_ingest/v2/example.py +37 -0
- unstructured_ingest/v2/interfaces/__init__.py +29 -0
- unstructured_ingest/v2/interfaces/connector.py +32 -0
- unstructured_ingest/v2/interfaces/downloader.py +79 -0
- unstructured_ingest/v2/interfaces/file_data.py +49 -0
- unstructured_ingest/v2/interfaces/indexer.py +28 -0
- unstructured_ingest/v2/interfaces/process.py +20 -0
- unstructured_ingest/v2/interfaces/processor.py +48 -0
- unstructured_ingest/v2/interfaces/upload_stager.py +48 -0
- unstructured_ingest/v2/interfaces/uploader.py +39 -0
- unstructured_ingest/v2/logger.py +126 -0
- unstructured_ingest/v2/main.py +11 -0
- unstructured_ingest/v2/pipeline/__init__.py +0 -0
- unstructured_ingest/v2/pipeline/interfaces.py +167 -0
- unstructured_ingest/v2/pipeline/pipeline.py +284 -0
- unstructured_ingest/v2/pipeline/steps/__init__.py +0 -0
- unstructured_ingest/v2/pipeline/steps/chunk.py +85 -0
- unstructured_ingest/v2/pipeline/steps/download.py +124 -0
- unstructured_ingest/v2/pipeline/steps/embed.py +84 -0
- unstructured_ingest/v2/pipeline/steps/index.py +61 -0
- unstructured_ingest/v2/pipeline/steps/partition.py +78 -0
- unstructured_ingest/v2/pipeline/steps/stage.py +64 -0
- unstructured_ingest/v2/pipeline/steps/uncompress.py +68 -0
- unstructured_ingest/v2/pipeline/steps/upload.py +73 -0
- unstructured_ingest/v2/pipeline/utils.py +15 -0
- unstructured_ingest/v2/processes/__init__.py +0 -0
- unstructured_ingest/v2/processes/chunker.py +97 -0
- unstructured_ingest/v2/processes/connector_registry.py +63 -0
- unstructured_ingest/v2/processes/connectors/__init__.py +77 -0
- unstructured_ingest/v2/processes/connectors/astra.py +152 -0
- unstructured_ingest/v2/processes/connectors/azure_cognitive_search.py +211 -0
- unstructured_ingest/v2/processes/connectors/chroma.py +204 -0
- unstructured_ingest/v2/processes/connectors/databricks_volumes.py +96 -0
- unstructured_ingest/v2/processes/connectors/elasticsearch.py +401 -0
- unstructured_ingest/v2/processes/connectors/fsspec/__init__.py +37 -0
- unstructured_ingest/v2/processes/connectors/fsspec/azure.py +144 -0
- unstructured_ingest/v2/processes/connectors/fsspec/box.py +131 -0
- unstructured_ingest/v2/processes/connectors/fsspec/dropbox.py +130 -0
- unstructured_ingest/v2/processes/connectors/fsspec/fsspec.py +342 -0
- unstructured_ingest/v2/processes/connectors/fsspec/gcs.py +141 -0
- unstructured_ingest/v2/processes/connectors/fsspec/s3.py +164 -0
- unstructured_ingest/v2/processes/connectors/fsspec/sftp.py +166 -0
- unstructured_ingest/v2/processes/connectors/fsspec/utils.py +17 -0
- unstructured_ingest/v2/processes/connectors/google_drive.py +335 -0
- unstructured_ingest/v2/processes/connectors/local.py +204 -0
- unstructured_ingest/v2/processes/connectors/mongodb.py +138 -0
- unstructured_ingest/v2/processes/connectors/onedrive.py +216 -0
- unstructured_ingest/v2/processes/connectors/opensearch.py +155 -0
- unstructured_ingest/v2/processes/connectors/pinecone.py +178 -0
- unstructured_ingest/v2/processes/connectors/salesforce.py +293 -0
- unstructured_ingest/v2/processes/connectors/sharepoint.py +412 -0
- unstructured_ingest/v2/processes/connectors/singlestore.py +160 -0
- unstructured_ingest/v2/processes/connectors/sql.py +269 -0
- unstructured_ingest/v2/processes/connectors/utils.py +19 -0
- unstructured_ingest/v2/processes/connectors/weaviate.py +235 -0
- unstructured_ingest/v2/processes/embedder.py +76 -0
- unstructured_ingest/v2/processes/partitioner.py +166 -0
- unstructured_ingest/v2/processes/uncompress.py +43 -0
- unstructured_ingest-0.0.0.dist-info/METADATA +319 -0
- unstructured_ingest-0.0.0.dist-info/RECORD +356 -0
- unstructured_ingest-0.0.0.dist-info/WHEEL +5 -0
- unstructured_ingest-0.0.0.dist-info/entry_points.txt +2 -0
- unstructured_ingest-0.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
from unstructured.chunking import CHUNK_MAX_CHARS_DEFAULT, CHUNK_MULTI_PAGE_DEFAULT
|
|
5
|
+
|
|
6
|
+
from unstructured_ingest.v2.cli.interfaces import CliConfig
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class ChunkerCliConfig(CliConfig):
|
|
11
|
+
@staticmethod
|
|
12
|
+
def get_cli_options() -> list[click.Option]:
|
|
13
|
+
options = [
|
|
14
|
+
click.Option(
|
|
15
|
+
["--chunking-strategy"],
|
|
16
|
+
type=str,
|
|
17
|
+
default=None,
|
|
18
|
+
help="The rule-set to use to form chunks. Omit to disable chunking.",
|
|
19
|
+
),
|
|
20
|
+
click.Option(
|
|
21
|
+
["--chunk-combine-text-under-n-chars"],
|
|
22
|
+
type=int,
|
|
23
|
+
help=(
|
|
24
|
+
"Combine consecutive chunks when the first does not exceed this length and"
|
|
25
|
+
" the second will fit without exceeding the hard-maximum length. Only"
|
|
26
|
+
" operative for 'by_title' chunking-strategy."
|
|
27
|
+
),
|
|
28
|
+
),
|
|
29
|
+
click.Option(
|
|
30
|
+
["--chunk-include-orig-elements/--chunk-no-include-orig-elements"],
|
|
31
|
+
is_flag=True,
|
|
32
|
+
default=True,
|
|
33
|
+
help=(
|
|
34
|
+
"When chunking, add the original elements consolidated to form each chunk to"
|
|
35
|
+
" `.metadata.orig_elements` on that chunk."
|
|
36
|
+
),
|
|
37
|
+
),
|
|
38
|
+
click.Option(
|
|
39
|
+
["--chunk-max-characters"],
|
|
40
|
+
type=int,
|
|
41
|
+
default=CHUNK_MAX_CHARS_DEFAULT,
|
|
42
|
+
show_default=True,
|
|
43
|
+
help=(
|
|
44
|
+
"Hard maximum chunk length. No chunk will exceed this length. An oversized"
|
|
45
|
+
" element will be divided by text-splitting to fit this window."
|
|
46
|
+
),
|
|
47
|
+
),
|
|
48
|
+
click.Option(
|
|
49
|
+
["--chunk-multipage-sections/--chunk-no-multipage-sections"],
|
|
50
|
+
is_flag=True,
|
|
51
|
+
default=CHUNK_MULTI_PAGE_DEFAULT,
|
|
52
|
+
help=(
|
|
53
|
+
"Ignore page boundaries when chunking such that elements from two different"
|
|
54
|
+
" pages can appear in the same chunk. Only operative for 'by_title'"
|
|
55
|
+
" chunking-strategy."
|
|
56
|
+
),
|
|
57
|
+
),
|
|
58
|
+
click.Option(
|
|
59
|
+
["--chunk-new-after-n-chars"],
|
|
60
|
+
type=int,
|
|
61
|
+
help=(
|
|
62
|
+
"Soft-maximum chunk length. Another element will not be added to a chunk of"
|
|
63
|
+
" this length even when it would fit without exceeding the hard-maximum"
|
|
64
|
+
" length."
|
|
65
|
+
),
|
|
66
|
+
),
|
|
67
|
+
click.Option(
|
|
68
|
+
["--chunk-overlap"],
|
|
69
|
+
type=int,
|
|
70
|
+
default=0,
|
|
71
|
+
show_default=True,
|
|
72
|
+
help=(
|
|
73
|
+
"Prefix chunk text with last overlap=N characters of prior chunk. Only"
|
|
74
|
+
" applies to oversized chunks divided by text-splitting. To apply overlap to"
|
|
75
|
+
" non-oversized chunks use the --overlap-all option."
|
|
76
|
+
),
|
|
77
|
+
),
|
|
78
|
+
click.Option(
|
|
79
|
+
["--chunk-overlap-all"],
|
|
80
|
+
is_flag=True,
|
|
81
|
+
default=False,
|
|
82
|
+
help=(
|
|
83
|
+
"Apply overlap to chunks formed from whole elements as well as those formed"
|
|
84
|
+
" by text-splitting oversized elements. Overlap length is take from --overlap"
|
|
85
|
+
" option value."
|
|
86
|
+
),
|
|
87
|
+
),
|
|
88
|
+
]
|
|
89
|
+
return options
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import click
|
|
5
|
+
from dataclasses_json.core import Json
|
|
6
|
+
from unstructured.embed import EMBEDDING_PROVIDER_TO_CLASS_MAP
|
|
7
|
+
|
|
8
|
+
from unstructured_ingest.v2.cli.interfaces import CliConfig
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass
|
|
12
|
+
class EmbedderCliConfig(CliConfig):
|
|
13
|
+
@staticmethod
|
|
14
|
+
def get_cli_options() -> list[click.Option]:
|
|
15
|
+
options = [
|
|
16
|
+
click.Option(
|
|
17
|
+
["--embedding-provider"],
|
|
18
|
+
help="Type of the embedding class to be used. Can be one of: "
|
|
19
|
+
f"{list(EMBEDDING_PROVIDER_TO_CLASS_MAP)}",
|
|
20
|
+
type=click.Choice(list(EMBEDDING_PROVIDER_TO_CLASS_MAP)),
|
|
21
|
+
),
|
|
22
|
+
click.Option(
|
|
23
|
+
["--embedding-api-key"],
|
|
24
|
+
help="API key for the embedding model, for the case an API key is needed.",
|
|
25
|
+
type=str,
|
|
26
|
+
default=None,
|
|
27
|
+
),
|
|
28
|
+
click.Option(
|
|
29
|
+
["--embedding-model-name"],
|
|
30
|
+
help="Embedding model name, if needed. "
|
|
31
|
+
"Chooses a particular LLM between different options, to embed with it.",
|
|
32
|
+
type=str,
|
|
33
|
+
default=None,
|
|
34
|
+
),
|
|
35
|
+
click.Option(
|
|
36
|
+
["--embedding-aws-access-key-id"],
|
|
37
|
+
help="AWS access key used for AWS-based embedders, such as bedrock",
|
|
38
|
+
type=str,
|
|
39
|
+
default=None,
|
|
40
|
+
),
|
|
41
|
+
click.Option(
|
|
42
|
+
["--embedding-aws-secret-access-key"],
|
|
43
|
+
help="AWS secret key used for AWS-based embedders, such as bedrock",
|
|
44
|
+
type=str,
|
|
45
|
+
default=None,
|
|
46
|
+
),
|
|
47
|
+
click.Option(
|
|
48
|
+
["--embedding-aws-region"],
|
|
49
|
+
help="AWS region used for AWS-based embedders, such as bedrock",
|
|
50
|
+
type=str,
|
|
51
|
+
default="us-west-2",
|
|
52
|
+
),
|
|
53
|
+
]
|
|
54
|
+
return options
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def from_dict(cls, kvs: Json, **kwargs: Any):
|
|
58
|
+
"""
|
|
59
|
+
Extension of the dataclass from_dict() to avoid a naming conflict with other CLI params.
|
|
60
|
+
This allows CLI arguments to be prepended with embedding_ during CLI invocation but
|
|
61
|
+
doesn't require that as part of the field names in this class
|
|
62
|
+
"""
|
|
63
|
+
if isinstance(kvs, dict):
|
|
64
|
+
new_kvs = {
|
|
65
|
+
k[len("embedding_") :]: v # noqa: E203
|
|
66
|
+
for k, v in kvs.items()
|
|
67
|
+
if k.startswith("embedding_")
|
|
68
|
+
}
|
|
69
|
+
if len(new_kvs.keys()) == 0:
|
|
70
|
+
return None
|
|
71
|
+
if not new_kvs.get("provider"):
|
|
72
|
+
return None
|
|
73
|
+
return super().from_dict(new_kvs, **kwargs)
|
|
74
|
+
return super().from_dict(kvs, **kwargs)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from unstructured_ingest.v2.cli.interfaces import CliConfig
|
|
6
|
+
from unstructured_ingest.v2.cli.utils import DelimitedString, Dict
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class PartitionerCliConfig(CliConfig):
|
|
11
|
+
@staticmethod
|
|
12
|
+
def get_cli_options() -> list[click.Option]:
|
|
13
|
+
options = [
|
|
14
|
+
click.Option(
|
|
15
|
+
["--strategy"],
|
|
16
|
+
default="auto",
|
|
17
|
+
help="The method that will be used to process the documents. "
|
|
18
|
+
"Default: auto. Other strategies include `fast` and `hi_res`.",
|
|
19
|
+
),
|
|
20
|
+
click.Option(
|
|
21
|
+
["--ocr-languages"],
|
|
22
|
+
default=None,
|
|
23
|
+
type=DelimitedString(delimiter="+"),
|
|
24
|
+
help="A list of language packs to specify which languages to use for OCR, "
|
|
25
|
+
"separated by '+' e.g. 'eng+deu' to use the English and German language packs. "
|
|
26
|
+
"The appropriate Tesseract "
|
|
27
|
+
"language pack needs to be installed.",
|
|
28
|
+
),
|
|
29
|
+
click.Option(
|
|
30
|
+
["--encoding"],
|
|
31
|
+
default=None,
|
|
32
|
+
help="Text encoding to use when reading documents. By default the encoding is "
|
|
33
|
+
"detected automatically.",
|
|
34
|
+
),
|
|
35
|
+
click.Option(
|
|
36
|
+
["--skip-infer-table-types"],
|
|
37
|
+
type=DelimitedString(),
|
|
38
|
+
default=None,
|
|
39
|
+
help="Optional list of document types to skip table extraction on",
|
|
40
|
+
),
|
|
41
|
+
click.Option(
|
|
42
|
+
["--additional-partition-args"],
|
|
43
|
+
type=Dict(),
|
|
44
|
+
help="A json string representation of values to pass through to partition()",
|
|
45
|
+
),
|
|
46
|
+
click.Option(
|
|
47
|
+
["--fields-include"],
|
|
48
|
+
type=DelimitedString(),
|
|
49
|
+
default=["element_id", "text", "type", "metadata", "embeddings"],
|
|
50
|
+
help="Comma-delimited list. If set, include the specified top-level "
|
|
51
|
+
"fields in an element.",
|
|
52
|
+
),
|
|
53
|
+
click.Option(
|
|
54
|
+
["--flatten-metadata"],
|
|
55
|
+
is_flag=True,
|
|
56
|
+
default=False,
|
|
57
|
+
help="Results in flattened json elements. "
|
|
58
|
+
"Specifically, the metadata key values are brought to "
|
|
59
|
+
"the top-level of the element, and the `metadata` key itself is removed.",
|
|
60
|
+
),
|
|
61
|
+
click.Option(
|
|
62
|
+
["--metadata-include"],
|
|
63
|
+
default=[],
|
|
64
|
+
type=DelimitedString(),
|
|
65
|
+
help="Comma-delimited list. If set, include the specified metadata "
|
|
66
|
+
"fields if they exist and drop all other fields. ",
|
|
67
|
+
),
|
|
68
|
+
click.Option(
|
|
69
|
+
["--metadata-exclude"],
|
|
70
|
+
default=[],
|
|
71
|
+
type=DelimitedString(),
|
|
72
|
+
help="Comma-delimited list. If set, drop the specified metadata "
|
|
73
|
+
"fields if they exist.",
|
|
74
|
+
),
|
|
75
|
+
click.Option(
|
|
76
|
+
["--partition-by-api"],
|
|
77
|
+
is_flag=True,
|
|
78
|
+
default=False,
|
|
79
|
+
help="Use a remote API to partition the files."
|
|
80
|
+
" Otherwise, use the function from partition.auto",
|
|
81
|
+
),
|
|
82
|
+
click.Option(
|
|
83
|
+
["--partition-endpoint"],
|
|
84
|
+
default="https://api.unstructured.io/general/v0/general",
|
|
85
|
+
help="If partitioning via api, use the following host. "
|
|
86
|
+
"Default: https://api.unstructured.io/general/v0/general",
|
|
87
|
+
),
|
|
88
|
+
click.Option(
|
|
89
|
+
["--api-key"],
|
|
90
|
+
default=None,
|
|
91
|
+
help="API Key for partition endpoint.",
|
|
92
|
+
),
|
|
93
|
+
click.Option(
|
|
94
|
+
["--hi-res-model-name"],
|
|
95
|
+
default=None,
|
|
96
|
+
help="Model name for hi-res strategy.",
|
|
97
|
+
),
|
|
98
|
+
]
|
|
99
|
+
return options
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from unstructured_ingest.v2.cli.interfaces import CliConfig
|
|
6
|
+
from unstructured_ingest.v2.interfaces.processor import DEFAULT_WORK_DIR
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class ProcessorCliConfig(CliConfig):
|
|
11
|
+
@staticmethod
|
|
12
|
+
def get_cli_options() -> list[click.Option]:
|
|
13
|
+
options = [
|
|
14
|
+
click.Option(
|
|
15
|
+
["--reprocess"],
|
|
16
|
+
is_flag=True,
|
|
17
|
+
default=False,
|
|
18
|
+
help="Reprocess a downloaded file even if the relevant structured "
|
|
19
|
+
"output .json file in output directory already exists.",
|
|
20
|
+
),
|
|
21
|
+
click.Option(
|
|
22
|
+
["--work-dir"],
|
|
23
|
+
type=str,
|
|
24
|
+
default=DEFAULT_WORK_DIR,
|
|
25
|
+
show_default=True,
|
|
26
|
+
help="Where to place working files when processing each step",
|
|
27
|
+
),
|
|
28
|
+
click.Option(
|
|
29
|
+
["--num-processes"],
|
|
30
|
+
default=2,
|
|
31
|
+
show_default=True,
|
|
32
|
+
type=click.IntRange(min=1),
|
|
33
|
+
help="Number of parallel processes with which to process docs",
|
|
34
|
+
),
|
|
35
|
+
click.Option(
|
|
36
|
+
["--max-connections"],
|
|
37
|
+
default=None,
|
|
38
|
+
show_default=True,
|
|
39
|
+
type=click.IntRange(min=1),
|
|
40
|
+
help="Max number of connections allowed when running an async step",
|
|
41
|
+
),
|
|
42
|
+
click.Option(
|
|
43
|
+
["--raise-on-error"],
|
|
44
|
+
is_flag=True,
|
|
45
|
+
default=False,
|
|
46
|
+
help="Is set, will raise error if any doc in the pipeline fail. Otherwise will "
|
|
47
|
+
"log error and continue with other docs",
|
|
48
|
+
),
|
|
49
|
+
click.Option(
|
|
50
|
+
["--re-download"],
|
|
51
|
+
is_flag=True,
|
|
52
|
+
default=False,
|
|
53
|
+
help="Re-download files even if they are already present in download dir.",
|
|
54
|
+
),
|
|
55
|
+
click.Option(
|
|
56
|
+
["--preserve-downloads"],
|
|
57
|
+
is_flag=True,
|
|
58
|
+
default=False,
|
|
59
|
+
help="Preserve downloaded files. Otherwise each file is removed "
|
|
60
|
+
"after being processed successfully.",
|
|
61
|
+
),
|
|
62
|
+
click.Option(
|
|
63
|
+
["--download-only"],
|
|
64
|
+
is_flag=True,
|
|
65
|
+
default=False,
|
|
66
|
+
help="Download any files that are not already present in either --download-dir or "
|
|
67
|
+
"the default download ~/.cache/... location in case --download-dir "
|
|
68
|
+
"is not specified and "
|
|
69
|
+
"skip processing them through unstructured.",
|
|
70
|
+
),
|
|
71
|
+
click.Option(
|
|
72
|
+
["--max-docs"],
|
|
73
|
+
default=None,
|
|
74
|
+
type=int,
|
|
75
|
+
help="If specified, process at most the specified number of documents.",
|
|
76
|
+
),
|
|
77
|
+
click.Option(
|
|
78
|
+
["--uncompress"],
|
|
79
|
+
type=bool,
|
|
80
|
+
default=False,
|
|
81
|
+
is_flag=True,
|
|
82
|
+
help="Uncompress any archived files. Currently supporting zip and tar "
|
|
83
|
+
"files based on file extension.",
|
|
84
|
+
),
|
|
85
|
+
click.Option(["--verbose"], is_flag=True, default=False),
|
|
86
|
+
click.Option(["--tqdm"], is_flag=True, default=False, help="Show progress bar"),
|
|
87
|
+
]
|
|
88
|
+
return options
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CliConfig(ABC):
|
|
7
|
+
@staticmethod
|
|
8
|
+
@abstractmethod
|
|
9
|
+
def get_cli_options() -> list[click.Option]:
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
@classmethod
|
|
13
|
+
def add_cli_options(cls, cmd: click.Command) -> None:
|
|
14
|
+
options_to_add = cls.get_cli_options()
|
|
15
|
+
CliConfig.add_params(cmd, params=options_to_add)
|
|
16
|
+
|
|
17
|
+
@staticmethod
|
|
18
|
+
def add_params(cmd: click.Command, params: list[click.Parameter]):
|
|
19
|
+
existing_opts = []
|
|
20
|
+
for param in cmd.params:
|
|
21
|
+
existing_opts.extend(param.opts)
|
|
22
|
+
for param in params:
|
|
23
|
+
for opt in param.opts:
|
|
24
|
+
if opt in existing_opts:
|
|
25
|
+
raise ValueError(f"{opt} is already defined on the command {cmd.name}")
|
|
26
|
+
existing_opts.append(opt)
|
|
27
|
+
cmd.params.append(param)
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os.path
|
|
3
|
+
import sys
|
|
4
|
+
from dataclasses import fields, is_dataclass
|
|
5
|
+
from gettext import gettext, ngettext
|
|
6
|
+
from gettext import gettext as _
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any, ForwardRef, Optional, Type, TypeVar, Union, get_args, get_origin
|
|
9
|
+
|
|
10
|
+
import click
|
|
11
|
+
|
|
12
|
+
from unstructured_ingest.enhanced_dataclass import EnhancedDataClassJsonMixin
|
|
13
|
+
from unstructured_ingest.v2.logger import logger
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def conform_click_options(options: dict):
|
|
17
|
+
# Click sets all multiple fields as tuple, this needs to be updated to list
|
|
18
|
+
for k, v in options.items():
|
|
19
|
+
if isinstance(v, tuple):
|
|
20
|
+
options[k] = list(v)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Dict(click.ParamType):
|
|
24
|
+
name = "dict"
|
|
25
|
+
|
|
26
|
+
def convert(
|
|
27
|
+
self,
|
|
28
|
+
value: Any,
|
|
29
|
+
param: Optional[click.Parameter] = None,
|
|
30
|
+
ctx: Optional[click.Context] = None,
|
|
31
|
+
) -> Any:
|
|
32
|
+
try:
|
|
33
|
+
return json.loads(value)
|
|
34
|
+
except json.JSONDecodeError:
|
|
35
|
+
self.fail(
|
|
36
|
+
gettext(
|
|
37
|
+
"{value} is not a valid json value.",
|
|
38
|
+
).format(value=value),
|
|
39
|
+
param,
|
|
40
|
+
ctx,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class FileOrJson(click.ParamType):
|
|
45
|
+
name = "file-or-json"
|
|
46
|
+
|
|
47
|
+
def __init__(self, allow_raw_str: bool = False):
|
|
48
|
+
self.allow_raw_str = allow_raw_str
|
|
49
|
+
|
|
50
|
+
def convert(
|
|
51
|
+
self,
|
|
52
|
+
value: Any,
|
|
53
|
+
param: Optional[click.Parameter] = None,
|
|
54
|
+
ctx: Optional[click.Context] = None,
|
|
55
|
+
) -> Any:
|
|
56
|
+
# check if valid file
|
|
57
|
+
full_path = os.path.abspath(os.path.expanduser(value))
|
|
58
|
+
if os.path.isfile(full_path):
|
|
59
|
+
return str(Path(full_path).resolve())
|
|
60
|
+
if isinstance(value, str):
|
|
61
|
+
try:
|
|
62
|
+
return json.loads(value)
|
|
63
|
+
except json.JSONDecodeError:
|
|
64
|
+
if self.allow_raw_str:
|
|
65
|
+
return value
|
|
66
|
+
self.fail(
|
|
67
|
+
gettext(
|
|
68
|
+
"{value} is not a valid json string nor an existing filepath.",
|
|
69
|
+
).format(value=value),
|
|
70
|
+
param,
|
|
71
|
+
ctx,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class DelimitedString(click.ParamType):
|
|
76
|
+
name = "delimited-string"
|
|
77
|
+
|
|
78
|
+
def __init__(self, delimiter: str = ",", choices: Optional[list[str]] = None):
|
|
79
|
+
self.choices = choices if choices else []
|
|
80
|
+
self.delimiter = delimiter
|
|
81
|
+
|
|
82
|
+
def convert(
|
|
83
|
+
self,
|
|
84
|
+
value: Any,
|
|
85
|
+
param: Optional[click.Parameter] = None,
|
|
86
|
+
ctx: Optional[click.Context] = None,
|
|
87
|
+
) -> Any:
|
|
88
|
+
# In case a list is provided as the default, will not break
|
|
89
|
+
if isinstance(value, list):
|
|
90
|
+
split = [str(v).strip() for v in value]
|
|
91
|
+
else:
|
|
92
|
+
split = [v.strip() for v in value.split(self.delimiter)]
|
|
93
|
+
if not self.choices:
|
|
94
|
+
return split
|
|
95
|
+
choices_str = ", ".join(map(repr, self.choices))
|
|
96
|
+
for s in split:
|
|
97
|
+
if s not in self.choices:
|
|
98
|
+
self.fail(
|
|
99
|
+
ngettext(
|
|
100
|
+
"{value!r} is not {choice}.",
|
|
101
|
+
"{value!r} is not one of {choices}.",
|
|
102
|
+
len(self.choices),
|
|
103
|
+
).format(value=s, choice=choices_str, choices=choices_str),
|
|
104
|
+
param,
|
|
105
|
+
ctx,
|
|
106
|
+
)
|
|
107
|
+
return split
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
EnhancedDataClassJsonMixinT = TypeVar(
|
|
111
|
+
"EnhancedDataClassJsonMixinT", bound=EnhancedDataClassJsonMixin
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def extract_config(
|
|
116
|
+
flat_data: dict, config: Type[EnhancedDataClassJsonMixinT]
|
|
117
|
+
) -> EnhancedDataClassJsonMixinT:
|
|
118
|
+
"""
|
|
119
|
+
To be able to extract a nested dataclass from a flat dictionary (as in one coming
|
|
120
|
+
from a click-based options input), the config class is dynamically looked through for
|
|
121
|
+
nested dataclass fields and new nested dictionaries are created to conform to the
|
|
122
|
+
shape the overall class expects when parsing from a dict. During the process, this will create
|
|
123
|
+
copies of the original dictionary to avoid pruning fields but this isn't a
|
|
124
|
+
problem since the `from_dict()` method ignores unneeded values.
|
|
125
|
+
|
|
126
|
+
Not handling more complex edge cases for now such as nested types i.e Union[List[List[...]]]
|
|
127
|
+
"""
|
|
128
|
+
|
|
129
|
+
def conform_dict(inner_d: dict, inner_config: Type[EnhancedDataClassJsonMixinT]):
|
|
130
|
+
# Catch edge cases (i.e. Dict[str, ...]) where underlying type is not a concrete Class,
|
|
131
|
+
# causing 'issubclass() arg 1 must be a class' errors, return False
|
|
132
|
+
def is_subclass(instance, class_type) -> bool:
|
|
133
|
+
try:
|
|
134
|
+
return issubclass(instance, class_type)
|
|
135
|
+
except Exception:
|
|
136
|
+
return False
|
|
137
|
+
|
|
138
|
+
dd = inner_d.copy()
|
|
139
|
+
for field in fields(inner_config):
|
|
140
|
+
f_type = field.type
|
|
141
|
+
# typing can be defined using a string, in which case it needs to be resolved
|
|
142
|
+
# to the actual type. following logic is cherry picked from the typing
|
|
143
|
+
# get_type_hints() since type resolution can be expensive, only do it
|
|
144
|
+
# when the type is a string
|
|
145
|
+
if isinstance(f_type, str):
|
|
146
|
+
try:
|
|
147
|
+
base_globals = sys.modules[inner_config.__module__].__dict__
|
|
148
|
+
for_ref = ForwardRef(f_type, is_argument=False, is_class=True)
|
|
149
|
+
f_type = for_ref._evaluate(
|
|
150
|
+
globalns=base_globals, localns=None, recursive_guard=frozenset()
|
|
151
|
+
)
|
|
152
|
+
except NameError as e:
|
|
153
|
+
logger.warning(f"couldn't resolve type {f_type}: {e}")
|
|
154
|
+
# Handle the case where the type of a value if a Union (possibly optional)
|
|
155
|
+
if get_origin(f_type) is Union:
|
|
156
|
+
union_values = get_args(f_type)
|
|
157
|
+
# handle List types
|
|
158
|
+
union_values = [
|
|
159
|
+
get_args(u)[0] if get_origin(u) is list else u for u in union_values
|
|
160
|
+
]
|
|
161
|
+
# Ignore injected NoneType when optional
|
|
162
|
+
concrete_union_values = [v for v in union_values if not is_subclass(v, type(None))]
|
|
163
|
+
dataclass_union_values = [v for v in concrete_union_values if is_dataclass(v)]
|
|
164
|
+
non_dataclass_union_values = [
|
|
165
|
+
v for v in concrete_union_values if not is_dataclass(v)
|
|
166
|
+
]
|
|
167
|
+
if not dataclass_union_values:
|
|
168
|
+
continue
|
|
169
|
+
# Check if the key for this field already exists in the dictionary,
|
|
170
|
+
# if so it might map to one of these non dataclass fields and this
|
|
171
|
+
# can't be enforced
|
|
172
|
+
if non_dataclass_union_values and field.name in dd:
|
|
173
|
+
continue
|
|
174
|
+
if len(dataclass_union_values) > 1:
|
|
175
|
+
logger.warning(
|
|
176
|
+
"more than one dataclass type possible for field {}, "
|
|
177
|
+
"not extracting: {}".format(field.name, ", ".join(dataclass_union_values))
|
|
178
|
+
)
|
|
179
|
+
continue
|
|
180
|
+
f_type = dataclass_union_values[0]
|
|
181
|
+
origin = get_origin(f_type)
|
|
182
|
+
if origin:
|
|
183
|
+
f_type = origin
|
|
184
|
+
if is_subclass(f_type, EnhancedDataClassJsonMixin):
|
|
185
|
+
dd[field.name] = conform_dict(inner_d=dd, inner_config=f_type)
|
|
186
|
+
return dd
|
|
187
|
+
|
|
188
|
+
adjusted_dict = conform_dict(inner_d=flat_data, inner_config=config)
|
|
189
|
+
return config.from_dict(adjusted_dict, apply_name_overload=False)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
class Group(click.Group):
|
|
193
|
+
def parse_args(self, ctx, args):
|
|
194
|
+
"""
|
|
195
|
+
This allows for subcommands to be called with the --help flag without breaking
|
|
196
|
+
if parent command is missing any of its required parameters
|
|
197
|
+
"""
|
|
198
|
+
|
|
199
|
+
try:
|
|
200
|
+
return super().parse_args(ctx, args)
|
|
201
|
+
except click.MissingParameter:
|
|
202
|
+
if "--help" not in args:
|
|
203
|
+
raise
|
|
204
|
+
|
|
205
|
+
# remove the required params so that help can display
|
|
206
|
+
for param in self.params:
|
|
207
|
+
param.required = False
|
|
208
|
+
return super().parse_args(ctx, args)
|
|
209
|
+
|
|
210
|
+
def format_commands(self, ctx: click.Context, formatter: click.HelpFormatter) -> None:
|
|
211
|
+
"""
|
|
212
|
+
Copy of the original click.Group format_commands() method but replacing
|
|
213
|
+
'Commands' -> 'Destinations'
|
|
214
|
+
"""
|
|
215
|
+
commands = []
|
|
216
|
+
for subcommand in self.list_commands(ctx):
|
|
217
|
+
cmd = self.get_command(ctx, subcommand)
|
|
218
|
+
# What is this, the tool lied about a command. Ignore it
|
|
219
|
+
if cmd is None:
|
|
220
|
+
continue
|
|
221
|
+
if cmd.hidden:
|
|
222
|
+
continue
|
|
223
|
+
|
|
224
|
+
commands.append((subcommand, cmd))
|
|
225
|
+
|
|
226
|
+
# allow for 3 times the default spacing
|
|
227
|
+
if len(commands):
|
|
228
|
+
if formatter.width:
|
|
229
|
+
limit = formatter.width - 6 - max(len(cmd[0]) for cmd in commands)
|
|
230
|
+
else:
|
|
231
|
+
limit = -6 - max(len(cmd[0]) for cmd in commands)
|
|
232
|
+
|
|
233
|
+
rows = []
|
|
234
|
+
for subcommand, cmd in commands:
|
|
235
|
+
help = cmd.get_short_help_str(limit)
|
|
236
|
+
rows.append((subcommand, help))
|
|
237
|
+
|
|
238
|
+
if rows:
|
|
239
|
+
with formatter.section(_("Destinations")):
|
|
240
|
+
formatter.write_dl(rows)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from unstructured_ingest.v2.interfaces import ProcessorConfig
|
|
4
|
+
from unstructured_ingest.v2.logger import logger
|
|
5
|
+
from unstructured_ingest.v2.pipeline.pipeline import Pipeline
|
|
6
|
+
from unstructured_ingest.v2.processes.chunker import ChunkerConfig
|
|
7
|
+
from unstructured_ingest.v2.processes.connectors.fsspec.s3 import (
|
|
8
|
+
S3ConnectionConfig,
|
|
9
|
+
S3DownloaderConfig,
|
|
10
|
+
S3IndexerConfig,
|
|
11
|
+
)
|
|
12
|
+
from unstructured_ingest.v2.processes.connectors.local import (
|
|
13
|
+
LocalUploaderConfig,
|
|
14
|
+
)
|
|
15
|
+
from unstructured_ingest.v2.processes.embedder import EmbedderConfig
|
|
16
|
+
from unstructured_ingest.v2.processes.partitioner import PartitionerConfig
|
|
17
|
+
|
|
18
|
+
base_path = Path(__file__).parent.parent.parent.parent
|
|
19
|
+
docs_path = base_path / "example-docs"
|
|
20
|
+
work_dir = base_path / "tmp_ingest"
|
|
21
|
+
output_path = work_dir / "output"
|
|
22
|
+
download_path = work_dir / "download"
|
|
23
|
+
|
|
24
|
+
if __name__ == "__main__":
|
|
25
|
+
logger.info(f"Writing all content in: {work_dir.resolve()}")
|
|
26
|
+
Pipeline.from_configs(
|
|
27
|
+
context=ProcessorConfig(
|
|
28
|
+
work_dir=str(work_dir.resolve()), tqdm=True, reprocess=True, verbose=True
|
|
29
|
+
),
|
|
30
|
+
indexer_config=S3IndexerConfig(remote_url="s3://utic-dev-tech-fixtures/small-pdf-set/"),
|
|
31
|
+
downloader_config=S3DownloaderConfig(download_dir=download_path),
|
|
32
|
+
source_connection_config=S3ConnectionConfig(anonymous=True),
|
|
33
|
+
partitioner_config=PartitionerConfig(strategy="fast"),
|
|
34
|
+
chunker_config=ChunkerConfig(chunking_strategy="by_title"),
|
|
35
|
+
embedder_config=EmbedderConfig(embedding_provider="langchain-huggingface"),
|
|
36
|
+
uploader_config=LocalUploaderConfig(output_dir=str(output_path.resolve())),
|
|
37
|
+
).run()
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from .connector import AccessConfig, BaseConnector, ConnectionConfig
|
|
2
|
+
from .downloader import Downloader, DownloaderConfig, DownloadResponse, download_responses
|
|
3
|
+
from .file_data import FileData, SourceIdentifiers
|
|
4
|
+
from .indexer import Indexer, IndexerConfig
|
|
5
|
+
from .process import BaseProcess
|
|
6
|
+
from .processor import ProcessorConfig
|
|
7
|
+
from .upload_stager import UploadStager, UploadStagerConfig
|
|
8
|
+
from .uploader import UploadContent, Uploader, UploaderConfig
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"DownloadResponse",
|
|
12
|
+
"download_responses",
|
|
13
|
+
"Downloader",
|
|
14
|
+
"DownloaderConfig",
|
|
15
|
+
"FileData",
|
|
16
|
+
"Indexer",
|
|
17
|
+
"IndexerConfig",
|
|
18
|
+
"BaseProcess",
|
|
19
|
+
"ProcessorConfig",
|
|
20
|
+
"UploadStager",
|
|
21
|
+
"UploadStagerConfig",
|
|
22
|
+
"Uploader",
|
|
23
|
+
"UploaderConfig",
|
|
24
|
+
"SourceIdentifiers",
|
|
25
|
+
"UploadContent",
|
|
26
|
+
"AccessConfig",
|
|
27
|
+
"ConnectionConfig",
|
|
28
|
+
"BaseConnector",
|
|
29
|
+
]
|