hcarter333 / datasette-enrichments-gmap-geocode

Apache License 2.0
1 stars 1 forks source link

Make first release #4

Closed hcarter333 closed 11 months ago

hcarter333 commented 11 months ago

Make the first release of the package.

I may have to change the name to start with datasette-enrichment...

hcarter333 commented 11 months ago

Changed the repository name to live in the datasaette space. Now, I need to change all the names in the source code and yaml file so that they do as well.

hcarter333 commented 11 months ago

Spent the afternoon looking for this fix: `def resolve_api_key(datasette, config): plugin_config = datasette.plugin_config("datasette-enrichments-gmap-geocode") or {} api_key = plugin_config.get("api_key") if api_key: return api_key

Look for it in config

api_key_name = config.get("api_key")
if not api_key_name:
    raise ApiKeyError("No API key reference found in config")
# Look it up in the stash
#                          datasette_enrichments_gmaps_api_stashed_keys
if not hasattr(datasette, "_enrichments_gmap_geocode_stashed_keys"):
    raise ApiKeyError("No API key stash found")
stashed_keys = datasette._enrichments_gmap_geocode_stashed_keys
if api_key_name not in stashed_keys:
    raise ApiKeyError("No API key found in stash for {}".format(api_key_name))
return stashed_keys[api_key_name]

`

Instead of this `def resolve_api_key(datasette, config): plugin_config = datasette.plugin_config("datasette-enrichments-gmap-geocode") or {} api_key = plugin_config.get("api_key") if api_key: return api_key

Look for it in config

api_key_name = config.get("api_key")
if not api_key_name:
    raise ApiKeyError("No API key reference found in config")
# Look it up in the stash
#                          datasette_enrichments_gmaps_api_stashed_keys
if not hasattr(datasette, "datasette_enrichments_gmap_geocode_stashed_keys"):
    raise ApiKeyError("No API key stash found")
stashed_keys = datasette.datasette_enrichments_gmap_geocode_stashed_keys
if api_key_name not in stashed_keys:
    raise ApiKeyError("No API key found in stash for {}".format(api_key_name))
return stashed_keys[api_key_name]

`

That hurts so much!

For whatever reasion, raise ApiKeyError("No API key reference found in config")

Never fired a message because the code is not executed in a try block.

hcarter333 commented 11 months ago

In general, errors that look like this mean something else is going on:

`E AssertionError: The following responses are mocked but not requested: E Match GET requests on re.compile('https://maps.googleapis.com/maps/api/geocode/json.*') E assert not [<pytest_httpx._request_matcher._RequestMatcher object at 0x780db62e9700>]

../.local/lib/python3.9/site-packages/pytest_httpx/_httpx_mock.py:257: AssertionError`

hcarter333 commented 11 months ago

Looks like this was the next issue:

plugin_config = datasette.plugin_config("datasette-enrichments-gmap-geocode") or {}

And It Was! OK, all test cases are passing!!!

hcarter333 commented 11 months ago

All test cases passing!

Next step is to figure out how to make a release.

hcarter333 commented 11 months ago

For releasing see: https://github.com/datasette/datasette-enrichments-opencage/blob/main/.github/workflows/publish.yml

Looks like I should be able to add the workflow in just a bit fairly easily.

hcarter333 commented 11 months ago

Working through the release flow this morning. I'm using the twine docs as a guide.

Turns out build is a python module so I had to install it: python3 -m build I'm also using the example for the datasette opencage deployment.

That led me to cd into the datasette-enrichments-gmap-geocode directory to run build. At that point I discovered that I didn't have venv installed:

* Creating venv isolated environment...
The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt-get install python3-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: ['/tmp/build-env-1prfqag_/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

After hemming and hawing about not wanting to use sudo I finally did python3 -m pip install --upgrade pip followed by sudo apt-get install python3-venv

and was rewarded with image

And! The dist directory is there! It's not just a concep that should be named something else. (Common first time through instructions confusion for me.)

image

The results were good and bad. While it clearly didn't complete, I at least know my password :) image

I then used these instructions and tried again

And success! image

Moving back to the twine instructions...

I tried to run the command for a real release twine upload dist/* which led me through the same token instructions for pypi rather than testpypi. Trying again...

And it worked!!! image

hcarter333 commented 11 months ago

Another interesting thing. github creates the tar code assets when the release is published. I did not have to provide them. image

Again, this makes sense, I just didn't know the first time.

hcarter333 commented 11 months ago

The next step... for the next release is to copy the datasette-opencate publish workflow to this repository.