Skip to content

Conversation

@crugas
Copy link
Collaborator

@crugas crugas commented Dec 5, 2025

Description

Created a new script that updates the building field for a location. update_locationbuilding.py retrieves location IDs with a given building name passed in the oB (originalBuilding) argument using an SQL query to the ASpace database. Then it takes a list of those IDs and retrieves their JSON data from the API and updates the building field with the argument passed in the uB (updatedBuilding) argument. Then it posts the updated location JSON data to ArchivesSpace, saving the original JSON data in a given .jsonl file and logging the results of the update to a given log file. NOTE: put "" around the building name if it contains spaces, like so: -uB="NMAH-FSD, Building 92".

I also updated utilities_testdata.py since the digital object that was used for testing various get operations was deleted. Replaced it with a digital object in the test repository on ASpace PROD until we can implement #66.

Also, added another unittest for utilities_tests.py, renamed update_locations.py to update_locationrepo.py, and other small updates.

@lorawoodford Put this as a draft, in case you think it would be better in the repeatable folder, not one_time_scripts. I could see us using this in the future, but not frequently (I hope).

Related GitHub Issue

#137

Testing

Wrote unittests via updatelocationbuilding_tests.py

Screenshot(s):

Checklist

  • ✔️ Have you assigned at least one reviewer?
  • 🔗 Have you referenced any issues this PR will close?
  • ⬇️ Have you merged the latest upstream changes into your branch?
  • 🧪 Have you added tests to cover these changes? If not, why:
  • 📘 Have you updated/added any relevant readmes/wiki pages/comments in the codebase?
  • 📚 Have you updated/added any external documentation (e.g. Confluence, AirTable, GitHub Projects)?

…y, updated utilities_testdata.py to successfully run on PROD data, updated query_database in utilities.py to more accurately reflect error thrown, added test_invalid_query to utilities_tests.py, renamed update_locations.py to update_locationrepo.py
@crugas crugas linked an issue Dec 5, 2025 that may be closed by this pull request
18 tasks
@crugas crugas requested a review from lorawoodford December 5, 2025 15:45
Copy link
Contributor

@lorawoodford lorawoodford left a comment

Choose a reason for hiding this comment

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

@crugas This all looks good, and I think is fine in one-time scripts. That said, I just am wondering why we can't just use the built-in batch_update endpoint in the API and avoid having a script altogether? I haven't tried this yet, but looking at the endpoint, you should be able to post a payload like this to /locations/batch_update and get the same result without have to post-back full location json over and over:

{
    "building": "Updated Building Name",
    "record_uris": ["/locations/1","/locations/2","/locations/3"]
}

@crugas
Copy link
Collaborator Author

crugas commented Dec 5, 2025

@lorawoodford Oh my gosh, I completely forgot about that endpoint! That would be infinitely better and quite a bit faster too. I may end up refactoring the script so that it can use this endpoint (I've already confirmed the changes with NMAH), since it would be useful if we do need to use it again.

But, I also need to update the original ticket, since NMAH wants text from the Room field into the Floor field - which may vary (but shouldn't because it's a one-story building) if we need to run the script again. So, I'll give this more thought before submitting, since I need to rethink how to approach the original script's endpoint to hit and the updated requirements for the task.

@lorawoodford
Copy link
Contributor

lorawoodford commented Dec 5, 2025 via email

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.

[PROJECT_REQUEST]: Update Location Name for NMAH

2 participants