QEats module 3 returning of lists of taga

  1. Describe the issue briefly
    after requesting on clarifai i got some binary or bytes data …and i dont know what to return by the def get_tags_suggestions(api_key, image_url):
    this fuction return this or what???
    gettting confused what to return after this…or this is correct output::::???

b’{“status”:{“code”:10000,“description”:“Ok”,“req_id”:“f3e8d9aad7774d7fbbf5e7d3f00450cf”},“outputs”:[{“id”:“a4d5b67af97a4eb598b9886fbcff93b9”,“status”:{“code”:10000,“description”:“Ok”},“created_at”:“2020-04-11T07:04:10.825952300Z”,“model”:{“id”:“bd367be194cf45149e75f01d59f77ba7”,“name”:“food-items-v1.0”,“created_at”:“2016-09-17T22:18:59.955626Z”,“app_id”:“main”,“output_info”:{“output_config”:{“concepts_mutually_exclusive”:false,“closed_environment”:false,“max_concepts”:0,“min_value”:0},“message”:“Show output_info with: GET /models/{model_id}/output_info”,“type”:“concept”,“type_ext”:“concept”},“model_version”:{“id”:“dfebc169854e429086aceb8368662641”,“created_at”:“2016-09-17T22:18:59.955626Z”,“status”:{“code”:21100,“description”:“Model is trained and ready”},“worker_id”:“a0966e7403e8488fb9f23b17517be638”},“display_name”:“Food”},“input”:{“id”:“49a3bbea160348e8ac3fce0088c59960”,“data”:{“image”:{“url”:“https://samples.clarifai.com/food.jpg"}}},“data”:{“concepts”:[{“id”:“ai_GC6FB0cQ”,“name”:“sauce”,“value”:0.99833155,“app_id”:“main”},{“id”:“ai_fBH5DFMJ”,“name”:“pasta”,“value”:0.9958751,“app_id”:“main”},{“id”:“ai_XN1QLhwp”,“name”:“penne”,“value”:0.97589076,“app_id”:“main”},{“id”:“ai_2KV5G1Fg”,“name”:“basil”,“value”:0.9757403,“app_id”:“main”},{“id”:“ai_KWmFf1fn”,“name”:“meat”,“value”:0.97163224,“app_id”:“main”},{“id”:“ai_XVpwLB09”,“name”:“beef”,“value”:0.9662882,“app_id”:“main”},{“id”:“ai_qmTM9wzt”,“name”:“spaghetti”,“value”:0.96250445,“app_id”:“main”},{“id”:“ai_CB8hsS3T”,“name”:“tomato”,“value”:0.94417286,“app_id”:“main”},{“id”:“ai_FnZCSVMH”,“name”:“cheese”,“value”:0.88961625,“app_id”:“main”},{“id”:“ai_CQT1pP96”,“name”:“macaroni”,“value”:0.869142,“app_id”:“main”},{“id”:“ai_NDbbpCv1”,“name”:“vegetable”,“value”:0.86451674,“app_id”:“main”},{“id”:“ai_CSW3Njnd”,“name”:"meat sauce”,“value”:0.8525688,“app_id”:“main”},{“id”:“ai_3fJXxTPQ”,“name”:“sausage”,“value”:0.68008953,“app_id”:“main”},{“id”:“ai_ZBtC2kLC”,“name”:“spaghetti bolognese”,“value”:0.627321,“app_id”:“main”},{“id”:“ai_Bh2xGwKk”,“name”:“tomato sauce”,“value”:0.6137849,“app_id”:“main”},{“id”:“ai_TRbv6FWL”,“name”:“pork”,“value”:0.5720775,“app_id”:“main”},{“id”:“ai_cdw5bgmc”,“name”:“pasta sauce”,“value”:0.46461484,“app_id”:“main”},{“id”:“ai_6s1vcbq9”,“name”:“garlic”,“value”:0.45499253,“app_id”:“main”},{“id”:“ai_gNpKXVhq”,“name”:“tagliatelle”,“value”:0.45064634,“app_id”:“main”},{“id”:“ai_gLHbKNPn”,“name”:“parmesan”,“value”:0.44501826,“app_id”:“main”}]}}]}’

  1. How much time have you spent debugging this issue?
    (Please spend at least 15 minutes to resolve the issue on your own before posting a new topic here)
    more than one hour

  2. What is your hypothesis?

Your output should display the Name tags as the output of the app.
Work with the files clarify_tag_Suggestions.py and views.py to display the output

not getting this answer …the above output is right or wrong and also can i extract names from the above bites of data …???from json can i exact the data and return the name of list ???///
when I’m using the views.py …it showing …
ModuleNotFoundError: No module named ‘rest_framework’ this eroor

Hint: Use Dictionary in python to access the Names in the JSON Output. Then return the list of names in the def get_tags_suggestions(api_key, image_url).

my name list is>>
[‘rice’, ‘meat’, ‘vegetable’, ‘paella’, ‘chicken’, ‘pilaf’, ‘pepper’, ‘saffron’, ‘pork’, ‘fried rice’, ‘curry’, ‘shrimp’, ‘risotto’, ‘seafood’, ‘sauce’, ‘onion’, ‘chili’, ‘chicken curry’, ‘prawn’, ‘cereal’]
is this right…??? sir atleast first tell whether this is right list or not…??
after doing this step i got 3 test cases pass one fail…???
what to do!!![Screenshot (10)|690x387]
(upload://dvxuKZLrdEwVkOD5WhczyJrP3Yi.png)

.
.
.
2020-04-11 13:03:41,672 unitTesting INFO Running pytest
2020-04-11 13:03:53,716 unitTesting INFO ============================= test session starts ==============================
platform linux – Python 3.6.9, pytest-5.3.1, py-1.8.0, pluggy-0.12.0
Django settings: qeats.settings (from ini file)
rootdir: /salman0786-nav-ME_QEATS_REVIEW_MP-d919ea0c-7bf4-11ea-b56b-071de9ff8431/salman0786-nav-ME_QEATS_REVIEW_MP, inifile: pytest.ini
plugins: django-3.5.1, mock-1.10.4
collected 4 items

tests/test_views.py F…s [100%]

=================================== FAILURES ===================================
____________________ TestSocialSharing.test_tag_suggesstion ____________________

self = <tests.test_views.TestSocialSharing object at 0x3e40fac657f0>

def test_tag_suggesstion(self):
    prefix = os.getenv('USER_SOLUTION')
    if prefix is None:
        prefix = '.'

    image_path = prefix + '/tests/biryani.jpeg'
    if prefix is None:
        prefix = '.'
    img_b64 = restaurants.image_uploader.file_path_to_img64(image_path)

    body = {
            'imgBase64' : img_b64.decode('utf-8')
           }
    client = Client()

    resp = client.post(r'/qeats/v1/tags', data=json.dumps(body), content_type='application/json')
    assert resp.status_code == 200
    actual_tag_suggesstion_received = json.loads(resp.content)
    expected_tag_suggestion = ['rice', 'meat', 'vegetable', 'paella', 'chicken', 'pilaf', 'pepper', 'saffron', 'pork', 'fried rice', 'curry', 'shrimp', 'risotto', 'seafood', 'sauce', 'onion', 'chili', 'chicken curry', 'prawn', 'cereal']

    print(actual_tag_suggesstion_received)
    assert type(actual_tag_suggesstion_received) == type([])
  assert expected_tag_suggestion[0:3] == actual_tag_suggesstion_received[0:3]

E AssertionError: assert [‘rice’, ‘meat’, ‘vegetable’] == []
E Left contains 3 more items, first extra item: ‘rice’
E Use -v to get the full diff

tests/test_views.py:157: AssertionError
----------------------------- Captured stdout call -----------------------------
[]
=============================== warnings summary ===============================
/usr/local/lib/python3.6/dist-packages/_pytest/junitxml.py:436
/usr/local/lib/python3.6/dist-packages/_pytest/junitxml.py:436: PytestDeprecationWarning: The ‘junit_family’ default value will change to ‘xunit2’ in pytest 6.0.
Add ‘junit_family=legacy’ to your pytest.ini file to silence this warning and make your suite compatible.
_issue_warning_captured(deprecated.JUNIT_XML_DEFAULT_FAMILY, config.hook, 2)

– Docs: https://docs.pytest.org/en/latest/warnings.html

  • generated xml file: /salman0786-nav-ME_QEATS_REVIEW_MP-d919ea0c-7bf4-11ea-b56b-071de9ff8431/salman0786-nav-ME_QEATS_REVIEW_MP/tests.xml -
    ============== 1 failed, 2 passed, 1 skipped, 1 warning in 8.23s ===============

2020-04-11 13:03:53,717 unitTesting INFO Pytest run complete
2020-04-11 13:03:53,719 unitTesting INFO Report generated: {‘tests.test_views.TestSocialSharing.test_post_to_pinterest_share’: ‘TEST_STATUS_SUCCESS’, ‘tests.test_views.TestSocialSharing.test_tag_suggesstion’: ‘TEST_STATUS_FAILURE’, ‘tests.test_views.TestSocialSharing.test_post_to_facebook_share_cli’: ‘TEST_STATUS_SUCCESS’, ‘tests.test_views.TestSocialSharing.test_post_to_facebook_share’: ‘TEST_STATUS_SUCCESS’}

Hey,

Could you please check once did you call clarify function in the views.py ?

no clarify fuction in views.py


views.py getting this errror…do i need to call the get tags suggestions in class GetTags(APIView):
permission_classes = [AllowAny]
authentication_classes = []

def post()///////////i in this func  i need to write but i m getting error in views.py setup



File “/home/crio-user/.local/lib/python3.6/site-packages/django/conf/init.py”, line 76, in getattr
self._setup(name)
File “/home/crio-user/.local/lib/python3.6/site-packages/django/conf/init.py”, line 63, in _setup
self._wrapped = Settings(settings_module)
File “/home/crio-user/.local/lib/python3.6/site-packages/django/conf/init.py”, line 142, in init
mod = importlib.import_module(self.SETTINGS_MODULE)
File “/usr/lib/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named ‘mysite’

Hey,

can you please read this carefully -

  1. Use the Clarifai API to get a list of categories based on the review image submitted by users.
  2. Follow the instructions in clarifai_tag_suggestions.py and implement.
  3. Make the necessary changes in views.py to use methods you implemented in step 2 and send tag suggestions to the Android app.
1 Like

ok sir…i mixed lot of things in that so what i will do is i want to restart this module again so that i can go through in deep of milestone…
so how to reset current module…??

okay …now i went through all the steps very clearly and getting this error in views.py

…??

Traceback (most recent call last):
File “views.py”, line 2, in
from rest_framework.permissions import AllowAny
ModuleNotFoundError: No module named ‘rest_framework’
crio-user@salman0786-nav:~/workspace/salman0786-nav-ME_QEATS_REVIEW_MP/restaurants$ python3 views.py Traceback (most recent call last):
File “views.py”, line 2, in
from rest_framework.permissions import AllowAny
ModuleNotFoundError: No module named ‘rest_framework’
crio-user@salman0786-nav:~/workspace/salman0786-nav-ME_QEATS_REVIEW_MP/restaurants$ pip3 install djangorestframeworkDefaulting to user installation because normal site-packages is not writeable
Collecting djangorestframework
Downloading djangorestframework-3.11.0-py3-none-any.whl (911 kB)
|################################| 911 kB 1.6 MB/s
Collecting django>=1.11
Downloading Django-3.0.5-py3-none-any.whl (7.5 MB)
|################################| 7.5 MB 7.0 MB/s
Collecting asgiref~=3.2
Downloading asgiref-3.2.7-py2.py3-none-any.whl (19 kB)
Collecting sqlparse>=0.2.2
Downloading sqlparse-0.3.1-py2.py3-none-any.whl (40 kB)
|################################| 40 kB 14.8 MB/s
Collecting pytz
Downloading pytz-2019.3-py2.py3-none-any.whl (509 kB)
|################################| 509 kB 30.1 MB/s
Installing collected packages: asgiref, sqlparse, pytz, django, djangorestframework
WARNING: The script sqlformat is installed in ‘/home/crio-user/.local/bin’ which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script django-admin is installed in ‘/home/crio-user/.local/bin’ which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed asgiref-3.2.7 django-3.0.5 djangorestframework-3.11.0 pytz-2019.3 sqlparse-0.3.1
crio-user@salman0786-nav:~/workspace/salman0786-nav-ME_QEATS_REVIEW_MP/restaurants$ pip3 install djangorestframeworkDefaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: djangorestframework in /home/crio-user/.local/lib/python3.6/site-packages (3.11.0)
Requirement already satisfied: django>=1.11 in /home/crio-user/.local/lib/python3.6/site-packages (from djangorestframework) (3.0.5)
Requirement already satisfied: pytz in /home/crio-user/.local/lib/python3.6/site-packages (from django>=1.11->djangorestframework) (2019.3)
Requirement already satisfied: asgiref~=3.2 in /home/crio-user/.local/lib/python3.6/site-packages (from django>=1.11->djangorestframework) (3.2.7)
Requirement already satisfied: sqlparse>=0.2.2 in /home/crio-user/.local/lib/python3.6/site-packages (from django>=1.11->djangorestframework) (0.3.1)
crio-user@salman0786-nav:~/workspace/salman0786-nav-ME_QEATS_REVIEW_MP/restaurants$ python3 views.py Traceback (most recent call last):
File “views.py”, line 3, in
from rest_framework.views import APIView
File “/home/crio-user/.local/lib/python3.6/site-packages/rest_framework/views.py”, line 17, in
from rest_framework.schemas import DefaultSchema
File “/home/crio-user/.local/lib/python3.6/site-packages/rest_framework/schemas/init.py”, line 25, in
from . import coreapi, openapi
File “/home/crio-user/.local/lib/python3.6/site-packages/rest_framework/schemas/openapi.py”, line 12, in
from rest_framework import exceptions, renderers, serializers
File “/home/crio-user/.local/lib/python3.6/site-packages/rest_framework/renderers.py”, line 53, in
class JSONRenderer(BaseRenderer):
File “/home/crio-user/.local/lib/python3.6/site-packages/rest_framework/renderers.py”, line 60, in JSONRenderer
ensure_ascii = not api_settings.UNICODE_JSON
File “/home/crio-user/.local/lib/python3.6/site-packages/rest_framework/settings.py”, line 213, in getattr
val = self.user_settings[attr]
File “/home/crio-user/.local/lib/python3.6/site-packages/rest_framework/settings.py”, line 204, in user_settings
self._user_settings = getattr(settings, ‘REST_FRAMEWORK’, {})
File “/home/crio-user/.local/lib/python3.6/site-packages/django/conf/init.py”, line 76, in getattr
self._setup(name)
File “/home/crio-user/.local/lib/python3.6/site-packages/django/conf/init.py”, line 61, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting REST_FRAMEWORK, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

Hey,

If you want restart the refer to this -

My advice is not to start again. Spend some time and try to debug it yourself

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.