Repository: internetarchive/openlibrary

Issue:
Solr Builder failing after Docker rebuild
<!-- What problem are we solving? What does the experience look like today? What are the symptoms? -->
After rebuilding Docker today, I am unable to start my local Open Library instance without error.  When starting the instance, `home_1` crashes during the `reindex-solr` task.  Here are the `home_1` logs:

```
home_1          | Python 3.9.4
home_1          | Waiting for postgres...
home_1          | db:5432 - accepting connections
home_1          | psql --host db openlibrary -t -c 'select key from thing' | sed 's/ *//' | grep '^/books/' | PYTHONPATH=/openlibrary xargs python openlibrary/solr/update_work.py --ol-url http://web:8080/ --ol-config conf/openlibrary.yml --data-provider=legacy
home_1          | Traceback (most recent call last):
home_1          |   File "/openlibrary/openlibrary/solr/update_work.py", line 4, in <module>
home_1          |     import logging
home_1          |   File "/home/openlibrary/.pyenv/versions/3.9.4/lib/python3.9/logging/__init__.py", line 26, in <module>
home_1          |     import sys, os, time, io, re, traceback, warnings, weakref, collections.abc
home_1          |   File "/home/openlibrary/.pyenv/versions/3.9.4/lib/python3.9/re.py", line 124, in <module>
home_1          |     import enum
home_1          |   File "/home/openlibrary/.pyenv/versions/3.9.4/lib/python3.9/enum.py", line 2, in <module>
home_1          |     from types import MappingProxyType, DynamicClassAttribute
home_1          |   File "/openlibrary/openlibrary/solr/types.py", line 2, in <module>
home_1          |     from typing import TypedDict, Optional, List, Literal
home_1          |   File "/home/openlibrary/.pyenv/versions/3.9.4/lib/python3.9/typing.py", line 23, in <module>
home_1          |     import contextlib
home_1          |   File "/home/openlibrary/.pyenv/versions/3.9.4/lib/python3.9/contextlib.py", line 6, in <module>
home_1          |     from functools import wraps
home_1          |   File "/home/openlibrary/.pyenv/versions/3.9.4/lib/python3.9/functools.py", line 22, in <module>
home_1          |     from types import GenericAlias
home_1          | ImportError: cannot import name 'GenericAlias' from partially initialized module 'types' (most likely due to a circular import) (/openlibrary/openlibrary/solr/types.py)
home_1          | Makefile:62: recipe for target 'reindex-solr' failed
home_1          | make: *** [reindex-solr] Error 123
openlibrary_home_1 exited with code 2
```

### Evidence / Screenshot (if possible)

### Relevant url?
<!-- `https://openlibrary.org/...` -->

### Steps to Reproduce
<!-- What steps caused you to find the bug? -->
1. Rebuild Docker, using [these instructions](https://github.com/internetarchive/openlibrary/tree/master/docker#fully-resetting-your-environment)
2. Attempt to start Open Library using `docker-compose up`
3. Watch the logs.

<!-- What actually happened after these steps? What did you expect to happen? -->
* Actual: `home_1` crashes due to a possible circular import error.
* Expected: `home_1` shuts down safely after updating Solr.

### Details

- **Logged in (Y/N)?** N/A
- **Browser type/version?** N/A
- **Operating system?** Ubuntu 18.04
- **Environment (prod/dev/local)?** Local
<!-- If not sure, put prod -->

### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->
It's been a few months since I've rebuilt my local instance, and sometimes issues similar to this don't manifest until the environment is rebuilt.  Checking the past two or three months' history on the files mentioned in the logs is probably a good way to start troubleshooting this. I would start with any changes to the files' imports.

### Related files
<!-- Files related to this issue; this is super useful for new contributors who might want to help! If you're not sure, leave this blank; a maintainer will add them. -->

### Stakeholders
<!-- @ tag stakeholders of this bug -->



Discussion:

Resolving patch:
diff --git a/openlibrary/solr/types.py b/openlibrary/solr/solr_types.py
similarity index 100%
rename from openlibrary/solr/types.py
rename to openlibrary/solr/solr_types.py
diff --git a/openlibrary/solr/update_work.py b/openlibrary/solr/update_work.py
--- a/openlibrary/solr/update_work.py
+++ b/openlibrary/solr/update_work.py
@@ -30,7 +30,7 @@
 from openlibrary.core import helpers as h
 from openlibrary.plugins.upstream.utils import url_quote
 from openlibrary.solr.data_provider import get_data_provider, DataProvider
-from openlibrary.solr.types import SolrDocument
+from openlibrary.solr.solr_types import SolrDocument
 from openlibrary.utils import uniq
 from openlibrary.utils.ddc import normalize_ddc, choose_sorting_ddc
 from openlibrary.utils.isbn import opposite_isbn


Test patch:
diff --git a/openlibrary/tests/solr/test_types_generator.py b/openlibrary/tests/solr/test_types_generator.py
--- a/openlibrary/tests/solr/test_types_generator.py
+++ b/openlibrary/tests/solr/test_types_generator.py
@@ -7,7 +7,7 @@
 
 
 def test_up_to_date():
-    types_path = os.path.join(root, '..', '..', 'solr', 'types.py')
+    types_path = os.path.join(root, '..', '..', 'solr', 'solr_types.py')
     assert generate().strip() == open(types_path).read().strip(), """
     This auto-generated file is out-of-date. Run:
     ./openlibrary/solr/types_generator.py > ./openlibrary/solr/types.py`