Page MenuHomeSoftware Heritage

webapp: Migrate to Use the object's object_type field
ClosedPublic

Authored by ardumont on Jun 30 2020, 11:24 AM.

Details

Summary

Related to D3152

Test Plan

tox

Diff Detail

Repository
rDWAPPS Web applications
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 13224
Build 20191: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 20190: arc lint + arc unit

Event Timeline

Build has FAILED

Patch application report for D3373 (id=11973)

Rebasing onto a8d4c61935...

Current branch diff-target is up to date.
Changes applied before test
commit 3f49522bff4e9633b03947211f4a3a0ed7bea953
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Tue Jun 30 10:51:46 2020 +0200

    Migrate to Use the object's object_type field
    
    Related to D3152

Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/244/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/244/console

anlambert added a subscriber: anlambert.
anlambert added inline comments.
swh/web/tests/views.py
48

I would rather use Content.object_type here instead of hard-coding the string value.

Also I can not find a model object with the "content_file" type. Where does it come from ?

This revision now requires changes to proceed.Jun 30 2020, 11:56 AM
swh/web/tests/views.py
48

It comes from DiskBackedContent, changed introduced in D3152.

swh/web/tests/views.py
48

I would rather use Content.object_type here instead of hard-coding the string value.

I did not grasp what you meant, sorry.

Build has FAILED

Patch application report for D3373 (id=11973)

Rebasing onto 9be63da1dd...

First, rewinding head to replay your work on top of it...
Applying: Migrate to Use the object's object_type field
Changes applied before test
commit 675d072ad6690e431a081167360e6e5477e03901
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Tue Jun 30 10:51:46 2020 +0200

    Migrate to Use the object's object_type field
    
    Related to D3152

Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/246/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/246/console

swh/web/tests/views.py
48
from swh.model.model import Content, DiskBackedContent

if obj.object_type in (Content.object_type, DiskBackedContent.object_type):
swh/web/tests/views.py
48

ah ok. Here we go then ;)

swh/web/tests/views.py
48

Ok, DiskBackedContent is in swh.model.from_disk, that's why I missed it

ardumont edited the test plan for this revision. (Show Details)

Adapt according to review
Rebase on latest master

This revision is now accepted and ready to land.Jun 30 2020, 12:18 PM

Build has FAILED

Patch application report for D3373 (id=11979)

Rebasing onto d4e37c158b...

Current branch diff-target is up to date.
Changes applied before test
commit 294fd97633370ab929d2233cd259b13f911064b1
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Tue Jun 30 10:51:46 2020 +0200

    Migrate to Use the object's object_type field
    
    Related to D3152

Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/247/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/247/console

lol

anlambert unhappy
jenkin happy

now

anlambert happy
jenkins unhappy

come on ;)

lol

anlambert unhappy
jenkin happy

now

anlambert happy
jenkins unhappy

come on ;)

What the heck ! swh-model seems at the right version, I do not get the error.

I'll check after food time.

(Need to unstuck the debian model build first)

Build has FAILED

Patch application report for D3373 (id=11979)

Rebasing onto d4e37c158b...

Current branch diff-target is up to date.
Changes applied before test
commit 294fd97633370ab929d2233cd259b13f911064b1
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Tue Jun 30 10:51:46 2020 +0200

    Migrate to Use the object's object_type field
    
    Related to D3152

Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/248/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/248/console

I'll check after food time.

(Need to unstuck the debian model build first)

Found the issue (D3375), I am the one to blame here.

I'll check after food time.

(Need to unstuck the debian model build first)

done

Found the issue (D3375), I am the one to blame here.

heh, i'm not programmed for that ;)

Nice, thanks.

I'll wait and rebase on your diff then ;)

Cheers,

Build was aborted

Patch application report for D3373 (id=11988)

Rebasing onto fcd8604928...

Current branch diff-target is up to date.
Changes applied before test
commit c385f65e5dbfd67cd0e17f60baf97794c068b99d
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Tue Jun 30 10:51:46 2020 +0200

    Migrate to Use the object's object_type field
    
    Related to D3152

Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/250/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/250/console

Build was aborted

Patch application report for D3373 (id=11988)

Rebasing onto fcd8604928...

Current branch diff-target is up to date.
Changes applied before test
commit c385f65e5dbfd67cd0e17f60baf97794c068b99d
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Tue Jun 30 10:51:46 2020 +0200

    Migrate to Use the object's object_type field
    
    Related to D3152

Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/251/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/251/console

Rebase (hopefully the build won't get stuck ;)

Build was aborted

Patch application report for D3373 (id=12005)

Rebasing onto 91f81bb1e4...

Current branch diff-target is up to date.
Changes applied before test
commit 406cf0b32c6f47a3eb4ea0ee03389c98761f17e0
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Tue Jun 30 10:51:46 2020 +0200

    Migrate to Use the object's object_type field
    
    Related to D3152

Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/253/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/253/console

So it seems D3375 did not fix the issue after all, jeez

Traceback (most recent call last):
  File "/usr/lib/python3.7/wsgiref/handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/wsgi.py", line 141, in __call__
    response = self.get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/base.py", line 75, in get_response
    response = self._middleware_chain(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/antoine/swh/swh-environment/swh-web/swh/web/auth/middlewares.py", line 33, in __call__
    return self.get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/antoine/swh/swh-environment/swh-web/swh/web/common/middlewares.py", line 66, in __call__
    resp = self.get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/rest_framework/views.py", line 505, in dispatch
    response = self.handle_exception(exc)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/rest_framework/views.py", line 465, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
    raise exc
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/rest_framework/views.py", line 502, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/antoine/.virtualenvs/swh/lib/python3.7/site-packages/rest_framework/decorators.py", line 50, in handler
    return func(*args, **kwargs)
  File "/home/antoine/swh/swh-environment/swh-web/swh/web/tests/views.py", line 107, in get_content_code_data_all_exts
    _init_content_code_data_exts()
  File "/home/antoine/swh/swh-environment/swh-web/swh/web/tests/views.py", line 73, in _init_content_code_data_exts
    "resources/contents/code/extensions", _content_code_data_exts, True
  File "/home/antoine/swh/swh-environment/swh-web/swh/web/tests/views.py", line 48, in _init_content_tests_data
    if obj.object_type in [Content.object_type, DiskBackedContent.object_type]:
AttributeError: 'Content' object has no attribute 'object_type'

Ok got it, turns out from_disk.Directory.from_disk does not return swh.model.model objects but swh.model.from_disk ones. Those does not have the object_type field thus the AttributeError.

Renaming the type field of those classes to object_type will fix the issue.

Ok got it, turns out from_disk.Directory.from_disk does not return swh.model.model objects but swh.model.from_disk ones. Those does not have the object_type field thus the AttributeError.

Renaming the type field of those classes to object_type will fix the issue.

In fact, there is a simpler fix: s/obj.object_type/obj.to_model().object_type/.

Adapt according to review.

I absolutely did not realize this part was about using front tests.
And I was only doing pytest runs ¯\_(ツ)_/¯.

Thanks!

Build is green

Patch application report for D3373 (id=12010)

Rebasing onto 91f81bb1e4...

Current branch diff-target is up to date.
Changes applied before test
commit f433684afd32cf385e7262abfa1f015e00ed72ba
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Tue Jun 30 10:51:46 2020 +0200

    Migrate to Use the object's object_type field
    
    Related to D3152

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