Skip to content

S3: Basic unstructured file support - #31209

Merged
Joe Reuter (flash1293) merged 28 commits into
masterfrom
flash1293/markdown-parser
Oct 17, 2023
Merged

Joe Reuter (flash1293) merged 28 commits into
masterfrom
flash1293/markdown-parser

Conversation

@flash1293

@flash1293 Joe Reuter (flash1293) commented Oct 10, 2023 •

Copy link
Copy Markdown
Contributor

What

Fixes #31208

Screenshot 2023-10-10 at 13 23 03

Testing

To test, I spun up a local minio server using docker run -p 9000:9000 -p 9001:9001 minio/minio server /data --console-address ":9001"

To set up syncable data:

  • Navigate to the admin console (http://localhost:9001/login) minioadmin:minioadmin for access
  • Create a bucket
  • Uploade some files
  • Create an access key with the following policy:
{
 "Version": "2012-10-17",
 "Statement": [
  {
   "Effect": "Allow",
   "Action": [
    "s3:*"
   ],
   "Resource": [
    "arn:aws:s3:::*"
   ]
  }
 ]
}

How

  • Add a new option to the file format configuration for unstructured formats
  • Add a new parser to implement the new file format
  • In the parser, delegate to the unstructured library partition method to extract information from the file
  • Turn the returned array of elements into markdown (if the file is markdown already, just use it directly)
  • Return a record with content and file id (just the file name in this case but could be different for other sources)
  • If a file has the wrong format, it is treated as a parsing error

Limitations:

  • For incremental syncs, Airbyte can only track up to 10k files - after this, it will apply a heuristic and only load files newer than a configurable number of dates
  • For append+dedup syncs, stale chunks won't be removed if a file gets smaller than it was before (this is described in the documentation)

Problems

Open questions

  • Which file types to support? Technically, more file types are "for free" as the unstructured lib is doing the heavy lifting
    • IMHO, starting with markdown, pdf and docx is fine for now
  • The markdown rendering is very basic currently, but the element structure of unstructured doesn't give us much to work with (for example the level of a heading). Is this good enough?
    • IMHO yes
  • How large can we realistically go with chunk sizes? Need to check with platform team.
    • The biggest limitation is the maximum column size in the destination. 4M seems to be a safe choice for now, we can play with this later
  • Single file size limit: The setup can't be streamed for a single file so it needs to fit into memory in its entirety. We don't grant a lot of memory to source connectors, easiest "handling" is to just let it crash trying to load a file that's too big to fit. Not sure whether this is good enough, we could add a check and skip files that are too large. Is this necessary?
    • IMHO just crashing is OK for now
  • OCR - should we use an OCR strategy to allow extracting text from images in PDFs? Allow images as input format in general? The downside is the increased processing costs
  • Markdown conversion loses some available meta information. Depending on the downstream processing, this might not be the best possible approach. We could add an output format option to the file format (markdown or json) or add two columns for both formats and rely on platform column selection to remove the once that's not needed. What's the right approach here?
    • IMHO we can start with just the markdown and defer that to later
  • Do we want to support doc (separately from docx)? It requires libreoffice which I don't know whether we want to add as a dependency
    • IMHO we can defer that to later
  • Should we do chunking or truncate a record if it gets too large? This would limit the usability, but make things a lot simpler (I can also imagine it's annoying in the destination to work with chunks all the time)
    • IMHO we can start with doing chunking - it's experimental so it should be OK to break it later on

@vercel

vercel Bot commented Oct 10, 2023 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
airbyte-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 17, 2023 7:44am

@octavia-squidington-iii Octavia Squidington III (octavia-squidington-iii) added area/connectors Connector related issues area/documentation Improvements or additions to documentation labels Oct 10, 2023
@github-actions

Copy link
Copy Markdown
Contributor

Before Merging a Connector Pull Request

Wow! What a great pull request you have here! 🎉

To merge this PR, ensure the following has been done/considered for each connector added or updated:

  • PR name follows PR naming conventions
  • Breaking changes are considered. If a Breaking Change is being introduced, ensure an Airbyte engineer has created a Breaking Change Plan.
  • Connector version has been incremented in the Dockerfile and metadata.yaml according to our Semantic Versioning for Connectors guidelines
  • You've updated the connector's metadata.yaml file any other relevant changes, including a breakingChanges entry for major version bumps. See metadata.yaml docs
  • Secrets in the connector's spec are annotated with airbyte_secret
  • All documentation files are up to date. (README.md, bootstrap.md, docs.md, etc...)
  • Changelog updated in docs/integrations/<source or destination>/<name>.md with an entry for the new version. See changelog example
  • Migration guide updated in docs/integrations/<source or destination>/<name>-migrations.md with an entry for the new version, if the version is a breaking change. See migration guide example
  • If set, you've ensured the icon is present in the platform-internal repo. (Docs)

If the checklist is complete, but the CI check is failing,

  1. Check for hidden checklists in your PR description

  2. Toggle the github label checklist-action-run on/off to re-run the checklist CI.

@flash1293 Joe Reuter (flash1293) changed the title WIP S3: Basic unstructured file support S3: Basic unstructured file support Oct 11, 2023
@airbyte-oss-build-runner

Copy link
Copy Markdown
Collaborator

source-s3 test report (commit 2695eceee9) - ❌

⏲️ Total pipeline duration: 19mn54s

Step Result
Build source-s3 docker image for platform(s) linux/x86_64 ✅
Unit tests ✅
Acceptance tests ❌
Code format checks ❌
Validate metadata for source-s3 ✅
Connector version semver check ✅
Connector version increment check ✅
QA checks ✅

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-s3 test

@flash1293

Copy link
Copy Markdown
Contributor Author

The acceptance test errors also happen on master (not caused by this PR): https://connectors.airbyte.com/files/generated_reports/test_summary/source-s3/index.html

@airbyte-oss-build-runner

Copy link
Copy Markdown
Collaborator

source-s3 test report (commit a61a8c1be7) - ❌

⏲️ Total pipeline duration: 18mn59s

Step Result
Build source-s3 docker image for platform(s) linux/x86_64 ✅
Unit tests ✅
Acceptance tests ❌
Code format checks ✅
Validate metadata for source-s3 ✅
Connector version semver check ✅
Connector version increment check ✅
QA checks ✅

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-s3 test

@aaronsteers

Aaron ("AJ") Steers (aaronsteers) commented Oct 11, 2023 •

Copy link
Copy Markdown
Member

Problems

Noted. And I think agree this is probably acceptable for a first pass, as discussed.

Open questions

  • Which file types to support? Technically, more file types are "for free" as the unstructured lib is doing the heavy lifting

    • IMHO, starting with markdown, pdf and docx is fine for now

Sounds very reasonable. Less surface area to support means we can better focus on edge cases (if/when those arise) for a smaller number of possible file types. I'm also fine with excluding PDF in the first version if it makes sense to exclude, since it's the only one of these that requires OCR (image recognition) and probably is an order of magnitude slower than the other purely text-based processing methods.

  • The markdown rendering is very basic currently, but the element structure of unstructured doesn't give us much to work with (for example the level of a heading). Is this good enough?

    • IMHO yes

Yes - and... I just checked in on my request here:

Was apparently closed as resolved here:

Joe Reuter (@flash1293) - Could this help at all with giving us richer markdown info? (In this pass or in a future one.) I haven't closely looked at their implementation or spec as of yet.

  • How large can we realistically go with chunk sizes? Need to check with platform team.

    • The biggest limitation is the maximum column size in the destination. 4M seems to be a safe choice for now, we can play with this later

👍

  • Single file size limit: The setup can't be streamed for a single file so it needs to fit into memory in its entirety. We don't grant a lot of memory to source connectors, easiest "handling" is to just let it crash trying to load a file that's too big to fit. Not sure whether this is good enough, we could add a check and skip files that are too large. Is this necessary?

    • IMHO just crashing is OK for now

👍

  • OCR - should we use an OCR strategy to allow extracting text from images in PDFs? Allow images as input format in general? The downside is the increased processing costs

👍 - Long-term, I imagine we'd expose some of these nobs/dials to the users when they are using a parser that requires OCR. Perhaps instead of exposing all internals, we could reduce to "max quality", "max speed", or "balanced".

  • Markdown conversion loses some available meta information. Depending on the downstream processing, this might not be the best possible approach. We could add an output format option to the file format (markdown or json) or add two columns for both formats and rely on platform column selection to remove the once that's not needed. What's the right approach here?

Do you mean PDF->Markdown and Word->Markdown?

In the first pass, I'm inclined to keep simple and just output the markdown text. But this is dependent on the specific nature of the issues/shortcomings...

  • IMHO we can start with just the markdown and defer that to later

👍

  • Do we want to support doc (separately from docx)? It requires libreoffice which I don't know whether we want to add as a dependency

    • IMHO we can defer that to later

Totally okay to keep doc (the older, pre-xml format) for later addition.

  • Should we do chunking or truncate a record if it gets too large? This would limit the usability, but make things a lot simpler (I can also imagine it's annoying in the destination to work with chunks all the time)

    • IMHO we can start with doing chunking - it's experimental so it should be OK to break it later on

I'm okay with chunking or truncating at this phase.

Argument for chunking:

  • Most likely to deliver all the text data, regardless of text size.

Argument for truncating:

  • Doesn't require us to have a robust chunking algorithm yet.
  • Doesn't require extra record metadata properties (yet).
  • Prioritizes a lean execution model and no chance of stale chunks/remnants being orphaned in the destination table.

Argument for doing neither (yet):

  • Shows us where the systems will break - specifically the platform and destinations.
  • Doesn't add more complexity (yet) in terms of spec and/or record schema.
  • Sets us up nicely to let to be deferred to destination-side or platform-side handling - which are both possible future outcomes.

@airbyte-oss-build-runner

Copy link
Copy Markdown
Collaborator

source-s3 test report (commit 9d66e3e4b3) - ✅

⏲️ Total pipeline duration: 17mn33s

Step Result
Build source-s3 docker image for platform(s) linux/x86_64 ✅
Unit tests ✅
Acceptance tests ✅
Code format checks ✅
Validate metadata for source-s3 ✅
Connector version semver check ✅
Connector version increment check ✅
QA checks ✅

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-s3 test

@airbyte-oss-build-runner

Copy link
Copy Markdown
Collaborator

source-s3 test report (commit c1cc4d122d) - ❌

⏲️ Total pipeline duration: 17mn51s

Step Result
Build source-s3 docker image for platform(s) linux/x86_64 ✅
Unit tests ✅
Acceptance tests ✅
Code format checks ❌
Validate metadata for source-s3 ✅
Connector version semver check ✅
Connector version increment check ✅
QA checks ✅

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-s3 test

@airbyte-oss-build-runner

Copy link
Copy Markdown
Collaborator

source-s3 test report (commit 7f2ded80e7) - ❌

⏲️ Total pipeline duration: 17mn14s

Step Result
Build source-s3 docker image for platform(s) linux/x86_64 ✅
Unit tests ✅
Acceptance tests ✅
Code format checks ❌
Validate metadata for source-s3 ✅
Connector version semver check ✅
Connector version increment check ✅
QA checks ✅

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-s3 test

@airbyte-oss-build-runner

Copy link
Copy Markdown
Collaborator

source-s3 test report (commit d1f3645786) - ✅

⏲️ Total pipeline duration: 17mn30s

Step Result
Build source-s3 docker image for platform(s) linux/x86_64 ✅
Unit tests ✅
Acceptance tests ✅
Code format checks ✅
Validate metadata for source-s3 ✅
Connector version semver check ✅
Connector version increment check ✅
QA checks ✅

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-s3 test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completed a full code readthrough. Besides what we previously discussed, I think the only other thing that pops out to me is the question of output schema, such as column names, incremental key, and primary key. I put a comment below that we may want to try to match the file_uri column name rather than introducing the new "id" column.

Similarly, we could consider a column name like "document_markdown" or "file_markdown" or "markdown_contents" - but I also do think "contents" works. I didn't see schema for last-modified timestamps, but that may already be internally handled by the CDK.

Approving with these comments as non-blocking. This is a great first iteration. 🙏

Comment on lines +45 to +48
return {
"content": {"type": "string"},
"id": {"type": "string"},
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a different name for the column id (file uri) in the CDK today for the other file types.

Should we try to match that?

@airbyte-oss-build-runner

Copy link
Copy Markdown
Collaborator

source-s3 test report (commit c4bdb38fc8) - ✅

⏲️ Total pipeline duration: 13mn11s

Step Result
Build source-s3 docker image for platform(s) linux/x86_64 ✅
Unit tests ✅
Acceptance tests ✅
Code format checks ✅
Validate metadata for source-s3 ✅
Connector version semver check ✅
Connector version increment check ✅
QA checks ✅

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-s3 test

@airbyte-oss-build-runner

Copy link
Copy Markdown
Collaborator

source-s3 test report (commit 6608dc5324) - ❌

⏲️ Total pipeline duration: 05mn22s

Step Result

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-s3 test

@airbyte-oss-build-runner

Copy link
Copy Markdown
Collaborator

source-s3 test report (commit 6608dc5324) - ❌

⏲️ Total pipeline duration: 06mn36s

Step Result

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-s3 test

@airbyte-oss-build-runner

Copy link
Copy Markdown
Collaborator

source-s3 test report (commit 6608dc5324) - ❌

⏲️ Total pipeline duration: 06mn44s

Step Result

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-s3 test

@airbyte-oss-build-runner

Copy link
Copy Markdown
Collaborator

source-s3 test report (commit d14d6a8b1c) - ❌

⏲️ Total pipeline duration: 04mn25s

Step Result

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-s3 test

@airbyte-oss-build-runner

Copy link
Copy Markdown
Collaborator

source-s3 test report (commit 495f428322) - ✅

⏲️ Total pipeline duration: 16mn29s

Step Result
Build source-s3 docker image for platform(s) linux/x86_64 ✅
Unit tests ✅
Acceptance tests ✅
Code format checks ✅
Validate metadata for source-s3 ✅
Connector version semver check ✅
Connector version increment check ✅
QA checks ✅

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-s3 test

@flash1293
Joe Reuter (flash1293) merged commit 0a01bc2 into master Oct 17, 2023
@flash1293
Joe Reuter (flash1293) deleted the flash1293/markdown-parser branch October 17, 2023 13:18
Aries Gunawan (ariesgun) pushed a commit to ariesgun/airbyte that referenced this pull request Oct 23, 2023
Co-authored-by: flash1293 <flash1293@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — 495f4283 Deployed Oct 17, 2023 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/connectors Connector related issues area/documentation Improvements or additions to documentation connectors/source/s3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add document file type parser to S3 connector

5 participants