Page MenuHomeSoftware Heritage

models: Add explicit app_label
ClosedPublic

Authored by anlambert on Apr 20 2021, 3:27 PM.

Details

Summary

Explicitely set app_label to models in order to avoid import
errors when using sphinx autodoc.

WARNING: autodoc: failed to import module 'urls' from module 'swh.deposit'; the following exception was raised:
Traceback (most recent call last):
  File "/home/anlambert/swh/swh-environment/swh-docs/.tox/sphinx-dev/lib/python3.7/site-packages/sphinx/ext/autodoc/importer.py", line 71, in import_module
    return importlib.import_module(modname)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/anlambert/swh/swh-environment/swh-docs/.tox/sphinx-dev/lib/python3.7/site-packages/swh/deposit/urls.py", line 40, in <module>
    url(r"^1/", include("swh.deposit.api.urls")),
  File "/home/anlambert/swh/swh-environment/swh-docs/.tox/sphinx-dev/lib/python3.7/site-packages/django/urls/conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/anlambert/swh/swh-environment/swh-docs/.tox/sphinx-dev/lib/python3.7/site-packages/swh/deposit/api/urls.py", line 14, in <module>
    from .collection import CollectionAPI
  File "/home/anlambert/swh/swh-environment/swh-docs/.tox/sphinx-dev/lib/python3.7/site-packages/swh/deposit/api/collection.py", line 11, in <module>
    from ..models import Deposit
  File "/home/anlambert/swh/swh-environment/swh-docs/.tox/sphinx-dev/lib/python3.7/site-packages/swh/deposit/models.py", line 32, in <module>
    class Dbversion(models.Model):
  File "/home/anlambert/swh/swh-environment/swh-docs/.tox/sphinx-dev/lib/python3.7/site-packages/django/db/models/base.py", line 111, in __new__
    "INSTALLED_APPS." % (module, name)
RuntimeError: Model class swh.deposit.models.Dbversion doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

The label is the same as before so no migration is required.

swh) ✔ ~/swh/swh-environment/swh-deposit [models-explicit-app-label L|✔] 
15:26 $ python3 swh/deposit/manage.py makemigrations
/home/anlambert/.virtualenvs/swh/lib/python3.7/site-packages/jose/backends/cryptography_backend.py:18: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
  from cryptography.utils import int_from_bytes, int_to_bytes
No changes detected

Diff Detail

Repository
rDDEP Push deposit
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D5562 (id=19869)

Rebasing onto 65725672b4...

Current branch diff-target is up to date.
Changes applied before test
commit 1beb29a92c892c8c872610b09e59996d12525f5a
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Tue Apr 20 15:22:07 2021 +0200

    models: Add explicit app_label
    
    Explicitely set app_label to models in order to avoid import
    errors when using sphinx autodoc.
    
    The label is the same as before so no migration is required.

See https://jenkins.softwareheritage.org/job/DDEP/job/tests-on-diff/638/ for more details.

This revision is now accepted and ready to land.Apr 20 2021, 3:35 PM
This revision was automatically updated to reflect the committed changes.