unstructured-ingest 0.3.13__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.
- test/__init__.py +0 -0
- test/integration/__init__.py +0 -0
- test/integration/chunkers/__init__.py +0 -0
- test/integration/chunkers/test_chunkers.py +31 -0
- test/integration/connectors/__init__.py +0 -0
- test/integration/connectors/conftest.py +38 -0
- test/integration/connectors/databricks/__init__.py +0 -0
- test/integration/connectors/databricks/test_volumes_native.py +269 -0
- test/integration/connectors/discord/__init__.py +0 -0
- test/integration/connectors/discord/test_discord.py +90 -0
- test/integration/connectors/duckdb/__init__.py +0 -0
- test/integration/connectors/duckdb/conftest.py +14 -0
- test/integration/connectors/duckdb/test_duckdb.py +89 -0
- test/integration/connectors/duckdb/test_motherduck.py +95 -0
- test/integration/connectors/elasticsearch/__init__.py +0 -0
- test/integration/connectors/elasticsearch/conftest.py +34 -0
- test/integration/connectors/elasticsearch/test_elasticsearch.py +330 -0
- test/integration/connectors/elasticsearch/test_opensearch.py +325 -0
- test/integration/connectors/sql/__init__.py +0 -0
- test/integration/connectors/sql/test_postgres.py +195 -0
- test/integration/connectors/sql/test_singlestore.py +176 -0
- test/integration/connectors/sql/test_snowflake.py +238 -0
- test/integration/connectors/sql/test_sqlite.py +162 -0
- test/integration/connectors/test_astradb.py +217 -0
- test/integration/connectors/test_azure_ai_search.py +255 -0
- test/integration/connectors/test_chroma.py +120 -0
- test/integration/connectors/test_confluence.py +113 -0
- test/integration/connectors/test_delta_table.py +185 -0
- test/integration/connectors/test_lancedb.py +247 -0
- test/integration/connectors/test_milvus.py +203 -0
- test/integration/connectors/test_mongodb.py +335 -0
- test/integration/connectors/test_neo4j.py +236 -0
- test/integration/connectors/test_notion.py +145 -0
- test/integration/connectors/test_onedrive.py +118 -0
- test/integration/connectors/test_pinecone.py +288 -0
- test/integration/connectors/test_qdrant.py +215 -0
- test/integration/connectors/test_redis.py +119 -0
- test/integration/connectors/test_s3.py +183 -0
- test/integration/connectors/test_vectara.py +270 -0
- test/integration/connectors/utils/__init__.py +0 -0
- test/integration/connectors/utils/constants.py +7 -0
- test/integration/connectors/utils/docker.py +151 -0
- test/integration/connectors/utils/docker_compose.py +59 -0
- test/integration/connectors/utils/validation/__init__.py +0 -0
- test/integration/connectors/utils/validation/destination.py +75 -0
- test/integration/connectors/utils/validation/equality.py +75 -0
- test/integration/connectors/utils/validation/source.py +299 -0
- test/integration/connectors/utils/validation/utils.py +36 -0
- test/integration/connectors/weaviate/__init__.py +0 -0
- test/integration/connectors/weaviate/conftest.py +15 -0
- test/integration/connectors/weaviate/test_cloud.py +34 -0
- test/integration/connectors/weaviate/test_local.py +131 -0
- test/integration/embedders/__init__.py +0 -0
- test/integration/embedders/conftest.py +13 -0
- test/integration/embedders/test_azure_openai.py +59 -0
- test/integration/embedders/test_bedrock.py +103 -0
- test/integration/embedders/test_huggingface.py +26 -0
- test/integration/embedders/test_mixedbread.py +71 -0
- test/integration/embedders/test_octoai.py +77 -0
- test/integration/embedders/test_openai.py +76 -0
- test/integration/embedders/test_togetherai.py +71 -0
- test/integration/embedders/test_vertexai.py +65 -0
- test/integration/embedders/test_voyageai.py +65 -0
- test/integration/embedders/utils.py +68 -0
- test/integration/partitioners/__init__.py +0 -0
- test/integration/partitioners/test_partitioner.py +75 -0
- test/integration/utils.py +15 -0
- test/unit/__init__.py +0 -0
- test/unit/embed/__init__.py +0 -0
- test/unit/embed/test_mixedbreadai.py +42 -0
- test/unit/embed/test_octoai.py +27 -0
- test/unit/embed/test_openai.py +20 -0
- test/unit/embed/test_vertexai.py +25 -0
- test/unit/embed/test_voyageai.py +24 -0
- test/unit/test_error.py +27 -0
- test/unit/test_logger.py +78 -0
- test/unit/test_utils.py +184 -0
- test/unit/v2/__init__.py +0 -0
- test/unit/v2/chunkers/__init__.py +0 -0
- test/unit/v2/chunkers/test_chunkers.py +49 -0
- test/unit/v2/connectors/__init__.py +0 -0
- test/unit/v2/connectors/test_confluence.py +39 -0
- test/unit/v2/embedders/__init__.py +0 -0
- test/unit/v2/embedders/test_bedrock.py +36 -0
- test/unit/v2/embedders/test_huggingface.py +48 -0
- test/unit/v2/embedders/test_mixedbread.py +37 -0
- test/unit/v2/embedders/test_octoai.py +35 -0
- test/unit/v2/embedders/test_openai.py +35 -0
- test/unit/v2/embedders/test_togetherai.py +37 -0
- test/unit/v2/embedders/test_vertexai.py +37 -0
- test/unit/v2/embedders/test_voyageai.py +38 -0
- test/unit/v2/partitioners/__init__.py +0 -0
- test/unit/v2/partitioners/test_partitioner.py +63 -0
- test/unit/v2/test_interfaces.py +26 -0
- test/unit/v2/test_utils.py +82 -0
- test/unit/v2/utils/__init__.py +0 -0
- test/unit/v2/utils/data_generator.py +32 -0
- 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 +37 -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/astradb.py +99 -0
- unstructured_ingest/cli/cmds/azure_ai_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 +663 -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/astradb.py +267 -0
- unstructured_ingest/connector/azure_ai_search.py +144 -0
- unstructured_ingest/connector/biomed.py +320 -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 +174 -0
- unstructured_ingest/connector/gitlab.py +142 -0
- unstructured_ingest/connector/google_drive.py +348 -0
- unstructured_ingest/connector/hubspot.py +278 -0
- unstructured_ingest/connector/jira.py +469 -0
- unstructured_ingest/connector/kafka.py +293 -0
- unstructured_ingest/connector/local.py +139 -0
- unstructured_ingest/connector/mongodb.py +284 -0
- unstructured_ingest/connector/notion/__init__.py +0 -0
- unstructured_ingest/connector/notion/client.py +248 -0
- unstructured_ingest/connector/notion/connector.py +469 -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 +96 -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 +73 -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 +45 -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 +253 -0
- unstructured_ingest/connector/weaviate.py +190 -0
- unstructured_ingest/connector/wikipedia.py +208 -0
- unstructured_ingest/embed/__init__.py +0 -0
- unstructured_ingest/embed/azure_openai.py +31 -0
- unstructured_ingest/embed/bedrock.py +193 -0
- unstructured_ingest/embed/huggingface.py +52 -0
- unstructured_ingest/embed/interfaces.py +117 -0
- unstructured_ingest/embed/mixedbreadai.py +233 -0
- unstructured_ingest/embed/octoai.py +130 -0
- unstructured_ingest/embed/openai.py +116 -0
- unstructured_ingest/embed/togetherai.py +106 -0
- unstructured_ingest/embed/vertexai.py +126 -0
- unstructured_ingest/embed/voyageai.py +130 -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/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 +852 -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 +270 -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 +134 -0
- unstructured_ingest/pipeline/reformat/embedding.py +64 -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/astradb.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/astradb.py +22 -0
- unstructured_ingest/runner/writers/azure_ai_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/chunking.py +56 -0
- unstructured_ingest/utils/compression.py +118 -0
- unstructured_ingest/utils/data_prep.py +200 -0
- unstructured_ingest/utils/dep_check.py +78 -0
- unstructured_ingest/utils/google_filetype.py +9 -0
- unstructured_ingest/utils/string_and_date_utils.py +49 -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 +269 -0
- unstructured_ingest/v2/cli/base/dest.py +85 -0
- unstructured_ingest/v2/cli/base/importer.py +34 -0
- unstructured_ingest/v2/cli/base/src.py +85 -0
- unstructured_ingest/v2/cli/cli.py +24 -0
- unstructured_ingest/v2/cli/cmds.py +14 -0
- unstructured_ingest/v2/cli/utils/__init__.py +0 -0
- unstructured_ingest/v2/cli/utils/click.py +237 -0
- unstructured_ingest/v2/cli/utils/model_conversion.py +222 -0
- unstructured_ingest/v2/constants.py +2 -0
- unstructured_ingest/v2/errors.py +18 -0
- unstructured_ingest/v2/interfaces/__init__.py +32 -0
- unstructured_ingest/v2/interfaces/connector.py +50 -0
- unstructured_ingest/v2/interfaces/downloader.py +89 -0
- unstructured_ingest/v2/interfaces/file_data.py +116 -0
- unstructured_ingest/v2/interfaces/indexer.py +30 -0
- unstructured_ingest/v2/interfaces/process.py +19 -0
- unstructured_ingest/v2/interfaces/processor.py +88 -0
- unstructured_ingest/v2/interfaces/upload_stager.py +102 -0
- unstructured_ingest/v2/interfaces/uploader.py +53 -0
- unstructured_ingest/v2/logger.py +126 -0
- unstructured_ingest/v2/main.py +11 -0
- unstructured_ingest/v2/otel.py +111 -0
- unstructured_ingest/v2/pipeline/__init__.py +0 -0
- unstructured_ingest/v2/pipeline/interfaces.py +211 -0
- unstructured_ingest/v2/pipeline/otel.py +32 -0
- unstructured_ingest/v2/pipeline/pipeline.py +384 -0
- unstructured_ingest/v2/pipeline/steps/__init__.py +0 -0
- unstructured_ingest/v2/pipeline/steps/chunk.py +80 -0
- unstructured_ingest/v2/pipeline/steps/download.py +207 -0
- unstructured_ingest/v2/pipeline/steps/embed.py +79 -0
- unstructured_ingest/v2/pipeline/steps/filter.py +35 -0
- unstructured_ingest/v2/pipeline/steps/index.py +86 -0
- unstructured_ingest/v2/pipeline/steps/partition.py +79 -0
- unstructured_ingest/v2/pipeline/steps/stage.py +65 -0
- unstructured_ingest/v2/pipeline/steps/uncompress.py +50 -0
- unstructured_ingest/v2/pipeline/steps/upload.py +58 -0
- unstructured_ingest/v2/processes/__init__.py +18 -0
- unstructured_ingest/v2/processes/chunker.py +124 -0
- unstructured_ingest/v2/processes/connector_registry.py +69 -0
- unstructured_ingest/v2/processes/connectors/__init__.py +117 -0
- unstructured_ingest/v2/processes/connectors/airtable.py +235 -0
- unstructured_ingest/v2/processes/connectors/astradb.py +402 -0
- unstructured_ingest/v2/processes/connectors/azure_ai_search.py +276 -0
- unstructured_ingest/v2/processes/connectors/chroma.py +190 -0
- unstructured_ingest/v2/processes/connectors/confluence.py +207 -0
- unstructured_ingest/v2/processes/connectors/couchbase.py +334 -0
- unstructured_ingest/v2/processes/connectors/databricks/__init__.py +52 -0
- unstructured_ingest/v2/processes/connectors/databricks/volumes.py +208 -0
- unstructured_ingest/v2/processes/connectors/databricks/volumes_aws.py +87 -0
- unstructured_ingest/v2/processes/connectors/databricks/volumes_azure.py +102 -0
- unstructured_ingest/v2/processes/connectors/databricks/volumes_gcp.py +85 -0
- unstructured_ingest/v2/processes/connectors/databricks/volumes_native.py +86 -0
- unstructured_ingest/v2/processes/connectors/delta_table.py +191 -0
- unstructured_ingest/v2/processes/connectors/discord.py +158 -0
- unstructured_ingest/v2/processes/connectors/duckdb/__init__.py +15 -0
- unstructured_ingest/v2/processes/connectors/duckdb/base.py +100 -0
- unstructured_ingest/v2/processes/connectors/duckdb/duckdb.py +127 -0
- unstructured_ingest/v2/processes/connectors/duckdb/motherduck.py +126 -0
- unstructured_ingest/v2/processes/connectors/elasticsearch/__init__.py +19 -0
- unstructured_ingest/v2/processes/connectors/elasticsearch/elasticsearch.py +470 -0
- unstructured_ingest/v2/processes/connectors/elasticsearch/opensearch.py +195 -0
- unstructured_ingest/v2/processes/connectors/fsspec/__init__.py +37 -0
- unstructured_ingest/v2/processes/connectors/fsspec/azure.py +197 -0
- unstructured_ingest/v2/processes/connectors/fsspec/box.py +170 -0
- unstructured_ingest/v2/processes/connectors/fsspec/dropbox.py +168 -0
- unstructured_ingest/v2/processes/connectors/fsspec/fsspec.py +332 -0
- unstructured_ingest/v2/processes/connectors/fsspec/gcs.py +197 -0
- unstructured_ingest/v2/processes/connectors/fsspec/s3.py +185 -0
- unstructured_ingest/v2/processes/connectors/fsspec/sftp.py +171 -0
- unstructured_ingest/v2/processes/connectors/fsspec/utils.py +17 -0
- unstructured_ingest/v2/processes/connectors/gitlab.py +268 -0
- unstructured_ingest/v2/processes/connectors/google_drive.py +348 -0
- unstructured_ingest/v2/processes/connectors/kafka/__init__.py +17 -0
- unstructured_ingest/v2/processes/connectors/kafka/cloud.py +121 -0
- unstructured_ingest/v2/processes/connectors/kafka/kafka.py +273 -0
- unstructured_ingest/v2/processes/connectors/kafka/local.py +103 -0
- unstructured_ingest/v2/processes/connectors/kdbai.py +148 -0
- unstructured_ingest/v2/processes/connectors/lancedb/__init__.py +30 -0
- unstructured_ingest/v2/processes/connectors/lancedb/aws.py +43 -0
- unstructured_ingest/v2/processes/connectors/lancedb/azure.py +43 -0
- unstructured_ingest/v2/processes/connectors/lancedb/cloud.py +42 -0
- unstructured_ingest/v2/processes/connectors/lancedb/gcp.py +44 -0
- unstructured_ingest/v2/processes/connectors/lancedb/lancedb.py +169 -0
- unstructured_ingest/v2/processes/connectors/lancedb/local.py +44 -0
- unstructured_ingest/v2/processes/connectors/local.py +217 -0
- unstructured_ingest/v2/processes/connectors/milvus.py +225 -0
- unstructured_ingest/v2/processes/connectors/mongodb.py +361 -0
- unstructured_ingest/v2/processes/connectors/neo4j.py +385 -0
- unstructured_ingest/v2/processes/connectors/notion/__init__.py +0 -0
- unstructured_ingest/v2/processes/connectors/notion/client.py +349 -0
- unstructured_ingest/v2/processes/connectors/notion/connector.py +346 -0
- unstructured_ingest/v2/processes/connectors/notion/helpers.py +448 -0
- unstructured_ingest/v2/processes/connectors/notion/interfaces.py +32 -0
- unstructured_ingest/v2/processes/connectors/notion/types/__init__.py +0 -0
- unstructured_ingest/v2/processes/connectors/notion/types/block.py +96 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/__init__.py +63 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/bookmark.py +40 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/breadcrumb.py +21 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/bulleted_list_item.py +31 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/callout.py +94 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/child_database.py +23 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/child_page.py +23 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/code.py +43 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/column_list.py +35 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/divider.py +22 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/embed.py +36 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/equation.py +23 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/file.py +49 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/heading.py +37 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/image.py +21 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/link_preview.py +24 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/link_to_page.py +29 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/numbered_list.py +29 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/paragraph.py +31 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/pdf.py +49 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/quote.py +37 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/synced_block.py +57 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/table.py +63 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/table_of_contents.py +23 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/template.py +30 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/todo.py +42 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/toggle.py +37 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/unsupported.py +20 -0
- unstructured_ingest/v2/processes/connectors/notion/types/blocks/video.py +22 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database.py +73 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/__init__.py +106 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/checkbox.py +38 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/created_by.py +35 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/created_time.py +34 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/date.py +41 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/email.py +36 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/files.py +37 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/formula.py +49 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/last_edited_by.py +34 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/last_edited_time.py +34 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/multiselect.py +73 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/number.py +49 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/people.py +41 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/phone_number.py +36 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/relation.py +67 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/rich_text.py +43 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/rollup.py +56 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/select.py +69 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/status.py +81 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/title.py +37 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/unique_id.py +50 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/url.py +37 -0
- unstructured_ingest/v2/processes/connectors/notion/types/database_properties/verification.py +78 -0
- unstructured_ingest/v2/processes/connectors/notion/types/date.py +29 -0
- unstructured_ingest/v2/processes/connectors/notion/types/file.py +54 -0
- unstructured_ingest/v2/processes/connectors/notion/types/page.py +45 -0
- unstructured_ingest/v2/processes/connectors/notion/types/parent.py +66 -0
- unstructured_ingest/v2/processes/connectors/notion/types/rich_text.py +189 -0
- unstructured_ingest/v2/processes/connectors/notion/types/user.py +79 -0
- unstructured_ingest/v2/processes/connectors/onedrive.py +447 -0
- unstructured_ingest/v2/processes/connectors/outlook.py +239 -0
- unstructured_ingest/v2/processes/connectors/pinecone.py +277 -0
- unstructured_ingest/v2/processes/connectors/qdrant/__init__.py +16 -0
- unstructured_ingest/v2/processes/connectors/qdrant/cloud.py +59 -0
- unstructured_ingest/v2/processes/connectors/qdrant/local.py +58 -0
- unstructured_ingest/v2/processes/connectors/qdrant/qdrant.py +160 -0
- unstructured_ingest/v2/processes/connectors/qdrant/server.py +60 -0
- unstructured_ingest/v2/processes/connectors/redisdb.py +182 -0
- unstructured_ingest/v2/processes/connectors/salesforce.py +303 -0
- unstructured_ingest/v2/processes/connectors/sharepoint.py +448 -0
- unstructured_ingest/v2/processes/connectors/slack.py +248 -0
- unstructured_ingest/v2/processes/connectors/sql/__init__.py +27 -0
- unstructured_ingest/v2/processes/connectors/sql/postgres.py +162 -0
- unstructured_ingest/v2/processes/connectors/sql/singlestore.py +166 -0
- unstructured_ingest/v2/processes/connectors/sql/snowflake.py +210 -0
- unstructured_ingest/v2/processes/connectors/sql/sql.py +434 -0
- unstructured_ingest/v2/processes/connectors/sql/sqlite.py +168 -0
- unstructured_ingest/v2/processes/connectors/utils.py +29 -0
- unstructured_ingest/v2/processes/connectors/vectara.py +350 -0
- unstructured_ingest/v2/processes/connectors/weaviate/__init__.py +22 -0
- unstructured_ingest/v2/processes/connectors/weaviate/cloud.py +165 -0
- unstructured_ingest/v2/processes/connectors/weaviate/embedded.py +90 -0
- unstructured_ingest/v2/processes/connectors/weaviate/local.py +73 -0
- unstructured_ingest/v2/processes/connectors/weaviate/weaviate.py +267 -0
- unstructured_ingest/v2/processes/embedder.py +195 -0
- unstructured_ingest/v2/processes/filter.py +60 -0
- unstructured_ingest/v2/processes/partitioner.py +188 -0
- unstructured_ingest/v2/processes/uncompress.py +61 -0
- unstructured_ingest/v2/unstructured_api.py +128 -0
- unstructured_ingest/v2/utils.py +61 -0
- unstructured_ingest-0.3.13.dist-info/LICENSE.md +201 -0
- unstructured_ingest-0.3.13.dist-info/METADATA +205 -0
- unstructured_ingest-0.3.13.dist-info/RECORD +557 -0
- unstructured_ingest-0.3.13.dist-info/WHEEL +5 -0
- unstructured_ingest-0.3.13.dist-info/entry_points.txt +2 -0
- unstructured_ingest-0.3.13.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import chromadb
|
|
5
|
+
import pytest
|
|
6
|
+
from _pytest.fixtures import TopRequest
|
|
7
|
+
|
|
8
|
+
from test.integration.connectors.utils.constants import (
|
|
9
|
+
DESTINATION_TAG,
|
|
10
|
+
)
|
|
11
|
+
from test.integration.connectors.utils.docker import HealthCheck, container_context
|
|
12
|
+
from test.integration.connectors.utils.validation.destination import (
|
|
13
|
+
StagerValidationConfigs,
|
|
14
|
+
stager_validation,
|
|
15
|
+
)
|
|
16
|
+
from unstructured_ingest.v2.interfaces import FileData, SourceIdentifiers
|
|
17
|
+
from unstructured_ingest.v2.processes.connectors.chroma import (
|
|
18
|
+
CONNECTOR_TYPE,
|
|
19
|
+
ChromaConnectionConfig,
|
|
20
|
+
ChromaUploader,
|
|
21
|
+
ChromaUploaderConfig,
|
|
22
|
+
ChromaUploadStager,
|
|
23
|
+
ChromaUploadStagerConfig,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@pytest.fixture
|
|
28
|
+
def chroma_instance():
|
|
29
|
+
with container_context(
|
|
30
|
+
image="chromadb/chroma:latest",
|
|
31
|
+
ports={8000: 8000},
|
|
32
|
+
name="chroma_int_test",
|
|
33
|
+
healthcheck=HealthCheck(
|
|
34
|
+
interval=5,
|
|
35
|
+
timeout=10,
|
|
36
|
+
retries=3,
|
|
37
|
+
test="timeout 10s bash -c ':> /dev/tcp/127.0.0.1/8000' || exit 1",
|
|
38
|
+
),
|
|
39
|
+
) as ctx:
|
|
40
|
+
yield ctx
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def validate_collection(collection_name: str, num_embeddings: int):
|
|
44
|
+
print(f"Checking contents of Chroma collection: {collection_name}")
|
|
45
|
+
|
|
46
|
+
chroma_client = chromadb.HttpClient(
|
|
47
|
+
host="localhost",
|
|
48
|
+
port="8000",
|
|
49
|
+
tenant="default_tenant",
|
|
50
|
+
database="default_database",
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
collection = chroma_client.get_or_create_collection(name=collection_name)
|
|
54
|
+
|
|
55
|
+
number_of_embeddings = collection.count()
|
|
56
|
+
expected_embeddings = num_embeddings
|
|
57
|
+
print(
|
|
58
|
+
f"# of embeddings in collection vs expected: {number_of_embeddings}/{expected_embeddings}"
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
assert number_of_embeddings == expected_embeddings, (
|
|
62
|
+
f"Number of rows in generated table ({number_of_embeddings}) "
|
|
63
|
+
f"doesn't match expected value: {expected_embeddings}"
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@pytest.mark.tags(CONNECTOR_TYPE, DESTINATION_TAG)
|
|
68
|
+
def test_chroma_destination(
|
|
69
|
+
upload_file: Path,
|
|
70
|
+
chroma_instance,
|
|
71
|
+
tmp_path: Path,
|
|
72
|
+
):
|
|
73
|
+
collection_name = "test_collection"
|
|
74
|
+
file_data = FileData(
|
|
75
|
+
source_identifiers=SourceIdentifiers(fullpath=upload_file.name, filename=upload_file.name),
|
|
76
|
+
connector_type=CONNECTOR_TYPE,
|
|
77
|
+
identifier="mock file data",
|
|
78
|
+
)
|
|
79
|
+
stager = ChromaUploadStager(upload_stager_config=ChromaUploadStagerConfig())
|
|
80
|
+
|
|
81
|
+
uploader = ChromaUploader(
|
|
82
|
+
connection_config=ChromaConnectionConfig(
|
|
83
|
+
host="localhost",
|
|
84
|
+
port=8000,
|
|
85
|
+
tenant="default_tenant",
|
|
86
|
+
database="default_database",
|
|
87
|
+
),
|
|
88
|
+
upload_config=ChromaUploaderConfig(collection_name=collection_name),
|
|
89
|
+
)
|
|
90
|
+
staged_filepath = stager.run(
|
|
91
|
+
elements_filepath=upload_file,
|
|
92
|
+
file_data=file_data,
|
|
93
|
+
output_dir=tmp_path,
|
|
94
|
+
output_filename=upload_file.name,
|
|
95
|
+
)
|
|
96
|
+
uploader.precheck()
|
|
97
|
+
uploader.run(path=staged_filepath, file_data=file_data)
|
|
98
|
+
|
|
99
|
+
# Run validation
|
|
100
|
+
with staged_filepath.open() as f:
|
|
101
|
+
staged_elements = json.load(f)
|
|
102
|
+
expected_count = len(staged_elements)
|
|
103
|
+
validate_collection(collection_name=collection_name, num_embeddings=expected_count)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@pytest.mark.parametrize("upload_file_str", ["upload_file_ndjson", "upload_file"])
|
|
107
|
+
@pytest.mark.tags(CONNECTOR_TYPE, DESTINATION_TAG, "stager")
|
|
108
|
+
def test_chroma_stager(
|
|
109
|
+
request: TopRequest,
|
|
110
|
+
upload_file_str: str,
|
|
111
|
+
tmp_path: Path,
|
|
112
|
+
):
|
|
113
|
+
upload_file: Path = request.getfixturevalue(upload_file_str)
|
|
114
|
+
stager = ChromaUploadStager()
|
|
115
|
+
stager_validation(
|
|
116
|
+
configs=StagerValidationConfigs(test_id=CONNECTOR_TYPE, expected_count=22),
|
|
117
|
+
input_file=upload_file,
|
|
118
|
+
stager=stager,
|
|
119
|
+
tmp_dir=tmp_path,
|
|
120
|
+
)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from test.integration.connectors.utils.constants import (
|
|
6
|
+
SOURCE_TAG,
|
|
7
|
+
)
|
|
8
|
+
from test.integration.connectors.utils.validation.source import (
|
|
9
|
+
SourceValidationConfigs,
|
|
10
|
+
source_connector_validation,
|
|
11
|
+
)
|
|
12
|
+
from test.integration.utils import requires_env
|
|
13
|
+
from unstructured_ingest.v2.processes.connectors.confluence import (
|
|
14
|
+
CONNECTOR_TYPE,
|
|
15
|
+
ConfluenceAccessConfig,
|
|
16
|
+
ConfluenceConnectionConfig,
|
|
17
|
+
ConfluenceDownloader,
|
|
18
|
+
ConfluenceDownloaderConfig,
|
|
19
|
+
ConfluenceIndexer,
|
|
20
|
+
ConfluenceIndexerConfig,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@pytest.mark.asyncio
|
|
25
|
+
@pytest.mark.tags(CONNECTOR_TYPE, SOURCE_TAG)
|
|
26
|
+
@requires_env("CONFLUENCE_USER_EMAIL", "CONFLUENCE_API_TOKEN")
|
|
27
|
+
async def test_confluence_source(temp_dir):
|
|
28
|
+
# Retrieve environment variables
|
|
29
|
+
confluence_url = "https://unstructured-ingest-test.atlassian.net"
|
|
30
|
+
user_email = os.environ["CONFLUENCE_USER_EMAIL"]
|
|
31
|
+
api_token = os.environ["CONFLUENCE_API_TOKEN"]
|
|
32
|
+
spaces = ["testteamsp", "MFS"]
|
|
33
|
+
|
|
34
|
+
# Create connection and indexer configurations
|
|
35
|
+
access_config = ConfluenceAccessConfig(api_token=api_token)
|
|
36
|
+
connection_config = ConfluenceConnectionConfig(
|
|
37
|
+
url=confluence_url,
|
|
38
|
+
user_email=user_email,
|
|
39
|
+
access_config=access_config,
|
|
40
|
+
)
|
|
41
|
+
index_config = ConfluenceIndexerConfig(
|
|
42
|
+
max_num_of_spaces=500,
|
|
43
|
+
max_num_of_docs_from_each_space=100,
|
|
44
|
+
spaces=spaces,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
download_config = ConfluenceDownloaderConfig(download_dir=temp_dir)
|
|
48
|
+
|
|
49
|
+
# Instantiate indexer and downloader
|
|
50
|
+
indexer = ConfluenceIndexer(
|
|
51
|
+
connection_config=connection_config,
|
|
52
|
+
index_config=index_config,
|
|
53
|
+
)
|
|
54
|
+
downloader = ConfluenceDownloader(
|
|
55
|
+
connection_config=connection_config,
|
|
56
|
+
download_config=download_config,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Run the source connector validation
|
|
60
|
+
await source_connector_validation(
|
|
61
|
+
indexer=indexer,
|
|
62
|
+
downloader=downloader,
|
|
63
|
+
configs=SourceValidationConfigs(
|
|
64
|
+
test_id="confluence",
|
|
65
|
+
expected_num_files=11,
|
|
66
|
+
validate_downloaded_files=True,
|
|
67
|
+
),
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@pytest.mark.asyncio
|
|
72
|
+
@pytest.mark.tags(CONNECTOR_TYPE, SOURCE_TAG)
|
|
73
|
+
@requires_env("CONFLUENCE_USER_EMAIL", "CONFLUENCE_API_TOKEN")
|
|
74
|
+
async def test_confluence_source_large(temp_dir):
|
|
75
|
+
# Retrieve environment variables
|
|
76
|
+
confluence_url = "https://unstructured-ingest-test.atlassian.net"
|
|
77
|
+
user_email = os.environ["CONFLUENCE_USER_EMAIL"]
|
|
78
|
+
api_token = os.environ["CONFLUENCE_API_TOKEN"]
|
|
79
|
+
spaces = ["testteamsp1"]
|
|
80
|
+
|
|
81
|
+
# Create connection and indexer configurations
|
|
82
|
+
access_config = ConfluenceAccessConfig(api_token=api_token)
|
|
83
|
+
connection_config = ConfluenceConnectionConfig(
|
|
84
|
+
url=confluence_url,
|
|
85
|
+
user_email=user_email,
|
|
86
|
+
access_config=access_config,
|
|
87
|
+
)
|
|
88
|
+
index_config = ConfluenceIndexerConfig(
|
|
89
|
+
max_num_of_spaces=10,
|
|
90
|
+
max_num_of_docs_from_each_space=250,
|
|
91
|
+
spaces=spaces,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
download_config = ConfluenceDownloaderConfig(download_dir=temp_dir)
|
|
95
|
+
|
|
96
|
+
# Instantiate indexer and downloader
|
|
97
|
+
indexer = ConfluenceIndexer(
|
|
98
|
+
connection_config=connection_config,
|
|
99
|
+
index_config=index_config,
|
|
100
|
+
)
|
|
101
|
+
downloader = ConfluenceDownloader(
|
|
102
|
+
connection_config=connection_config,
|
|
103
|
+
download_config=download_config,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# Run the source connector validation
|
|
107
|
+
await source_connector_validation(
|
|
108
|
+
indexer=indexer,
|
|
109
|
+
downloader=downloader,
|
|
110
|
+
configs=SourceValidationConfigs(
|
|
111
|
+
test_id="confluence_large", expected_num_files=250, validate_file_data=False
|
|
112
|
+
),
|
|
113
|
+
)
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import multiprocessing
|
|
2
|
+
import os
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
from deltalake import DeltaTable
|
|
7
|
+
from fsspec import get_filesystem_class
|
|
8
|
+
|
|
9
|
+
from test.integration.connectors.utils.constants import (
|
|
10
|
+
DESTINATION_TAG,
|
|
11
|
+
)
|
|
12
|
+
from test.integration.utils import requires_env
|
|
13
|
+
from unstructured_ingest.v2.interfaces import FileData, SourceIdentifiers
|
|
14
|
+
from unstructured_ingest.v2.processes.connectors.delta_table import (
|
|
15
|
+
CONNECTOR_TYPE,
|
|
16
|
+
DeltaTableAccessConfig,
|
|
17
|
+
DeltaTableConnectionConfig,
|
|
18
|
+
DeltaTableUploader,
|
|
19
|
+
DeltaTableUploaderConfig,
|
|
20
|
+
DeltaTableUploadStager,
|
|
21
|
+
DeltaTableUploadStagerConfig,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
multiprocessing.set_start_method("spawn")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@pytest.mark.asyncio
|
|
28
|
+
@pytest.mark.tags(CONNECTOR_TYPE, DESTINATION_TAG)
|
|
29
|
+
async def test_delta_table_destination_local(upload_file: Path, temp_dir: Path):
|
|
30
|
+
destination_path = str(temp_dir)
|
|
31
|
+
connection_config = DeltaTableConnectionConfig(
|
|
32
|
+
access_config=DeltaTableAccessConfig(),
|
|
33
|
+
table_uri=destination_path,
|
|
34
|
+
)
|
|
35
|
+
stager_config = DeltaTableUploadStagerConfig()
|
|
36
|
+
stager = DeltaTableUploadStager(upload_stager_config=stager_config)
|
|
37
|
+
new_upload_file = stager.run(
|
|
38
|
+
elements_filepath=upload_file,
|
|
39
|
+
output_dir=temp_dir,
|
|
40
|
+
output_filename=upload_file.name,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
upload_config = DeltaTableUploaderConfig()
|
|
44
|
+
uploader = DeltaTableUploader(connection_config=connection_config, upload_config=upload_config)
|
|
45
|
+
file_data = FileData(
|
|
46
|
+
source_identifiers=SourceIdentifiers(
|
|
47
|
+
fullpath=upload_file.name, filename=new_upload_file.name
|
|
48
|
+
),
|
|
49
|
+
connector_type=CONNECTOR_TYPE,
|
|
50
|
+
identifier="mock file data",
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
if uploader.is_async():
|
|
54
|
+
await uploader.run_async(path=new_upload_file, file_data=file_data)
|
|
55
|
+
else:
|
|
56
|
+
uploader.run(path=new_upload_file, file_data=file_data)
|
|
57
|
+
delta_table_path = os.path.join(destination_path, upload_file.name)
|
|
58
|
+
delta_table = DeltaTable(table_uri=delta_table_path)
|
|
59
|
+
df = delta_table.to_pandas()
|
|
60
|
+
|
|
61
|
+
EXPECTED_COLUMNS = 10
|
|
62
|
+
EXPECTED_ROWS = 22
|
|
63
|
+
assert (
|
|
64
|
+
len(df) == EXPECTED_ROWS
|
|
65
|
+
), f"Number of rows in table vs expected: {len(df)}/{EXPECTED_ROWS}"
|
|
66
|
+
assert (
|
|
67
|
+
len(df.columns) == EXPECTED_COLUMNS
|
|
68
|
+
), f"Number of columns in table vs expected: {len(df.columns)}/{EXPECTED_COLUMNS}"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def get_aws_credentials() -> dict:
|
|
72
|
+
access_key = os.getenv("S3_INGEST_TEST_ACCESS_KEY", None)
|
|
73
|
+
assert access_key
|
|
74
|
+
secret_key = os.getenv("S3_INGEST_TEST_SECRET_KEY", None)
|
|
75
|
+
assert secret_key
|
|
76
|
+
return {
|
|
77
|
+
"AWS_ACCESS_KEY_ID": access_key,
|
|
78
|
+
"AWS_SECRET_ACCESS_KEY": secret_key,
|
|
79
|
+
"AWS_REGION": "us-east-2",
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@pytest.mark.asyncio
|
|
84
|
+
@pytest.mark.tags(CONNECTOR_TYPE, DESTINATION_TAG)
|
|
85
|
+
@requires_env("S3_INGEST_TEST_ACCESS_KEY", "S3_INGEST_TEST_SECRET_KEY")
|
|
86
|
+
async def test_delta_table_destination_s3(upload_file: Path, temp_dir: Path):
|
|
87
|
+
aws_credentials = get_aws_credentials()
|
|
88
|
+
s3_bucket = "s3://utic-platform-test-destination"
|
|
89
|
+
destination_path = f"{s3_bucket}/destination/test"
|
|
90
|
+
connection_config = DeltaTableConnectionConfig(
|
|
91
|
+
access_config=DeltaTableAccessConfig(
|
|
92
|
+
aws_access_key_id=aws_credentials["AWS_ACCESS_KEY_ID"],
|
|
93
|
+
aws_secret_access_key=aws_credentials["AWS_SECRET_ACCESS_KEY"],
|
|
94
|
+
),
|
|
95
|
+
aws_region=aws_credentials["AWS_REGION"],
|
|
96
|
+
table_uri=destination_path,
|
|
97
|
+
)
|
|
98
|
+
stager_config = DeltaTableUploadStagerConfig()
|
|
99
|
+
stager = DeltaTableUploadStager(upload_stager_config=stager_config)
|
|
100
|
+
new_upload_file = stager.run(
|
|
101
|
+
elements_filepath=upload_file,
|
|
102
|
+
output_dir=temp_dir,
|
|
103
|
+
output_filename=upload_file.name,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
upload_config = DeltaTableUploaderConfig()
|
|
107
|
+
uploader = DeltaTableUploader(connection_config=connection_config, upload_config=upload_config)
|
|
108
|
+
file_data = FileData(
|
|
109
|
+
source_identifiers=SourceIdentifiers(
|
|
110
|
+
fullpath=upload_file.name, filename=new_upload_file.name
|
|
111
|
+
),
|
|
112
|
+
connector_type=CONNECTOR_TYPE,
|
|
113
|
+
identifier="mock file data",
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
uploader.precheck()
|
|
118
|
+
if uploader.is_async():
|
|
119
|
+
await uploader.run_async(path=new_upload_file, file_data=file_data)
|
|
120
|
+
else:
|
|
121
|
+
uploader.run(path=new_upload_file, file_data=file_data)
|
|
122
|
+
delta_table_path = os.path.join(destination_path, upload_file.name)
|
|
123
|
+
delta_table = DeltaTable(table_uri=delta_table_path, storage_options=aws_credentials)
|
|
124
|
+
df = delta_table.to_pandas()
|
|
125
|
+
|
|
126
|
+
EXPECTED_COLUMNS = 10
|
|
127
|
+
EXPECTED_ROWS = 22
|
|
128
|
+
assert (
|
|
129
|
+
len(df) == EXPECTED_ROWS
|
|
130
|
+
), f"Number of rows in table vs expected: {len(df)}/{EXPECTED_ROWS}"
|
|
131
|
+
assert (
|
|
132
|
+
len(df.columns) == EXPECTED_COLUMNS
|
|
133
|
+
), f"Number of columns in table vs expected: {len(df.columns)}/{EXPECTED_COLUMNS}"
|
|
134
|
+
finally:
|
|
135
|
+
s3fs = get_filesystem_class("s3")(
|
|
136
|
+
key=aws_credentials["AWS_ACCESS_KEY_ID"],
|
|
137
|
+
secret=aws_credentials["AWS_SECRET_ACCESS_KEY"],
|
|
138
|
+
)
|
|
139
|
+
s3fs.rm(path=destination_path, recursive=True)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
@pytest.mark.asyncio
|
|
143
|
+
@pytest.mark.tags(CONNECTOR_TYPE, DESTINATION_TAG)
|
|
144
|
+
@requires_env("S3_INGEST_TEST_ACCESS_KEY", "S3_INGEST_TEST_SECRET_KEY")
|
|
145
|
+
async def test_delta_table_destination_s3_bad_creds(upload_file: Path, temp_dir: Path):
|
|
146
|
+
aws_credentials = {
|
|
147
|
+
"AWS_ACCESS_KEY_ID": "bad key",
|
|
148
|
+
"AWS_SECRET_ACCESS_KEY": "bad secret",
|
|
149
|
+
"AWS_REGION": "us-east-2",
|
|
150
|
+
}
|
|
151
|
+
s3_bucket = "s3://utic-platform-test-destination"
|
|
152
|
+
destination_path = f"{s3_bucket}/destination/test"
|
|
153
|
+
connection_config = DeltaTableConnectionConfig(
|
|
154
|
+
access_config=DeltaTableAccessConfig(
|
|
155
|
+
aws_access_key_id=aws_credentials["AWS_ACCESS_KEY_ID"],
|
|
156
|
+
aws_secret_access_key=aws_credentials["AWS_SECRET_ACCESS_KEY"],
|
|
157
|
+
),
|
|
158
|
+
aws_region=aws_credentials["AWS_REGION"],
|
|
159
|
+
table_uri=destination_path,
|
|
160
|
+
)
|
|
161
|
+
stager_config = DeltaTableUploadStagerConfig()
|
|
162
|
+
stager = DeltaTableUploadStager(upload_stager_config=stager_config)
|
|
163
|
+
new_upload_file = stager.run(
|
|
164
|
+
elements_filepath=upload_file,
|
|
165
|
+
output_dir=temp_dir,
|
|
166
|
+
output_filename=upload_file.name,
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
upload_config = DeltaTableUploaderConfig()
|
|
170
|
+
uploader = DeltaTableUploader(connection_config=connection_config, upload_config=upload_config)
|
|
171
|
+
file_data = FileData(
|
|
172
|
+
source_identifiers=SourceIdentifiers(
|
|
173
|
+
fullpath=upload_file.name, filename=new_upload_file.name
|
|
174
|
+
),
|
|
175
|
+
connector_type=CONNECTOR_TYPE,
|
|
176
|
+
identifier="mock file data",
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
with pytest.raises(Exception) as excinfo:
|
|
180
|
+
if uploader.is_async():
|
|
181
|
+
await uploader.run_async(path=new_upload_file, file_data=file_data)
|
|
182
|
+
else:
|
|
183
|
+
uploader.run(path=new_upload_file, file_data=file_data)
|
|
184
|
+
|
|
185
|
+
assert "403 Forbidden" in str(excinfo.value), f"Exception message did not match: {str(excinfo)}"
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Literal, Union
|
|
4
|
+
from uuid import uuid4
|
|
5
|
+
|
|
6
|
+
import lancedb
|
|
7
|
+
import pandas as pd
|
|
8
|
+
import pyarrow as pa
|
|
9
|
+
import pytest
|
|
10
|
+
import pytest_asyncio
|
|
11
|
+
from lancedb import AsyncConnection
|
|
12
|
+
from upath import UPath
|
|
13
|
+
|
|
14
|
+
from test.integration.connectors.utils.constants import DESTINATION_TAG
|
|
15
|
+
from unstructured_ingest.v2.constants import RECORD_ID_LABEL
|
|
16
|
+
from unstructured_ingest.v2.interfaces.file_data import FileData, SourceIdentifiers
|
|
17
|
+
from unstructured_ingest.v2.processes.connectors.lancedb.aws import (
|
|
18
|
+
LanceDBAwsAccessConfig,
|
|
19
|
+
LanceDBAwsConnectionConfig,
|
|
20
|
+
LanceDBAwsUploader,
|
|
21
|
+
)
|
|
22
|
+
from unstructured_ingest.v2.processes.connectors.lancedb.azure import (
|
|
23
|
+
LanceDBAzureAccessConfig,
|
|
24
|
+
LanceDBAzureConnectionConfig,
|
|
25
|
+
LanceDBAzureUploader,
|
|
26
|
+
)
|
|
27
|
+
from unstructured_ingest.v2.processes.connectors.lancedb.gcp import (
|
|
28
|
+
LanceDBGCSAccessConfig,
|
|
29
|
+
LanceDBGCSConnectionConfig,
|
|
30
|
+
LanceDBGSPUploader,
|
|
31
|
+
)
|
|
32
|
+
from unstructured_ingest.v2.processes.connectors.lancedb.lancedb import (
|
|
33
|
+
CONNECTOR_TYPE,
|
|
34
|
+
LanceDBUploaderConfig,
|
|
35
|
+
LanceDBUploadStager,
|
|
36
|
+
)
|
|
37
|
+
from unstructured_ingest.v2.processes.connectors.lancedb.local import (
|
|
38
|
+
LanceDBLocalAccessConfig,
|
|
39
|
+
LanceDBLocalConnectionConfig,
|
|
40
|
+
LanceDBLocalUploader,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
DATABASE_NAME = "database"
|
|
44
|
+
TABLE_NAME = "elements"
|
|
45
|
+
DIMENSION = 384
|
|
46
|
+
NUMBER_EXPECTED_ROWS = 22
|
|
47
|
+
S3_BUCKET = "s3://utic-ingest-test-fixtures/"
|
|
48
|
+
GS_BUCKET = "gs://utic-test-ingest-fixtures-output/"
|
|
49
|
+
AZURE_BUCKET = "az://utic-ingest-test-fixtures-output/"
|
|
50
|
+
REQUIRED_ENV_VARS = {
|
|
51
|
+
"s3": ("S3_INGEST_TEST_ACCESS_KEY", "S3_INGEST_TEST_SECRET_KEY"),
|
|
52
|
+
"gcs": ("GCP_INGEST_SERVICE_KEY",),
|
|
53
|
+
"az": ("AZURE_DEST_CONNECTION_STR",),
|
|
54
|
+
"local": (),
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
SCHEMA = pa.schema(
|
|
58
|
+
[
|
|
59
|
+
pa.field(RECORD_ID_LABEL, pa.string()),
|
|
60
|
+
pa.field("vector", pa.list_(pa.float16(), DIMENSION)),
|
|
61
|
+
pa.field("text", pa.string(), nullable=True),
|
|
62
|
+
pa.field("type", pa.string(), nullable=True),
|
|
63
|
+
pa.field("element_id", pa.string(), nullable=True),
|
|
64
|
+
pa.field("metadata-text_as_html", pa.string(), nullable=True),
|
|
65
|
+
pa.field("metadata-filetype", pa.string(), nullable=True),
|
|
66
|
+
pa.field("metadata-filename", pa.string(), nullable=True),
|
|
67
|
+
pa.field("metadata-languages", pa.list_(pa.string()), nullable=True),
|
|
68
|
+
pa.field("metadata-is_continuation", pa.bool_(), nullable=True),
|
|
69
|
+
pa.field("metadata-page_number", pa.int32(), nullable=True),
|
|
70
|
+
]
|
|
71
|
+
)
|
|
72
|
+
NUMBER_EXPECTED_COLUMNS = len(SCHEMA.names)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@pytest_asyncio.fixture
|
|
76
|
+
async def connection_with_uri(request, tmp_path: Path):
|
|
77
|
+
target = request.param
|
|
78
|
+
uri = _get_uri(target, local_base_path=tmp_path)
|
|
79
|
+
|
|
80
|
+
unset_variables = [env for env in REQUIRED_ENV_VARS[target] if env not in os.environ]
|
|
81
|
+
if unset_variables:
|
|
82
|
+
pytest.skip(
|
|
83
|
+
reason="Following required environment variables were not set: "
|
|
84
|
+
+ f"{', '.join(unset_variables)}"
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
storage_options = {
|
|
88
|
+
"aws_access_key_id": os.getenv("S3_INGEST_TEST_ACCESS_KEY"),
|
|
89
|
+
"aws_secret_access_key": os.getenv("S3_INGEST_TEST_SECRET_KEY"),
|
|
90
|
+
"google_service_account_key": os.getenv("GCP_INGEST_SERVICE_KEY"),
|
|
91
|
+
}
|
|
92
|
+
azure_connection_string = os.getenv("AZURE_DEST_CONNECTION_STR")
|
|
93
|
+
if azure_connection_string:
|
|
94
|
+
storage_options.update(_parse_azure_connection_string(azure_connection_string))
|
|
95
|
+
|
|
96
|
+
storage_options = {key: value for key, value in storage_options.items() if value is not None}
|
|
97
|
+
connection = await lancedb.connect_async(
|
|
98
|
+
uri=uri,
|
|
99
|
+
storage_options=storage_options,
|
|
100
|
+
)
|
|
101
|
+
await connection.create_table(name=TABLE_NAME, schema=SCHEMA)
|
|
102
|
+
|
|
103
|
+
yield connection, uri
|
|
104
|
+
|
|
105
|
+
await connection.drop_database()
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@pytest.mark.asyncio
|
|
109
|
+
@pytest.mark.tags(CONNECTOR_TYPE, DESTINATION_TAG)
|
|
110
|
+
@pytest.mark.parametrize("connection_with_uri", ["local", "s3", "gcs", "az"], indirect=True)
|
|
111
|
+
async def test_lancedb_destination(
|
|
112
|
+
upload_file: Path,
|
|
113
|
+
connection_with_uri: tuple[AsyncConnection, str],
|
|
114
|
+
tmp_path: Path,
|
|
115
|
+
) -> None:
|
|
116
|
+
connection, uri = connection_with_uri
|
|
117
|
+
file_data = FileData(
|
|
118
|
+
source_identifiers=SourceIdentifiers(fullpath=upload_file.name, filename=upload_file.name),
|
|
119
|
+
connector_type=CONNECTOR_TYPE,
|
|
120
|
+
identifier="mock-file-data",
|
|
121
|
+
)
|
|
122
|
+
stager = LanceDBUploadStager()
|
|
123
|
+
uploader = _get_uploader(uri)
|
|
124
|
+
staged_file_path = stager.run(
|
|
125
|
+
elements_filepath=upload_file,
|
|
126
|
+
file_data=file_data,
|
|
127
|
+
output_dir=tmp_path,
|
|
128
|
+
output_filename=upload_file.name,
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
await uploader.run_async(path=staged_file_path, file_data=file_data)
|
|
132
|
+
|
|
133
|
+
# Test upload to empty table
|
|
134
|
+
with await connection.open_table(TABLE_NAME) as table:
|
|
135
|
+
table_df: pd.DataFrame = await table.to_pandas()
|
|
136
|
+
|
|
137
|
+
assert len(table_df) == NUMBER_EXPECTED_ROWS
|
|
138
|
+
assert len(table_df.columns) == NUMBER_EXPECTED_COLUMNS
|
|
139
|
+
|
|
140
|
+
assert table_df[RECORD_ID_LABEL][0] == file_data.identifier
|
|
141
|
+
assert table_df["element_id"][0] == "2470d8dc42215b3d68413b55bf00fed2"
|
|
142
|
+
assert table_df["type"][0] == "CompositeElement"
|
|
143
|
+
assert table_df["metadata-filename"][0] == "DA-1p-with-duplicate-pages.pdf.json"
|
|
144
|
+
assert table_df["metadata-text_as_html"][0] is None
|
|
145
|
+
|
|
146
|
+
# Test upload of the second file, rows should be appended
|
|
147
|
+
file_data.identifier = "mock-file-data-2"
|
|
148
|
+
staged_second_file_path = stager.run(
|
|
149
|
+
elements_filepath=upload_file,
|
|
150
|
+
file_data=file_data,
|
|
151
|
+
output_dir=tmp_path,
|
|
152
|
+
output_filename=f"{upload_file.stem}-2{upload_file.suffix}",
|
|
153
|
+
)
|
|
154
|
+
await uploader.run_async(path=staged_second_file_path, file_data=file_data)
|
|
155
|
+
with await connection.open_table(TABLE_NAME) as table:
|
|
156
|
+
appended_table_df: pd.DataFrame = await table.to_pandas()
|
|
157
|
+
assert len(appended_table_df) == 2 * NUMBER_EXPECTED_ROWS
|
|
158
|
+
|
|
159
|
+
# Test re-upload of the first file, rows should be overwritten, not appended
|
|
160
|
+
await uploader.run_async(path=staged_file_path, file_data=file_data)
|
|
161
|
+
with await connection.open_table(TABLE_NAME) as table:
|
|
162
|
+
overwritten_table_df: pd.DataFrame = await table.to_pandas()
|
|
163
|
+
assert len(overwritten_table_df) == 2 * NUMBER_EXPECTED_ROWS
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class TestPrecheck:
|
|
167
|
+
@pytest.mark.tags(CONNECTOR_TYPE, DESTINATION_TAG)
|
|
168
|
+
@pytest.mark.parametrize("connection_with_uri", ["local", "s3", "gcs", "az"], indirect=True)
|
|
169
|
+
def test_succeeds(
|
|
170
|
+
self,
|
|
171
|
+
upload_file: Path,
|
|
172
|
+
connection_with_uri: tuple[AsyncConnection, str],
|
|
173
|
+
tmp_path: Path,
|
|
174
|
+
) -> None:
|
|
175
|
+
_, uri = connection_with_uri
|
|
176
|
+
uploader = _get_uploader(uri)
|
|
177
|
+
uploader.precheck()
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def _get_uri(target: Literal["local", "s3", "gcs", "az"], local_base_path: Path) -> str:
|
|
181
|
+
if target == "local":
|
|
182
|
+
return str(local_base_path / DATABASE_NAME)
|
|
183
|
+
if target == "s3":
|
|
184
|
+
base_uri = UPath(S3_BUCKET)
|
|
185
|
+
elif target == "gcs":
|
|
186
|
+
base_uri = UPath(GS_BUCKET)
|
|
187
|
+
elif target == "az":
|
|
188
|
+
base_uri = UPath(AZURE_BUCKET)
|
|
189
|
+
|
|
190
|
+
return str(base_uri / "destination" / "lancedb" / str(uuid4()) / DATABASE_NAME)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def _get_uploader(
|
|
194
|
+
uri: str,
|
|
195
|
+
) -> Union[LanceDBAzureUploader, LanceDBAzureUploader, LanceDBAwsUploader, LanceDBGSPUploader]:
|
|
196
|
+
target = uri.split("://", maxsplit=1)[0] if uri.startswith(("s3", "az", "gs")) else "local"
|
|
197
|
+
upload_config = LanceDBUploaderConfig(table_name=TABLE_NAME)
|
|
198
|
+
if target == "az":
|
|
199
|
+
azure_connection_string = os.getenv("AZURE_DEST_CONNECTION_STR")
|
|
200
|
+
access_config_kwargs = _parse_azure_connection_string(azure_connection_string)
|
|
201
|
+
return LanceDBAzureUploader(
|
|
202
|
+
upload_config=upload_config,
|
|
203
|
+
connection_config=LanceDBAzureConnectionConfig(
|
|
204
|
+
access_config=LanceDBAzureAccessConfig(**access_config_kwargs),
|
|
205
|
+
uri=uri,
|
|
206
|
+
),
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
elif target == "s3":
|
|
210
|
+
return LanceDBAwsUploader(
|
|
211
|
+
upload_config=upload_config,
|
|
212
|
+
connection_config=LanceDBAwsConnectionConfig(
|
|
213
|
+
access_config=LanceDBAwsAccessConfig(
|
|
214
|
+
aws_access_key_id=os.getenv("S3_INGEST_TEST_ACCESS_KEY"),
|
|
215
|
+
aws_secret_access_key=os.getenv("S3_INGEST_TEST_SECRET_KEY"),
|
|
216
|
+
),
|
|
217
|
+
uri=uri,
|
|
218
|
+
),
|
|
219
|
+
)
|
|
220
|
+
elif target == "gs":
|
|
221
|
+
return LanceDBGSPUploader(
|
|
222
|
+
upload_config=upload_config,
|
|
223
|
+
connection_config=LanceDBGCSConnectionConfig(
|
|
224
|
+
access_config=LanceDBGCSAccessConfig(
|
|
225
|
+
google_service_account_key=os.getenv("GCP_INGEST_SERVICE_KEY")
|
|
226
|
+
),
|
|
227
|
+
uri=uri,
|
|
228
|
+
),
|
|
229
|
+
)
|
|
230
|
+
else:
|
|
231
|
+
return LanceDBLocalUploader(
|
|
232
|
+
upload_config=upload_config,
|
|
233
|
+
connection_config=LanceDBLocalConnectionConfig(
|
|
234
|
+
access_config=LanceDBLocalAccessConfig(),
|
|
235
|
+
uri=uri,
|
|
236
|
+
),
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def _parse_azure_connection_string(
|
|
241
|
+
connection_str: str,
|
|
242
|
+
) -> dict[Literal["azure_storage_account_name", "azure_storage_account_key"], str]:
|
|
243
|
+
parameters = dict(keyvalue.split("=", maxsplit=1) for keyvalue in connection_str.split(";"))
|
|
244
|
+
return {
|
|
245
|
+
"azure_storage_account_name": parameters.get("AccountName"),
|
|
246
|
+
"azure_storage_account_key": parameters.get("AccountKey"),
|
|
247
|
+
}
|