Skip to content

Asap 204 change all file handling to requests - #239

Merged
lkacenja merged 4 commits into
devfrom
asap-204-change-all-file-handling-to-requests
Jul 28, 2025
Merged

Asap 204 change all file handling to requests#239
lkacenja merged 4 commits into
devfrom
asap-204-change-all-file-handling-to-requests

Conversation

@lkacenja

@lkacenja lkacenja commented Jul 23, 2025

Copy link
Copy Markdown
Contributor

Some of the stakeholder sites have some different redirect strategies and security measures in place for their URLs. The requests library is a more robust option for downloading the files than the core urllib. We should implement a solution that makes the LLM features work for Georgia.

This PR changes both the document inference and evaluation codebases to use the same requests library-based download function. I also made the document inference container mount the codebase for easier development. I also added failure messages to the logs (eventually CloudWatch). Right now they are just sent back in the API response.

  • What additional steps are required to test this branch locally?

Rebuild the containers, add the API key and test the LLM features.

  • Are there any areas you would like extra review?

Georgia reported issues with the following sites:

Georgia: Office of the Child Advocate
Georgia: Nonpublic Postsecondary Education Commission
Georgia: Department of Human Services Division of Family & Children Services

We should test these out specifically.

  • Are there any rake tasks to run on production?

No

@lkacenja lkacenja self-assigned this Jul 23, 2025
@lkacenja
lkacenja changed the base branch from dev to main July 23, 2025 21:25
@lkacenja
lkacenja changed the base branch from main to dev July 23, 2025 21:25
from werkzeug import Request, Response

"""
Tests to assert that our file getting method works with some known curveballs.

@lkacenja lkacenja Jul 24, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added a few tests to try and cover issues we've run into in the past. I'm honestly not sure how helpful these are. We did not keep specific records of every file download error we ran into, many of which were on the Rails side. It's also difficult to replicate some of the server behavior faithfully in a test setup. The header check test fails with urllib, but that is a bit of a false flag because it's difficult to know which headers Georgia has configured Cloudflare to look for. The rest of tests pass with either approach.

If we run into any other issues like this, we can add a new test and document them here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if utilizing Jira might be a better approach than a spreadsheet, since we already document issues there. I'm not super familiar, but maybe we could create a new label so it's easier for us to find these issues?

Here are a couple of previous examples that seem relevant: ASAP-161, ASAP-35, ASAP-70.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good thinking. I added a label to ASAP-204 and the other issues. ASAP-35 and ASAP-70 are related to the Rails app and crawler, nothing we should add test coverage for here. I think the test for the 308 redirect covers the same scenario as the .cfm files from ASAP-161.

@lkacenja
lkacenja requested a review from allisonmorgan July 24, 2025 14:42

@allisonmorgan allisonmorgan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks great! Thank you for mocking up the tests and for digging into this. I confirmed that this URL getting approach worked for the Georgia sites you flagged, while also still working for SLC.

I did notice more failures on Austin documents, but I don't think this is related to the code changes here because they appear to fail when I navigate to them on their site via my web browser. Since that lead has gone cold, I don't think it's worth figuring out what's happening there.

@lkacenja

lkacenja commented Jul 28, 2025

Copy link
Copy Markdown
Contributor Author

I did notice more failures on Austin documents, but I don't think this is related to the code changes here because they appear to fail when I navigate to them on their site via my web browser. Since that lead has gone cold, I don't think it's worth figuring out what's happening there.

Yes, I noticed this as well. I think they may have increased security on their document URLs. The .cfm files give me this error when I visit them with the browser.

Screenshot 2025-07-28 at 8 53 25 AM

@lkacenja
lkacenja merged commit c731e15 into dev Jul 28, 2025
2 checks passed
@lkacenja
lkacenja deleted the asap-204-change-all-file-handling-to-requests branch April 7, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants