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
test/__init__.py
ADDED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
6
|
+
from test.integration.utils import requires_env
|
|
7
|
+
from unstructured_ingest.v2.processes.chunker import Chunker, ChunkerConfig
|
|
8
|
+
|
|
9
|
+
int_test_dir = Path(__file__).parent
|
|
10
|
+
assets_dir = int_test_dir / "assets"
|
|
11
|
+
|
|
12
|
+
chunker_files = [path for path in assets_dir.iterdir() if path.is_file()]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@pytest.mark.parametrize("chunker_file", chunker_files, ids=[path.name for path in chunker_files])
|
|
16
|
+
@pytest.mark.parametrize("strategy", ["basic", "by_title", "by_similarity", "by_page"])
|
|
17
|
+
@requires_env("UNSTRUCTURED_API_KEY", "UNSTRUCTURED_API_URL")
|
|
18
|
+
@pytest.mark.asyncio
|
|
19
|
+
async def test_chunker_api(chunker_file: Path, strategy: str):
|
|
20
|
+
api_key = os.getenv("UNSTRUCTURED_API_KEY")
|
|
21
|
+
api_url = os.getenv("UNSTRUCTURED_API_URL")
|
|
22
|
+
|
|
23
|
+
chunker_config = ChunkerConfig(
|
|
24
|
+
chunking_strategy=strategy,
|
|
25
|
+
chunk_by_api=True,
|
|
26
|
+
chunk_api_key=api_key,
|
|
27
|
+
chunking_endpoint=api_url,
|
|
28
|
+
)
|
|
29
|
+
chunker = Chunker(config=chunker_config)
|
|
30
|
+
results = await chunker.run_async(elements_filepath=chunker_file)
|
|
31
|
+
assert results
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import tempfile
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Generator
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from unstructured_ingest.v2.logger import logger
|
|
8
|
+
|
|
9
|
+
FILENAME = Path("DA-1p-with-duplicate-pages.pdf.json")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@pytest.fixture
|
|
13
|
+
def upload_file() -> Path:
|
|
14
|
+
int_test_dir = Path(__file__).parent
|
|
15
|
+
assets_dir = int_test_dir / "assets"
|
|
16
|
+
upload_file = assets_dir / FILENAME
|
|
17
|
+
assert upload_file.exists()
|
|
18
|
+
assert upload_file.is_file()
|
|
19
|
+
return upload_file
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.fixture
|
|
23
|
+
def upload_file_ndjson() -> Path:
|
|
24
|
+
int_test_dir = Path(__file__).parent
|
|
25
|
+
assets_dir = int_test_dir / "assets"
|
|
26
|
+
upload_file = assets_dir / FILENAME.with_suffix(".ndjson")
|
|
27
|
+
assert upload_file.exists()
|
|
28
|
+
assert upload_file.is_file()
|
|
29
|
+
return upload_file
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@pytest.fixture
|
|
33
|
+
def temp_dir() -> Generator[Path, None, None]:
|
|
34
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
|
35
|
+
temp_path = Path(temp_dir)
|
|
36
|
+
logger.info(f"Created temp dir '{temp_path}'")
|
|
37
|
+
yield temp_path
|
|
38
|
+
logger.info(f"Removing temp dir '{temp_path}'")
|
|
File without changes
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import uuid
|
|
4
|
+
from contextlib import contextmanager
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from unittest import mock
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
from databricks.sdk import WorkspaceClient
|
|
11
|
+
from databricks.sdk.errors.platform import NotFound
|
|
12
|
+
|
|
13
|
+
from test.integration.connectors.utils.constants import DESTINATION_TAG, SOURCE_TAG
|
|
14
|
+
from test.integration.connectors.utils.validation.source import (
|
|
15
|
+
SourceValidationConfigs,
|
|
16
|
+
source_connector_validation,
|
|
17
|
+
)
|
|
18
|
+
from test.integration.utils import requires_env
|
|
19
|
+
from unstructured_ingest.v2.errors import UserAuthError, UserError
|
|
20
|
+
from unstructured_ingest.v2.interfaces import FileData, SourceIdentifiers
|
|
21
|
+
from unstructured_ingest.v2.processes.connectors.databricks.volumes_native import (
|
|
22
|
+
CONNECTOR_TYPE,
|
|
23
|
+
DatabricksNativeVolumesAccessConfig,
|
|
24
|
+
DatabricksNativeVolumesConnectionConfig,
|
|
25
|
+
DatabricksNativeVolumesDownloader,
|
|
26
|
+
DatabricksNativeVolumesDownloaderConfig,
|
|
27
|
+
DatabricksNativeVolumesIndexer,
|
|
28
|
+
DatabricksNativeVolumesIndexerConfig,
|
|
29
|
+
DatabricksNativeVolumesUploader,
|
|
30
|
+
DatabricksNativeVolumesUploaderConfig,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass
|
|
35
|
+
class BaseEnvData:
|
|
36
|
+
host: str
|
|
37
|
+
catalog: str
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass
|
|
41
|
+
class BasicAuthEnvData(BaseEnvData):
|
|
42
|
+
client_id: str
|
|
43
|
+
client_secret: str
|
|
44
|
+
|
|
45
|
+
def get_connection_config(self) -> DatabricksNativeVolumesConnectionConfig:
|
|
46
|
+
return DatabricksNativeVolumesConnectionConfig(
|
|
47
|
+
host=self.host,
|
|
48
|
+
access_config=DatabricksNativeVolumesAccessConfig(
|
|
49
|
+
client_id=self.client_id,
|
|
50
|
+
client_secret=self.client_secret,
|
|
51
|
+
),
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dataclass
|
|
56
|
+
class PATEnvData(BaseEnvData):
|
|
57
|
+
token: str
|
|
58
|
+
|
|
59
|
+
def get_connection_config(self) -> DatabricksNativeVolumesConnectionConfig:
|
|
60
|
+
return DatabricksNativeVolumesConnectionConfig(
|
|
61
|
+
host=self.host,
|
|
62
|
+
access_config=DatabricksNativeVolumesAccessConfig(
|
|
63
|
+
token=self.token,
|
|
64
|
+
),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def get_basic_auth_env_data() -> BasicAuthEnvData:
|
|
69
|
+
return BasicAuthEnvData(
|
|
70
|
+
host=os.environ["DATABRICKS_HOST"],
|
|
71
|
+
client_id=os.environ["DATABRICKS_CLIENT_ID"],
|
|
72
|
+
client_secret=os.environ["DATABRICKS_CLIENT_SECRET"],
|
|
73
|
+
catalog=os.environ["DATABRICKS_CATALOG"],
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def get_pat_env_data() -> PATEnvData:
|
|
78
|
+
return PATEnvData(
|
|
79
|
+
host=os.environ["DATABRICKS_HOST"],
|
|
80
|
+
catalog=os.environ["DATABRICKS_CATALOG"],
|
|
81
|
+
token=os.environ["DATABRICKS_PAT"],
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@pytest.mark.asyncio
|
|
86
|
+
@pytest.mark.tags(CONNECTOR_TYPE, SOURCE_TAG)
|
|
87
|
+
@requires_env(
|
|
88
|
+
"DATABRICKS_HOST", "DATABRICKS_CLIENT_ID", "DATABRICKS_CLIENT_SECRET", "DATABRICKS_CATALOG"
|
|
89
|
+
)
|
|
90
|
+
async def test_volumes_native_source(tmp_path: Path):
|
|
91
|
+
env_data = get_basic_auth_env_data()
|
|
92
|
+
with mock.patch.dict(os.environ, clear=True):
|
|
93
|
+
indexer_config = DatabricksNativeVolumesIndexerConfig(
|
|
94
|
+
recursive=True,
|
|
95
|
+
volume="test-platform",
|
|
96
|
+
volume_path="databricks-volumes-test-input",
|
|
97
|
+
catalog=env_data.catalog,
|
|
98
|
+
)
|
|
99
|
+
connection_config = env_data.get_connection_config()
|
|
100
|
+
download_config = DatabricksNativeVolumesDownloaderConfig(download_dir=tmp_path)
|
|
101
|
+
indexer = DatabricksNativeVolumesIndexer(
|
|
102
|
+
connection_config=connection_config, index_config=indexer_config
|
|
103
|
+
)
|
|
104
|
+
downloader = DatabricksNativeVolumesDownloader(
|
|
105
|
+
connection_config=connection_config, download_config=download_config
|
|
106
|
+
)
|
|
107
|
+
await source_connector_validation(
|
|
108
|
+
indexer=indexer,
|
|
109
|
+
downloader=downloader,
|
|
110
|
+
configs=SourceValidationConfigs(
|
|
111
|
+
test_id="databricks_volumes_native",
|
|
112
|
+
expected_num_files=1,
|
|
113
|
+
),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@pytest.mark.asyncio
|
|
118
|
+
@pytest.mark.tags(CONNECTOR_TYPE, SOURCE_TAG)
|
|
119
|
+
@requires_env("DATABRICKS_HOST", "DATABRICKS_PAT", "DATABRICKS_CATALOG")
|
|
120
|
+
async def test_volumes_native_source_pat(tmp_path: Path):
|
|
121
|
+
env_data = get_pat_env_data()
|
|
122
|
+
with mock.patch.dict(os.environ, clear=True):
|
|
123
|
+
indexer_config = DatabricksNativeVolumesIndexerConfig(
|
|
124
|
+
recursive=True,
|
|
125
|
+
volume="test-platform",
|
|
126
|
+
volume_path="databricks-volumes-test-input",
|
|
127
|
+
catalog=env_data.catalog,
|
|
128
|
+
)
|
|
129
|
+
connection_config = env_data.get_connection_config()
|
|
130
|
+
download_config = DatabricksNativeVolumesDownloaderConfig(download_dir=tmp_path)
|
|
131
|
+
indexer = DatabricksNativeVolumesIndexer(
|
|
132
|
+
connection_config=connection_config, index_config=indexer_config
|
|
133
|
+
)
|
|
134
|
+
downloader = DatabricksNativeVolumesDownloader(
|
|
135
|
+
connection_config=connection_config, download_config=download_config
|
|
136
|
+
)
|
|
137
|
+
await source_connector_validation(
|
|
138
|
+
indexer=indexer,
|
|
139
|
+
downloader=downloader,
|
|
140
|
+
configs=SourceValidationConfigs(
|
|
141
|
+
test_id="databricks_volumes_native_pat",
|
|
142
|
+
expected_num_files=1,
|
|
143
|
+
),
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
@pytest.mark.tags(CONNECTOR_TYPE, SOURCE_TAG)
|
|
148
|
+
@requires_env("DATABRICKS_HOST", "DATABRICKS_PAT", "DATABRICKS_CATALOG")
|
|
149
|
+
def test_volumes_native_source_pat_invalid_catalog():
|
|
150
|
+
env_data = get_pat_env_data()
|
|
151
|
+
with mock.patch.dict(os.environ, clear=True):
|
|
152
|
+
indexer_config = DatabricksNativeVolumesIndexerConfig(
|
|
153
|
+
recursive=True,
|
|
154
|
+
volume="test-platform",
|
|
155
|
+
volume_path="databricks-volumes-test-input",
|
|
156
|
+
catalog="fake_catalog",
|
|
157
|
+
)
|
|
158
|
+
indexer = DatabricksNativeVolumesIndexer(
|
|
159
|
+
connection_config=env_data.get_connection_config(), index_config=indexer_config
|
|
160
|
+
)
|
|
161
|
+
with pytest.raises(UserError):
|
|
162
|
+
_ = list(indexer.run())
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
@pytest.mark.tags(CONNECTOR_TYPE, SOURCE_TAG)
|
|
166
|
+
@requires_env("DATABRICKS_HOST")
|
|
167
|
+
def test_volumes_native_source_pat_invalid_pat():
|
|
168
|
+
host = os.environ["DATABRICKS_HOST"]
|
|
169
|
+
with mock.patch.dict(os.environ, clear=True):
|
|
170
|
+
indexer_config = DatabricksNativeVolumesIndexerConfig(
|
|
171
|
+
recursive=True,
|
|
172
|
+
volume="test-platform",
|
|
173
|
+
volume_path="databricks-volumes-test-input",
|
|
174
|
+
catalog="fake_catalog",
|
|
175
|
+
)
|
|
176
|
+
connection_config = DatabricksNativeVolumesConnectionConfig(
|
|
177
|
+
host=host,
|
|
178
|
+
access_config=DatabricksNativeVolumesAccessConfig(
|
|
179
|
+
token="invalid-token",
|
|
180
|
+
),
|
|
181
|
+
)
|
|
182
|
+
indexer = DatabricksNativeVolumesIndexer(
|
|
183
|
+
connection_config=connection_config, index_config=indexer_config
|
|
184
|
+
)
|
|
185
|
+
with pytest.raises(UserAuthError):
|
|
186
|
+
_ = list(indexer.run())
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def _get_volume_path(catalog: str, volume: str, volume_path: str):
|
|
190
|
+
return f"/Volumes/{catalog}/default/{volume}/{volume_path}"
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
@contextmanager
|
|
194
|
+
def databricks_destination_context(
|
|
195
|
+
env_data: BasicAuthEnvData, volume: str, volume_path
|
|
196
|
+
) -> WorkspaceClient:
|
|
197
|
+
client = WorkspaceClient(
|
|
198
|
+
host=env_data.host, client_id=env_data.client_id, client_secret=env_data.client_secret
|
|
199
|
+
)
|
|
200
|
+
try:
|
|
201
|
+
yield client
|
|
202
|
+
finally:
|
|
203
|
+
# Cleanup
|
|
204
|
+
try:
|
|
205
|
+
for file in client.files.list_directory_contents(
|
|
206
|
+
directory_path=_get_volume_path(env_data.catalog, volume, volume_path)
|
|
207
|
+
):
|
|
208
|
+
client.files.delete(file.path)
|
|
209
|
+
client.files.delete_directory(_get_volume_path(env_data.catalog, volume, volume_path))
|
|
210
|
+
except NotFound:
|
|
211
|
+
# Directory was never created, don't need to delete
|
|
212
|
+
pass
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def validate_upload(client: WorkspaceClient, catalog: str, volume: str, volume_path: str):
|
|
216
|
+
files = list(
|
|
217
|
+
client.files.list_directory_contents(
|
|
218
|
+
directory_path=_get_volume_path(catalog, volume, volume_path)
|
|
219
|
+
)
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
assert len(files) == 1
|
|
223
|
+
|
|
224
|
+
resp = client.files.download(files[0].path)
|
|
225
|
+
data = json.loads(resp.contents.read())
|
|
226
|
+
|
|
227
|
+
assert len(data) == 22
|
|
228
|
+
element_types = {v["type"] for v in data}
|
|
229
|
+
assert len(element_types) == 1
|
|
230
|
+
assert "CompositeElement" in element_types
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
@pytest.mark.asyncio
|
|
234
|
+
@pytest.mark.tags(CONNECTOR_TYPE, DESTINATION_TAG)
|
|
235
|
+
@requires_env(
|
|
236
|
+
"DATABRICKS_HOST", "DATABRICKS_CLIENT_ID", "DATABRICKS_CLIENT_SECRET", "DATABRICKS_CATALOG"
|
|
237
|
+
)
|
|
238
|
+
async def test_volumes_native_destination(upload_file: Path):
|
|
239
|
+
env_data = get_basic_auth_env_data()
|
|
240
|
+
volume_path = f"databricks-volumes-test-output-{uuid.uuid4()}"
|
|
241
|
+
file_data = FileData(
|
|
242
|
+
source_identifiers=SourceIdentifiers(fullpath=upload_file.name, filename=upload_file.name),
|
|
243
|
+
connector_type=CONNECTOR_TYPE,
|
|
244
|
+
identifier="mock file data",
|
|
245
|
+
)
|
|
246
|
+
with databricks_destination_context(
|
|
247
|
+
volume="test-platform", volume_path=volume_path, env_data=env_data
|
|
248
|
+
) as workspace_client:
|
|
249
|
+
connection_config = env_data.get_connection_config()
|
|
250
|
+
uploader = DatabricksNativeVolumesUploader(
|
|
251
|
+
connection_config=connection_config,
|
|
252
|
+
upload_config=DatabricksNativeVolumesUploaderConfig(
|
|
253
|
+
volume="test-platform",
|
|
254
|
+
volume_path=volume_path,
|
|
255
|
+
catalog=env_data.catalog,
|
|
256
|
+
),
|
|
257
|
+
)
|
|
258
|
+
uploader.precheck()
|
|
259
|
+
if uploader.is_async():
|
|
260
|
+
await uploader.run_async(path=upload_file, file_data=file_data)
|
|
261
|
+
else:
|
|
262
|
+
uploader.run(path=upload_file, file_data=file_data)
|
|
263
|
+
|
|
264
|
+
validate_upload(
|
|
265
|
+
client=workspace_client,
|
|
266
|
+
catalog=env_data.catalog,
|
|
267
|
+
volume="test-platform",
|
|
268
|
+
volume_path=volume_path,
|
|
269
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import tempfile
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from test.integration.connectors.utils.constants import SOURCE_TAG
|
|
10
|
+
from test.integration.connectors.utils.validation.source import (
|
|
11
|
+
SourceValidationConfigs,
|
|
12
|
+
source_connector_validation,
|
|
13
|
+
)
|
|
14
|
+
from test.integration.utils import requires_env
|
|
15
|
+
from unstructured_ingest.error import SourceConnectionError
|
|
16
|
+
from unstructured_ingest.v2.processes.connectors.discord import (
|
|
17
|
+
CONNECTOR_TYPE,
|
|
18
|
+
DiscordAccessConfig,
|
|
19
|
+
DiscordConnectionConfig,
|
|
20
|
+
DiscordDownloader,
|
|
21
|
+
DiscordDownloaderConfig,
|
|
22
|
+
DiscordIndexer,
|
|
23
|
+
DiscordIndexerConfig,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True)
|
|
28
|
+
class EnvData:
|
|
29
|
+
token: Optional[str]
|
|
30
|
+
channels: Optional[list[str]]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def get_env_data() -> EnvData:
|
|
34
|
+
return EnvData(
|
|
35
|
+
token=os.getenv("DISCORD_TOKEN"),
|
|
36
|
+
channels=os.getenv("DISCORD_CHANNELS", default=[]).split(","),
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pytest.mark.asyncio
|
|
41
|
+
@pytest.mark.tags(CONNECTOR_TYPE, SOURCE_TAG)
|
|
42
|
+
@requires_env("DISCORD_TOKEN", "DISCORD_CHANNELS")
|
|
43
|
+
async def test_discord_source():
|
|
44
|
+
env = get_env_data()
|
|
45
|
+
indexer_config = DiscordIndexerConfig(channels=env.channels)
|
|
46
|
+
with tempfile.TemporaryDirectory() as tempdir:
|
|
47
|
+
tempdir_path = Path(tempdir)
|
|
48
|
+
connection_config = DiscordConnectionConfig(
|
|
49
|
+
access_config=DiscordAccessConfig(token=env.token)
|
|
50
|
+
)
|
|
51
|
+
download_config = DiscordDownloaderConfig(download_dir=tempdir_path)
|
|
52
|
+
indexer = DiscordIndexer(connection_config=connection_config, index_config=indexer_config)
|
|
53
|
+
downloader = DiscordDownloader(
|
|
54
|
+
connection_config=connection_config, download_config=download_config
|
|
55
|
+
)
|
|
56
|
+
expected_num_files = len(env.channels)
|
|
57
|
+
await source_connector_validation(
|
|
58
|
+
indexer=indexer,
|
|
59
|
+
downloader=downloader,
|
|
60
|
+
configs=SourceValidationConfigs(
|
|
61
|
+
test_id=CONNECTOR_TYPE,
|
|
62
|
+
expected_num_files=expected_num_files,
|
|
63
|
+
expected_number_indexed_file_data=expected_num_files,
|
|
64
|
+
validate_downloaded_files=True,
|
|
65
|
+
),
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@pytest.mark.tags(CONNECTOR_TYPE, SOURCE_TAG)
|
|
70
|
+
@requires_env("DISCORD_CHANNELS")
|
|
71
|
+
def test_discord_source_precheck_fail_no_token():
|
|
72
|
+
indexer_config = DiscordIndexerConfig(channels=get_env_data().channels)
|
|
73
|
+
|
|
74
|
+
connection_config = DiscordConnectionConfig(access_config=DiscordAccessConfig(token=""))
|
|
75
|
+
indexer = DiscordIndexer(connection_config=connection_config, index_config=indexer_config)
|
|
76
|
+
with pytest.raises(SourceConnectionError):
|
|
77
|
+
indexer.precheck()
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@pytest.mark.tags(CONNECTOR_TYPE, SOURCE_TAG)
|
|
81
|
+
@requires_env("DISCORD_TOKEN")
|
|
82
|
+
def test_discord_source_precheck_fail_no_channels():
|
|
83
|
+
indexer_config = DiscordIndexerConfig(channels=[])
|
|
84
|
+
|
|
85
|
+
connection_config = DiscordConnectionConfig(
|
|
86
|
+
access_config=DiscordAccessConfig(token=get_env_data().token)
|
|
87
|
+
)
|
|
88
|
+
indexer = DiscordIndexer(connection_config=connection_config, index_config=indexer_config)
|
|
89
|
+
with pytest.raises(SourceConnectionError):
|
|
90
|
+
indexer.precheck()
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
int_test_dir = Path(__file__).parent
|
|
6
|
+
assets_dir = int_test_dir / "assets"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@pytest.fixture
|
|
10
|
+
def duckdb_schema() -> Path:
|
|
11
|
+
schema_file = assets_dir / "duckdb-schema.sql"
|
|
12
|
+
assert schema_file.exists()
|
|
13
|
+
assert schema_file.is_file()
|
|
14
|
+
return schema_file
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import duckdb
|
|
5
|
+
import pytest
|
|
6
|
+
from _pytest.fixtures import TopRequest
|
|
7
|
+
|
|
8
|
+
from test.integration.connectors.utils.constants import DESTINATION_TAG
|
|
9
|
+
from test.integration.connectors.utils.validation.destination import (
|
|
10
|
+
StagerValidationConfigs,
|
|
11
|
+
stager_validation,
|
|
12
|
+
)
|
|
13
|
+
from unstructured_ingest.v2.interfaces.file_data import FileData, SourceIdentifiers
|
|
14
|
+
from unstructured_ingest.v2.processes.connectors.duckdb.duckdb import (
|
|
15
|
+
CONNECTOR_TYPE,
|
|
16
|
+
DuckDBConnectionConfig,
|
|
17
|
+
DuckDBUploader,
|
|
18
|
+
DuckDBUploaderConfig,
|
|
19
|
+
DuckDBUploadStager,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@pytest.fixture
|
|
24
|
+
def provisioned_db_file(duckdb_schema: Path, temp_dir: Path) -> Path:
|
|
25
|
+
db_path = Path(temp_dir) / "temp_duck.db"
|
|
26
|
+
with duckdb.connect(database=db_path) as duckdb_connection:
|
|
27
|
+
with duckdb_schema.open("r") as f:
|
|
28
|
+
query = f.read()
|
|
29
|
+
duckdb_connection.execute(query)
|
|
30
|
+
duckdb_connection.close()
|
|
31
|
+
return db_path
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def validate_duckdb_destination(db_path: Path, expected_num_elements: int):
|
|
35
|
+
conn = None
|
|
36
|
+
try:
|
|
37
|
+
conn = duckdb.connect(db_path)
|
|
38
|
+
_results = conn.sql("select count(*) from elements").fetchall()
|
|
39
|
+
_count = _results[0][0]
|
|
40
|
+
assert (
|
|
41
|
+
_count == expected_num_elements
|
|
42
|
+
), f"dest check failed: got {_count}, expected {expected_num_elements}"
|
|
43
|
+
conn.close()
|
|
44
|
+
finally:
|
|
45
|
+
if conn:
|
|
46
|
+
conn.close()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@pytest.mark.tags(CONNECTOR_TYPE, DESTINATION_TAG, "duckdb")
|
|
50
|
+
def test_duckdb_destination(upload_file: Path, provisioned_db_file: Path, temp_dir: Path):
|
|
51
|
+
file_data = FileData(
|
|
52
|
+
source_identifiers=SourceIdentifiers(fullpath=upload_file.name, filename=upload_file.name),
|
|
53
|
+
connector_type=CONNECTOR_TYPE,
|
|
54
|
+
identifier="mock-file-data",
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
stager = DuckDBUploadStager()
|
|
58
|
+
staged_path = stager.run(
|
|
59
|
+
elements_filepath=upload_file,
|
|
60
|
+
file_data=file_data,
|
|
61
|
+
output_dir=temp_dir,
|
|
62
|
+
output_filename=upload_file.name,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
connection_config = DuckDBConnectionConfig(database=str(provisioned_db_file))
|
|
66
|
+
upload_config = DuckDBUploaderConfig()
|
|
67
|
+
uploader = DuckDBUploader(connection_config=connection_config, upload_config=upload_config)
|
|
68
|
+
|
|
69
|
+
uploader.run(path=staged_path, file_data=file_data)
|
|
70
|
+
|
|
71
|
+
with staged_path.open() as f:
|
|
72
|
+
data = json.load(f)
|
|
73
|
+
validate_duckdb_destination(db_path=provisioned_db_file, expected_num_elements=len(data))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@pytest.mark.parametrize("upload_file_str", ["upload_file_ndjson", "upload_file"])
|
|
77
|
+
def test_duckdb_stager(
|
|
78
|
+
request: TopRequest,
|
|
79
|
+
upload_file_str: str,
|
|
80
|
+
tmp_path: Path,
|
|
81
|
+
):
|
|
82
|
+
upload_file: Path = request.getfixturevalue(upload_file_str)
|
|
83
|
+
stager = DuckDBUploadStager()
|
|
84
|
+
stager_validation(
|
|
85
|
+
configs=StagerValidationConfigs(test_id=CONNECTOR_TYPE, expected_count=22),
|
|
86
|
+
input_file=upload_file,
|
|
87
|
+
stager=stager,
|
|
88
|
+
tmp_dir=tmp_path,
|
|
89
|
+
)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import uuid
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Generator
|
|
5
|
+
|
|
6
|
+
import duckdb
|
|
7
|
+
import pandas as pd
|
|
8
|
+
import pytest
|
|
9
|
+
|
|
10
|
+
from test.integration.connectors.utils.constants import DESTINATION_TAG
|
|
11
|
+
from test.integration.utils import requires_env
|
|
12
|
+
from unstructured_ingest.v2.interfaces.file_data import FileData, SourceIdentifiers
|
|
13
|
+
from unstructured_ingest.v2.processes.connectors.duckdb.motherduck import (
|
|
14
|
+
CONNECTOR_TYPE,
|
|
15
|
+
MotherDuckAccessConfig,
|
|
16
|
+
MotherDuckConnectionConfig,
|
|
17
|
+
MotherDuckUploader,
|
|
18
|
+
MotherDuckUploaderConfig,
|
|
19
|
+
MotherDuckUploadStager,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@pytest.fixture
|
|
24
|
+
def md_token() -> str:
|
|
25
|
+
motherduck_token = os.getenv("MOTHERDUCK_TOKEN", None)
|
|
26
|
+
assert motherduck_token
|
|
27
|
+
return motherduck_token
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@pytest.fixture
|
|
31
|
+
def provisioned_db(md_token: str, duckdb_schema: Path) -> Generator[str, None, None]:
|
|
32
|
+
database_name = f"test_{str(uuid.uuid4()).replace('-', '_')}"
|
|
33
|
+
try:
|
|
34
|
+
with duckdb.connect(f"md:?motherduck_token={md_token}") as md_conn:
|
|
35
|
+
with duckdb_schema.open("r") as f:
|
|
36
|
+
query = f.read()
|
|
37
|
+
md_conn.execute(f"CREATE DATABASE {database_name}")
|
|
38
|
+
md_conn.execute(f"USE {database_name}")
|
|
39
|
+
md_conn.execute(query)
|
|
40
|
+
md_conn.close()
|
|
41
|
+
yield database_name
|
|
42
|
+
finally:
|
|
43
|
+
with duckdb.connect(f"md:?motherduck_token={md_token}") as md_conn:
|
|
44
|
+
md_conn.execute(f"DROP DATABASE {database_name}")
|
|
45
|
+
md_conn.close()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def validate_motherduck_destination(database: str, expected_num_elements: int, md_token: str):
|
|
49
|
+
conn = None
|
|
50
|
+
try:
|
|
51
|
+
conn = duckdb.connect(f"md:?motherduck_token={md_token}")
|
|
52
|
+
conn.execute(f"USE {database}")
|
|
53
|
+
_results = conn.sql("select count(*) from elements").fetchall()
|
|
54
|
+
_count = _results[0][0]
|
|
55
|
+
assert (
|
|
56
|
+
_count == expected_num_elements
|
|
57
|
+
), f"dest check failed: got {_count}, expected {expected_num_elements}"
|
|
58
|
+
conn.close()
|
|
59
|
+
finally:
|
|
60
|
+
if conn:
|
|
61
|
+
conn.close()
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@pytest.mark.tags(CONNECTOR_TYPE, DESTINATION_TAG)
|
|
65
|
+
@requires_env("MOTHERDUCK_TOKEN")
|
|
66
|
+
def test_motherduck_destination(
|
|
67
|
+
md_token: str, upload_file: Path, provisioned_db: str, temp_dir: Path
|
|
68
|
+
):
|
|
69
|
+
file_data = FileData(
|
|
70
|
+
source_identifiers=SourceIdentifiers(fullpath=upload_file.name, filename=upload_file.name),
|
|
71
|
+
connector_type=CONNECTOR_TYPE,
|
|
72
|
+
identifier="mock-file-data",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
stager = MotherDuckUploadStager()
|
|
76
|
+
staged_path = stager.run(
|
|
77
|
+
elements_filepath=upload_file,
|
|
78
|
+
file_data=file_data,
|
|
79
|
+
output_dir=temp_dir,
|
|
80
|
+
output_filename=upload_file.name,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
access_config = MotherDuckAccessConfig(md_token=md_token)
|
|
84
|
+
connection_config = MotherDuckConnectionConfig(
|
|
85
|
+
database=provisioned_db, access_config=access_config
|
|
86
|
+
)
|
|
87
|
+
upload_config = MotherDuckUploaderConfig()
|
|
88
|
+
uploader = MotherDuckUploader(connection_config=connection_config, upload_config=upload_config)
|
|
89
|
+
|
|
90
|
+
uploader.run(path=staged_path, file_data=file_data)
|
|
91
|
+
|
|
92
|
+
staged_df = pd.read_json(staged_path, orient="records", lines=True)
|
|
93
|
+
validate_motherduck_destination(
|
|
94
|
+
database=provisioned_db, expected_num_elements=len(staged_df), md_token=md_token
|
|
95
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import pandas as pd
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
int_test_dir = Path(__file__).parent
|
|
8
|
+
assets_dir = int_test_dir / "assets"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture
|
|
12
|
+
def movies_dataframe() -> pd.DataFrame:
|
|
13
|
+
movies_file = assets_dir / "wiki_movie_plots_small.csv"
|
|
14
|
+
assert movies_file.exists()
|
|
15
|
+
assert movies_file.is_file()
|
|
16
|
+
return pd.read_csv(movies_file).dropna().reset_index()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@pytest.fixture
|
|
20
|
+
def opensearch_elements_mapping() -> dict:
|
|
21
|
+
elements_mapping_file = assets_dir / "opensearch_elements_mappings.json"
|
|
22
|
+
assert elements_mapping_file.exists()
|
|
23
|
+
assert elements_mapping_file.is_file()
|
|
24
|
+
with elements_mapping_file.open() as fp:
|
|
25
|
+
return json.load(fp)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@pytest.fixture
|
|
29
|
+
def elasticsearch_elements_mapping() -> dict:
|
|
30
|
+
elements_mapping_file = assets_dir / "elasticsearch_elements_mappings.json"
|
|
31
|
+
assert elements_mapping_file.exists()
|
|
32
|
+
assert elements_mapping_file.is_file()
|
|
33
|
+
with elements_mapping_file.open() as fp:
|
|
34
|
+
return json.load(fp)
|