Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove boto3 dependency #3073

Merged
merged 1 commit into from
Oct 2, 2023
Merged

Conversation

ngken0995
Copy link
Collaborator

Fixes

Fixes #2305 by @krysal

Description

Remove boto3 dependency from api folder because api doesn't use API bucket.

Testing Instructions

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (if applicable).

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@ngken0995 ngken0995 requested a review from a team as a code owner September 28, 2023 13:44
@ngken0995 ngken0995 requested review from krysal and dhruvkb September 28, 2023 13:44
@openverse-bot openverse-bot added 🟩 priority: low Low priority and doesn't need to be rushed 💻 aspect: code Concerns the software code in the repository 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🧱 stack: api Related to the Django API labels Sep 28, 2023
Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

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

You will also need to update the lockfile. The ideal way to uninstall a package (that updates both the Pipfile and Pipfile.lock) is to open a shell into the web container and use Pipenv to uninstall the deps.

[host]$ just api/exec bash
[docker]$ pipenv uninstall boto3

@ngken0995
Copy link
Collaborator Author

ngken0995 commented Sep 28, 2023

@dhruvkb I couldn't get the command running properly. I went on the docker desktop and locate the openverse-web-1 container exec prompt and ran pipenv uninstall boto3. This did the job to remove boto3 from Pipfile and Pipfile.lock

@ngken0995
Copy link
Collaborator Author

@dhruvkb Build Docker images for api and api_nginx is failing because my Pipfile.lock (466a7e) is out of date and expecting (4c22ae). How can I resolve for this to pass?

@dhruvkb
Copy link
Member

dhruvkb commented Sep 28, 2023

Pipfile.lock records a checksum of the Pipfile to ensure that they're in sync. In this PR, this checksum is not matching and so the image refuses to build.

https://github.com/WordPress/openverse/actions/runs/6342392983/job/17228114541?pr=3073#step:7:381

To fix this, I would recommend hard resetting to origin/main, building a fresh image of the web service, exec-ing into the container and then removing Boto. This should look like these steps.

$ git reset --hard origin/main
$ just dc build web
$ just api/up
$ just dc up -d --force-recreate web
$ just dc exec web bash
[docker]$ pipenv uninstall boto3
[docker]$ exit
$ git add Pipfile Pipfile.lock

Lmk how it goes. Doing it this way will ensure that the final Pipfile.lock has an updated SHA256 hash and validates against the Pipfile.

@ngken0995
Copy link
Collaborator Author

ngken0995 commented Sep 28, 2023

@dhruvkb once I run pipenv uninstall boto3 There is an error which state PermissionError: [Errno 13] Permission denied: '/api/.__atomic-writecd0k9b0a'. This might be related to my ubuntu set up.

result traceback:

Traceback (most recent call last):
  File "/venv/bin/pipenv", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/venv/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/pipenv/cli/options.py", line 58, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/pipenv/vendor/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/pipenv/cli/command.py", line 287, in uninstall
    retcode = do_uninstall(
              ^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/pipenv/routines/uninstall.py", line 171, in do_uninstall
    do_lock(project, system=system, pypi_mirror=pypi_mirror)
  File "/venv/lib/python3.11/site-packages/pipenv/routines/lock.py", line 89, in do_lock
    project.write_lockfile(lockfile)
  File "/venv/lib/python3.11/site-packages/pipenv/project.py", line 1003, in write_lockfile
    with atomic_open_for_write(self.lockfile_location, **open_kwargs) as f:
  File "/usr/local/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/pipenv/utils/locking.py", line 209, in atomic_open_for_write
    f = NamedTemporaryFile(
        ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/tempfile.py", line 563, in NamedTemporaryFile
    file = _io.open(dir, mode, buffering=buffering,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/tempfile.py", line 560, in opener
    fd, name = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/tempfile.py", line 256, in _mkstemp_inner
    fd = _os.open(file, flags, 0o600)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/api/.__atomic-writecd0k9b0a'

@ngken0995 ngken0995 requested a review from dhruvkb September 28, 2023 23:53
@dhruvkb
Copy link
Member

dhruvkb commented Sep 29, 2023

Yeah, this seems like a setup issue but we'll need more info to determine why permissions are not working as exepcted (also seen in another PR where Playwright wouldn't run). I'll tag @AetherUnbound and @sarayourfriend here as they are the maintainers who have active Linux dev machines and might be able to help more.

Meanwhile, you can skip the part where we exec into the dev container and run the commands on the host. The main reason for doing this in the host was to avoid OS-related issues but if you're on Linux, that should not be necessary.

$ git reset --hard origin/main
$ cd api/
$ pipenv uninstall boto3
$ git add Pipfile Pipfile.lock

@ngken0995 ngken0995 force-pushed the remove-boto3-and-related branch from ba12de1 to 7549884 Compare September 29, 2023 14:24
@ngken0995
Copy link
Collaborator Author

@dhruvkb Thank you for the guidance. It works and all the git actions have passed.

Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

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

All good, thanks for the contribution @ngken0995!

@sarayourfriend
Copy link
Collaborator

Meanwhile, you can skip the part where we exec into the dev container and run the commands on the host. The main reason for doing this in the host was to avoid OS-related issues but if you're on Linux, that should not be necessary.

@dhruvkb I wasn't aware that it was possible to run pipenv inside the container. Is that something you use on a regular basis? It would save a lot of time when making changes to dependency if we worked that way because it removes the requirement to rebuild the container after changing Pipfile.

Copy link
Collaborator

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

LGTM!

@dhruvkb
Copy link
Member

dhruvkb commented Oct 2, 2023

Yes @sarayourfriend I mostly always use Pipenv inside the container, because it prevents the needless small diff changes between running Pipenv on a Mac vs Linux. IIRC Pipenv changes some metadata based on the OS, so running it in the container reduces this.

Also Pipenv had to be installed in the container because we need it to install packages using the lockfile.

@dhruvkb dhruvkb changed the title Remove boto3 Dependency Remove boto3 dependency Oct 2, 2023
@dhruvkb dhruvkb merged commit 4021cbe into WordPress:main Oct 2, 2023
44 checks passed
ngken0995 added a commit to ngken0995/openverse that referenced this pull request Oct 4, 2023
…WordPress#3055)

* change deprecated ES search body

* trim white space

Add thumbnail repsonse time runbooks (WordPress#3053)

* Add thumb repsonse time runbooks

* Add files to index

* Threshold alarms are low severity if not anomalous

generate-dag-docs recipe move DAGs.md to documentation folder (WordPress#3061)

Co-authored-by: Madison Swain-Bowden <[email protected]>

Upgrade psycopg to version 3 in the API (WordPress#3064)

Update VSourcesTable.vue (WordPress#3026)

Co-authored-by: sarayourfriend <[email protected]>
Co-authored-by: Olga Bulat <[email protected]>
Co-authored-by: Krystle Salazar <[email protected]>

Transfer UUID validation inside serializer (WordPress#3068)

* Transfer UUID validation inside serializer

* Add test case

Publish changelog for api-2023.09.28.00.26.34 (WordPress#3070)

Co-authored-by: AetherUnbound <[email protected]>

Use fully qualified docker image names (WordPress#3071)

Publish changelog for ingestion_server-2023.09.29.17.40.50 (WordPress#3082)

Co-authored-by: stacimc <[email protected]>

Update `_AIRFLOW_DB_UPGRADE` to `_AIRFLOW_DB_MIGRATE`

Increase the API sources cache TTL from 20 minutes to 4 hours (WordPress#3083)

Publish changelog for api-2023.09.30.00.15.32 (WordPress#3084)

Co-authored-by: AetherUnbound <[email protected]>

Bump ipython from 8.14.0 to 8.16.0 in /automations/python (WordPress#3099)

Bumps [ipython](https://github.com/ipython/ipython) from 8.14.0 to 8.16.0.
- [Release notes](https://github.com/ipython/ipython/releases)
- [Commits](ipython/ipython@8.14.0...8.16.0)

---
updated-dependencies:
- dependency-name: ipython
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Remove boto3 dependency (WordPress#3073)

Bump docker/login-action from 2 to 3 (WordPress#3089)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump elasticsearch from 8.8.2 to 8.10.0 in /api (WordPress#3103)

Bumps [elasticsearch](https://github.com/elastic/elasticsearch-py) from 8.8.2 to 8.10.0.
- [Release notes](https://github.com/elastic/elasticsearch-py/releases)
- [Commits](elastic/elasticsearch-py@v8.8.2...v8.10.0)

---
updated-dependencies:
- dependency-name: elasticsearch
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump psycopg2 from 2.9.7 to 2.9.8 in /ingestion_server (WordPress#3097)

Bumps [psycopg2](https://github.com/psycopg/psycopg2) from 2.9.7 to 2.9.8.
- [Changelog](https://github.com/psycopg/psycopg2/blob/master/NEWS)
- [Commits](psycopg/psycopg2@2.9.7...2.9.8)

---
updated-dependencies:
- dependency-name: psycopg2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump elasticsearch from 8.8.2 to 8.10.0 in /ingestion_server (WordPress#3095)

Bumps [elasticsearch](https://github.com/elastic/elasticsearch-py) from 8.8.2 to 8.10.0.
- [Release notes](https://github.com/elastic/elasticsearch-py/releases)
- [Commits](elastic/elasticsearch-py@v8.8.2...v8.10.0)

---
updated-dependencies:
- dependency-name: elasticsearch
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump pygithub from 1.59.1 to 2.1.1 in /automations/python (WordPress#3102)

Bumps [pygithub](https://github.com/pygithub/pygithub) from 1.59.1 to 2.1.1.
- [Release notes](https://github.com/pygithub/pygithub/releases)
- [Changelog](https://github.com/PyGithub/PyGithub/blob/main/doc/changes.rst)
- [Commits](PyGithub/PyGithub@v1.59.1...v2.1.1)

---
updated-dependencies:
- dependency-name: pygithub
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump furo from 2023.8.19 to 2023.9.10 in /documentation (WordPress#3092)

Bumps [furo](https://github.com/pradyunsg/furo) from 2023.8.19 to 2023.9.10.
- [Release notes](https://github.com/pradyunsg/furo/releases)
- [Changelog](https://github.com/pradyunsg/furo/blob/main/docs/changelog.md)
- [Commits](pradyunsg/furo@2023.08.19...2023.09.10)

---
updated-dependencies:
- dependency-name: furo
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump docker/build-push-action from 4 to 5 (WordPress#3090)

Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4 to 5.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](docker/build-push-action@v4...v5)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump actions/checkout from 3 to 4 (WordPress#3088)

Bump docker/setup-buildx-action from 2 to 3 (WordPress#3087)

Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2 to 3.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](docker/setup-buildx-action@v2...v3)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump fakeredis from 2.18.0 to 2.19.0 in /api (WordPress#3100)

Bumps [fakeredis](https://github.com/cunla/fakeredis-py) from 2.18.0 to 2.19.0.
- [Release notes](https://github.com/cunla/fakeredis-py/releases)
- [Commits](cunla/fakeredis-py@v2.18.0...v2.19.0)

---
updated-dependencies:
- dependency-name: fakeredis
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Show timeout errors on the frontend (WordPress#2838)

* Show timeout errors on the frontend

* Use FetchingError in all stores

* Fix error

* Show client-side errors on single result pages

* Set 500 as a non-retriable error

* Add changes from code review

* Use local base64 image for thumbnail

* Fix footer

* Fix image-cell test

* Extract common error checking functionality

* Update unit tests

Add runbooks for API Thumbnails 2XX/5XX responses and Request Count alarms (WordPress#3076)

Bump jsonschema from 4.19.0 to 4.19.1 in /ingestion_server (WordPress#3098)

Bumps [jsonschema](https://github.com/python-jsonschema/jsonschema) from 4.19.0 to 4.19.1.
- [Release notes](https://github.com/python-jsonschema/jsonschema/releases)
- [Changelog](https://github.com/python-jsonschema/jsonschema/blob/main/CHANGELOG.rst)
- [Commits](python-jsonschema/jsonschema@v4.19.0...v4.19.1)

---
updated-dependencies:
- dependency-name: jsonschema
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump ipython from 8.15.0 to 8.16.1 in /ingestion_server (WordPress#3110)

Bumps [ipython](https://github.com/ipython/ipython) from 8.15.0 to 8.16.1.
- [Release notes](https://github.com/ipython/ipython/releases)
- [Commits](https://github.com/ipython/ipython/commits)

---
updated-dependencies:
- dependency-name: ipython
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump sphinx from 7.2.5 to 7.2.6 in /documentation (WordPress#3091)

Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 7.2.5 to 7.2.6.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/master/CHANGES.rst)
- [Commits](sphinx-doc/sphinx@v7.2.5...v7.2.6)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump tldextract from 3.4.4 to 3.6.0 in /catalog (WordPress#3093)

Bumps [tldextract](https://github.com/john-kurkowski/tldextract) from 3.4.4 to 3.6.0.
- [Release notes](https://github.com/john-kurkowski/tldextract/releases)
- [Changelog](https://github.com/john-kurkowski/tldextract/blob/master/CHANGELOG.md)
- [Commits](john-kurkowski/tldextract@3.4.4...3.6.0)

---
updated-dependencies:
- dependency-name: tldextract
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump urllib3 from 2.0.5 to 2.0.6 in /documentation (WordPress#3120)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump urllib3 from 1.26.16 to 1.26.17 in /api (WordPress#3123)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump urllib3 from 2.0.5 to 2.0.6 in /automations/python (WordPress#3119)

Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.0.5 to 2.0.6.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](urllib3/urllib3@v2.0.5...2.0.6)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump urllib3 from 1.26.16 to 1.26.17 in /ingestion_server (WordPress#3124)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

implement vale

determine files

mircosoft sentence format

change alert level

change alert level

change alert level

change alert level

change alert level

change alert level

change alert level

Empty-Commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: api Related to the Django API
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Remove boto3 dependency and the s3 configuration from the API
4 participants