HumanBrainProject / hbp-validation-framework

Apache License 2.0
5 stars 12 forks source link

Error in editing an existing model #241

Closed appukuttan-shailesh closed 5 years ago

appukuttan-shailesh commented 5 years ago

Editing an existing model results in error.

URL: https://validation-v1.brainsimulation.eu/models/?app_id=359330 Sample payload:

{
  "models": [
          {
                  "id": "fa173234-a2b7-485d-9938-d98747bc89c3",
                  "description": "Model optimized using BluePyOpt"
          }
  ]
}

Error: 500 Internal Server Error

MultiValueDictKeyError at /models/ "'models'"

Request Method: PUT Request URL: https://validation-v1.brainsimulation.eu/models/?app_id=359330 Django Version: 1.10.5 Python Executable: /usr/local/bin/uwsgi Python Version: 2.7.9 Python Path: ['.', '', '/home/docker/packages/hbp-app-python-auth-0.1.5', '/home/docker', '/home/docker/site', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/lib/pymodules/python2.7', '..'] Server time: Wed, 15 May 2019 13:26:56 +0000 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'model_validation_api', 'jsonify', 'social.apps.django_app.default', 'hbp_app_python_auth', 'markdown_deux', 'corsheaders', 'rest_framework', 'sslserver'] Installed Middleware: ('app.middleware.personal_middleware.DisableCsrfCheck', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.security.SecurityMiddleware', 'social.apps.django_app.middleware.SocialAuthExceptionMiddleware')

Traceback:

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner

  1. response = get_response(request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _legacy_get_response

  1. response = self._get_response(request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response

  1. response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response

  1. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py" in wrapped_view

  1. return view_func(*args, **kwargs)

File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in view

  1. return self.dispatch(request, *args, **kwargs)

File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py" in dispatch

  1. response = self.handle_exception(exc)

File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py" in handle_exception

  1. self.raise_uncaught_exception(exc)

File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py" in dispatch

  1. response = handler(request, *args, **kwargs)

File "/home/docker/model_validation_api/views.py" in put

  1. value = request.data['models'][0]

File "/usr/local/lib/python2.7/dist-packages/django/utils/datastructures.py" in getitem

  1. raise MultiValueDictKeyError(repr(key))

Exception Type: MultiValueDictKeyError at /models/ Exception Value: "'models'" Request information: USER: AnonymousUser

GET: app_id = u'359330'

POST: No POST data

FILES: No FILES data

COOKIES: No cookie data

META: CONTENT_LENGTH = '176' CONTENT_TYPE = 'application/x-www-form-urlencoded' DOCUMENT_ROOT = '/usr/share/nginx/html' HTTPS = 'on' HTTP_ACCEPT = '/' HTTP_ACCEPT_ENCODING = 'gzip, deflate' HTTP_AUTHORIZATION = 'Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImJicC1vaWRjIn0.eyJleHAiOjE1NTc5NDA5NjUsInN1YiI6IjMwMzAyMCIsImF1ZCI6WyIzMjMxNDU3My1hMjQ1LTRiNWEtYjM3MS0yZjE1YWNjNzkxYmEiXSwiaXNzIjoiaHR0cHM6XC9cL3NlcnZpY2VzLmh1bWFuYnJhaW5wcm9qZWN0LmV1XC9vaWRjXC8iLCJqdGkiOiI1OThjOTJhZC01Yjk5LTRiY2ItOWIwZS00YzM5MTk0ZTgzNzEiLCJpYXQiOjE1NTc5MjY1NjUsImhicF9rZXkiOiI3M2M0NWVkMzRkY2Y2NTM5NzhlMTM5YjgyZWI2MmFjMGI4MjMxZmE2In0.DiAD5O7G3Alum9hKjEGk-XjPvCpPdQMGsqLAd3jbJDfs4UODPFtrHUmH9uy0GhcxmmWJdsfNFao562IDdIbRKmqq_d-3UZF6FRgKmMfFGPwwiSqu7Bht8IK0VY-SCkhzKGRC4QnqbWHjgo611w6DlYP2uOOt0LOycLWC0STqJZE' HTTP_CACHE_CONTROL = 'no-cache' HTTP_CONNECTION = 'keep-alive' HTTP_CONTENT_LENGTH = '176' HTTP_CONTENT_TYPE = 'application/x-www-form-urlencoded' HTTP_HOST = 'validation-v1.brainsimulation.eu' HTTP_POSTMAN_TOKEN = '49fc6d5b-ed9b-4902-9373-2faa3370e6ad' HTTP_USER_AGENT = 'PostmanRuntime/7.1.1' PATH_INFO = u'/models/' QUERY_STRING = 'app_id=359330' REMOTE_ADDR = '157.136.60.151' REMOTE_PORT = '49440' REQUEST_METHOD = 'PUT' REQUEST_URI = '/models/?app_id=359330' SCRIPT_NAME = u'' SERVER_NAME = 'validation-v1.brainsimulation.eu' SERVER_PORT = '443' SERVER_PROTOCOL = 'HTTP/1.1' uwsgi.node = '2a7067879a59' uwsgi.version = '2.0.15' wsgi.errors = <open file 'wsgi_errors', mode 'w' at 0x7fe42a3f98a0> wsgi.file_wrapper = '' wsgi.input = <uwsgi._Input object at 0x7fe42931f9d8> wsgi.multiprocess = True wsgi.multithread = False wsgi.run_once = False wsgi.url_scheme = 'https' wsgi.version =

Settings: Using settings module validation_service.settings ABSOLUTE_URL_OVERRIDES = {} ADMINS = [] ADMIN_COLLAB_ID = '13947' ALLOWED_HOSTS = ['*'] APPEND_SLASH = False AUTHENTICATION_BACKENDS = AUTH_PASSWORD_VALIDATORS = u'****' AUTH_USER_MODEL = u'auth.User' BASE_DIR = '/home/docker/site' BUILD_INFO = None CACHES = {u'default': {u'BACKEND': u'django.core.cache.backends.locmem.LocMemCache'}} CACHE_MIDDLEWARE_ALIAS = u'default' CACHE_MIDDLEWARE_KEY_PREFIX = u'****' CACHE_MIDDLEWARE_SECONDS = 600 CORS_ALLOW_CREDENTIALS = True CORS_ALLOW_HEADERS = CORS_ORIGIN_WHITELIST = CSRF_COOKIE_AGE = 31449600 CSRF_COOKIE_DOMAIN = CSRF_COOKIE_HTTPONLY = False CSRF_COOKIE_NAME = u'csrftoken' CSRF_COOKIE_PATH = u'/' CSRF_COOKIE_SECURE = False CSRF_FAILURE_VIEW = u'django.views.csrf.csrf_failure' CSRF_HEADER_NAME = u'HTTP_X_CSRFTOKEN' CSRF_TRUSTED_ORIGINS = ['localhost:8000', '127.0.0.1:9000'] DATABASES = {'default': {'ENGINE': 'django.db.backends.postgresql_psycopg2', 'AUTOCOMMIT': True, 'ATOMIC_REQUESTS': False, 'NAME': 'validations', 'CONN_MAX_AGE': 0, 'TIME_ZONE': None, 'PORT': '32768', 'HOST': '95.85.39.229', 'USER': 'validations_admin', 'TEST': {'COLLATION': None, 'CHARSET': None, 'NAME': None, 'MIRROR': None}, 'PASSWORD': u'****', 'OPTIONS': {}}} DATABASE_ROUTERS = [] DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440 DATA_UPLOAD_MAX_NUMBER_FIELDS = 1000 DATETIME_FORMAT = u'N j, Y, P' DATETIME_INPUT_FORMATS = [u'%Y-%m-%d %H:%M:%S', u'%Y-%m-%d %H:%M:%S.%f', u'%Y-%m-%d %H:%M', u'%Y-%m-%d', u'%m/%d/%Y %H:%M:%S', u'%m/%d/%Y %H:%M:%S.%f', u'%m/%d/%Y %H:%M', u'%m/%d/%Y', u'%m/%d/%y %H:%M:%S', u'%m/%d/%y %H:%M:%S.%f', u'%m/%d/%y %H:%M', u'%m/%d/%y'] DATE_FORMAT = u'N j, Y' DATE_INPUT_FORMATS = [u'%Y-%m-%d', u'%m/%d/%Y', u'%m/%d/%y', u'%b %d %Y', u'%b %d, %Y', u'%d %b %Y', u'%d %b, %Y', u'%B %d %Y', u'%B %d, %Y', u'%d %B %Y', u'%d %B, %Y'] DEBUG = True DEBUG_PROPAGATE_EXCEPTIONS = False DECIMAL_SEPARATOR = u'.' DEFAULT_CHARSET = u'utf-8' DEFAULT_CONTENT_TYPE = u'text/html' DEFAULT_EXCEPTION_REPORTER_FILTER = u'django.views.debug.SafeExceptionReporterFilter' DEFAULT_FILE_STORAGE = u'django.core.files.storage.FileSystemStorage' DEFAULT_FROM_EMAIL = u'webmaster@localhost' DEFAULT_INDEX_TABLESPACE = u'' DEFAULT_TABLESPACE = u'' DISALLOWED_USER_AGENTS = [] EMAIL_BACKEND = u'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = u'localhost' EMAIL_HOST_PASSWORD = u'****' EMAIL_HOST_USER = u'' EMAIL_PORT = 25 EMAIL_SSL_CERTFILE = None EMAIL_SSL_KEYFILE = u'****' EMAIL_SUBJECT_PREFIX = u'[Django] ' EMAIL_TIMEOUT = None EMAIL_USE_SSL = False EMAIL_USE_TLS = False ENV = 'dev' FILE_CHARSET = u'utf-8' FILE_UPLOAD_DIRECTORY_PERMISSIONS = None FILE_UPLOAD_HANDLERS = [u'django.core.files.uploadhandler.MemoryFileUploadHandler', u'django.core.files.uploadhandler.TemporaryFileUploadHandler'] FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440 FILE_UPLOAD_PERMISSIONS = None FILE_UPLOAD_TEMP_DIR = None FIRST_DAY_OF_WEEK = 0 FIXTURE_DIRS = [] FORCE_SCRIPT_NAME = None FORMAT_MODULE_PATH = None HBP_COLLAB_SERVICE_URL = 'https://services.humanbrainproject.eu/collab/v0/' HBP_ENV_URL = 'https://collab.humanbrainproject.eu/config.json' HBP_IDENTITY_SERVICE_URL = 'https://services.humanbrainproject.eu/idm/v1/api' HBP_STORAGE_SERVICE_URL = 'https://services.humanbrainproject.eu/storage/v1/api/entity/' IGNORABLE_404_URLS = [] INSTALLED_APPS = ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'model_validation_api', 'jsonify', 'social.apps.django_app.default', 'hbp_app_python_auth', 'markdown_deux', 'corsheaders', 'rest_framework', 'sslserver'] INTERNAL_IPS = [] LANGUAGES = [(u'af', u'Afrikaans'), (u'ar', u'Arabic'), (u'ast', u'Asturian'), (u'az', u'Azerbaijani'), (u'bg', u'Bulgarian'), (u'be', u'Belarusian'), (u'bn', u'Bengali'), (u'br', u'Breton'), (u'bs', u'Bosnian'), (u'ca', u'Catalan'), (u'cs', u'Czech'), (u'cy', u'Welsh'), (u'da', u'Danish'), (u'de', u'German'), (u'dsb', u'Lower Sorbian'), (u'el', u'Greek'), (u'en', u'English'), (u'en-au', u'Australian English'), (u'en-gb', u'British English'), (u'eo', u'Esperanto'), (u'es', u'Spanish'), (u'es-ar', u'Argentinian Spanish'), (u'es-co', u'Colombian Spanish'), (u'es-mx', u'Mexican Spanish'), (u'es-ni', u'Nicaraguan Spanish'), (u'es-ve', u'Venezuelan Spanish'), (u'et', u'Estonian'), (u'eu', u'Basque'), (u'fa', u'Persian'), (u'fi', u'Finnish'), (u'fr', u'French'), (u'fy', u'Frisian'), (u'ga', u'Irish'), (u'gd', u'Scottish Gaelic'), (u'gl', u'Galician'), (u'he', u'Hebrew'), (u'hi', u'Hindi'), (u'hr', u'Croatian'), (u'hsb', u'Upper Sorbian'), (u'hu', u'Hungarian'), (u'ia', u'Interlingua'), (u'id', u'Indonesian'), (u'io', u'Ido'), (u'is', u'Icelandic'), (u'it', u'Italian'), (u'ja', u'Japanese'), (u'ka', u'Georgian'), (u'kk', u'Kazakh'), (u'km', u'Khmer'), (u'kn', u'Kannada'), (u'ko', u'Korean'), (u'lb', u'Luxembourgish'), (u'lt', u'Lithuanian'), (u'lv', u'Latvian'), (u'mk', u'Macedonian'), (u'ml', u'Malayalam'), (u'mn', u'Mongolian'), (u'mr', u'Marathi'), (u'my', u'Burmese'), (u'nb', u'Norwegian Bokm\xe5l'), (u'ne', u'Nepali'), (u'nl', u'Dutch'), (u'nn', u'Norwegian Nynorsk'), (u'os', u'Ossetic'), (u'pa', u'Punjabi'), (u'pl', u'Polish'), (u'pt', u'Portuguese'), (u'pt-br', u'Brazilian Portuguese'), (u'ro', u'Romanian'), (u'ru', u'Russian'), (u'sk', u'Slovak'), (u'sl', u'Slovenian'), (u'sq', u'Albanian'), (u'sr', u'Serbian'), (u'sr-latn', u'Serbian Latin'), (u'sv', u'Swedish'), (u'sw', u'Swahili'), (u'ta', u'Tamil'), (u'te', u'Telugu'), (u'th', u'Thai'), (u'tr', u'Turkish'), (u'tt', u'Tatar'), (u'udm', u'Udmurt'), (u'uk', u'Ukrainian'), (u'ur', u'Urdu'), (u'vi', u'Vietnamese'), (u'zh-hans', u'Simplified Chinese'), (u'zh-hant', u'Traditional Chinese')] LANGUAGES_BIDI = [u'he', u'ar', u'fa', u'ur'] LANGUAGE_CODE = 'en-us' LANGUAGE_COOKIE_AGE = None LANGUAGE_COOKIE_DOMAIN = None LANGUAGE_COOKIE_NAME = u'django_language' LANGUAGE_COOKIE_PATH = u'/' LOCALE_PATHS = [] LOCAL_DB = False LOGGING = {'loggers': {'model_validation_api': u'****', 'django': {'handlers': ['file'], 'level': 'INFO'}}, 'handlers': {'file': {'level': 'DEBUG', 'formatter': 'verbose', 'class': 'logging.FileHandler', 'filename': 'django.log'}}, 'version': 1, 'disable_existing_loggers': False, 'formatters': {'verbose': {'format': '%(asctime)s %(levelname)s %(name)s: %(message)s'}}} LOGGING_CONFIG = u'logging.config.dictConfig' LOGIN_REDIRECT_URL = u'/accounts/profile/' LOGIN_URL = u'/accounts/login/' LOGOUT_REDIRECT_URL = None MANAGERS = [] MEDIA_ROOT = u'' MEDIA_URL = u'' MESSAGE_STORAGE = u'django.contrib.messages.storage.fallback.FallbackStorage' MIDDLEWARE = None MIDDLEWARE_CLASSES = MIGRATION_MODULES = {} MONTH_DAY_FORMAT = u'F j' NUMBER_GROUPING = 0 PASSWORD_HASHERS = u'****' PASSWORD_RESET_TIMEOUT_DAYS = u'****' PREPEND_WWW = False REST_FRAMEWORK = {'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.SessionAuthentication'), 'PAGE_SIZE': 100, 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination'} ROOT_URLCONF = 'validation_service.urls' SECRET_KEY = u'****' SECURE_BROWSER_XSS_FILTER = False SECURE_CONTENT_TYPE_NOSNIFF = False SECURE_HSTS_INCLUDE_SUBDOMAINS = False SECURE_HSTS_SECONDS = 0 SECURE_PROXY_SSL_HEADER = None SECURE_REDIRECT_EXEMPT = [] SECURE_SSL_HOST = None SECURE_SSL_REDIRECT = False SERVER_EMAIL = u'root@localhost' SESSION_CACHE_ALIAS = u'default' SESSION_COOKIE_AGE = 1209600 SESSION_COOKIE_DOMAIN = None SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_NAME = u'sessionid' SESSION_COOKIE_PATH = u'/' SESSION_COOKIE_SECURE = False SESSION_ENGINE = u'django.contrib.sessions.backends.db' SESSION_EXPIRE_AT_BROWSER_CLOSE = False SESSION_FILE_PATH = None SESSION_SAVE_EVERY_REQUEST = False SESSION_SERIALIZER = u'django.contrib.sessions.serializers.JSONSerializer' SETTINGS_MODULE = 'validation_service.settings' SHORT_DATETIME_FORMAT = u'm/d/Y P' SHORT_DATE_FORMAT = u'm/d/Y' SIGNING_BACKEND = u'django.core.signing.TimestampSigner' SILENCED_SYSTEM_CHECKS = [] SOCIAL_AUTH_HBP_KEY = u'****' SOCIAL_AUTH_HBP_SECRET = u'****' STATICFILES_DIRS = ['/home/docker/site/app'] STATICFILES_FINDERS = [u'django.contrib.staticfiles.finders.FileSystemFinder', u'django.contrib.staticfiles.finders.AppDirectoriesFinder'] STATICFILES_STORAGE = u'django.contrib.staticfiles.storage.StaticFilesStorage' STATIC_ROOT = '/home/docker/site/static/' STATIC_URL = '/static/' TEMPLATES = [{'DIRS': ['app/templates'], 'APP_DIRS': True, 'OPTIONS': {'context_processors': ['django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages']}, 'BACKEND': 'django.template.backends.django.DjangoTemplates'}] TEST_NON_SERIALIZED_APPS = [] TEST_RUNNER = u'django.test.runner.DiscoverRunner' THOUSAND_SEPARATOR = u',' TIME_FORMAT = u'P' TIME_INPUT_FORMATS = [u'%H:%M:%S', u'%H:%M:%S.%f', u'%H:%M'] TIME_ZONE = 'UTC' USE_ETAGS = False USE_I18N = True USE_L10N = True USE_THOUSAND_SEPARATOR = False USE_TZ = True USE_X_FORWARDED_HOST = False USE_X_FORWARDED_PORT = False WSGI_APPLICATION = 'validation_service.wsgi.application' X_FRAME_OPTIONS = u'SAMEORIGIN' YEAR_MONTH_FORMAT = u'F Y'

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard page generated by the handler for this status code.

appukuttan-shailesh commented 5 years ago

Interestingly, this works via the web apps. When I try to replicate the exact same API calls via Postman, I get the same error as above.

Web-app replication info: URL: https://validation-v1.brainsimulation.eu/models/?app_id=68489&format=json&web_app=True Payload:

{
   "models":[
      {
         "id":"fa173234-a2b7-485d-9938-d98747bc89c3",
         "name":"IGNORE - Test Model - 2019-05-15_13:54:16_duplicate",
         "alias":"2019-05-15_13:54:16_duplicate",
         "author":"Shailesh Appukuttan",
         "owner":"Shailesh Appukuttan",
         "app":{
            "id":"359330",
            "data_modalities":"",
            "test_type":"",
            "species":"",
            "brain_region":"",
            "cell_type":"",
            "model_scope":"",
            "abstraction_level":"",
            "organization":"",
            "app_type":"validation_app",
            "collab_id":52468
         },
         "organization":"HBP-SP6",
         "project":"SP 6.4",
         "private":false,
         "license":"BSD 3-Clause",
         "cell_type":"granule cell",
         "model_scope":"single cell",
         "abstraction_level":"spiking neurons",
         "brain_region":"hippocampus",
         "species":"Mus musculus",
         "description":"This is a test entry! Please ignore.",
         "instances":[

         ],
         "images":[

         ]
      }
   ]
}

Any thoughts on this @apdavison ?

appukuttan-shailesh commented 5 years ago

This is important since as a workaround users are asking us for entries to be deleted and new entries created (when several models need to be edited at once).

apdavison commented 5 years ago

Do you have the same problem with the staging server?

appukuttan-shailesh commented 5 years ago

Editing a model is still failing. E.g.

mc.get_model(model_id="21d03065-38e6-4720-bec6-dec4bdaff812") works.

But, mc.edit_model(model_id="21d03065-38e6-4720-bec6-dec4bdaff812", name="Kali_Freund_temp") fails with Exception: Error in updating model. Response = <Response [404]>

apdavison commented 5 years ago

I get

KeyError                                  Traceback (most recent call last)
<ipython-input-5-5f8bb6c6cdc5> in <module>
----> 1 mc.edit_model(model_id="21d03065-38e6-4720-bec6-dec4bdaff812", name="Kali_Freund_temp")

~/dev/validation/hbp-validation-client/hbp_validation_framework/__init__.py in edit_model(self, model_id, app_id, name, alias, author, organization, private, cell_type, model_scope, abstraction_level, brain_region, species, owner, project, license, description)
   1865                 model_data[key] = model_json[key]
   1866         if app_id is None:
-> 1867             app_id = model_json["app"]["id"]
   1868         if model_data["alias"] == "":
   1869             model_data["alias"] = None

KeyError: 'id'

Have you updated the client locally?

appukuttan-shailesh commented 5 years ago

I had the "url" partly incorrect. Correcting that gets rid off the 404 error, but brings me back to the original 500 error.

Yes, I had edited the client locally, by commenting out some lines (currently just for testing this):

        for key in model_data:
            if model_data[key] is None:
                model_data[key] = model_json[key]
        # if app_id is None:
        #     app_id = model_json["app"]["id"]
        if model_data["alias"] == "":
            model_data["alias"] = None

        values = self.get_attribute_options()

        # if model_data["cell_type"] not in values["cell_type"]:
        #     raise Exception("cell_type = '" +model_data["cell_type"]+"' is invalid.\nValue has to be one of these: " + str(values["cell_type"]))
        # if model_data["model_scope"] not in values["model_scope"]:
        #     raise Exception("model_scope = '" +model_data["model_scope"]+"' is invalid.\nValue has to be one of these: " + str(values["model_scope"]))
        # if model_data["abstraction_level"] not in values["abstraction_level"]:
        #     raise Exception("abstraction_level = '" +model_data["abstraction_level"]+"' is invalid.\nValue has to be one of these: " + str(values["abstraction_level"]))
        # if model_data["brain_region"] not in values["brain_region"]:
        #     raise Exception("brain_region = '" +model_data["brain_region"]+"' is invalid.\nValue has to be one of these: " + str(values["brain_region"]))
        # if model_data["species"] not in values["species"]:
        #     raise Exception("species = '" +model_data["species"]+"' is invalid.\nValue has to be one of these: " + str(values["species"]))
        # values["organization"].append("")   # allow blank organization field
        # if model_data["organization"] not in values["organization"]:
        #     raise Exception("organization = '" +model_data["organization"]+"' is invalid.\nValue has to be one of these: " + str(values["organization"]))
        # if model_data["private"] not in [True, False]:
        #     raise Exception("Model's 'private' attribute should be specified as True / False. Default value is False.")

        url = self.url + "/models/"
appukuttan-shailesh commented 5 years ago

Unable to get it working even via Postman.... The body of my request was:

{"models": [{"cell_type": "pyramidal cell", "description": "A model of CA1 pyramidal neurons, as described in:\n\nS. Kali, T.F. Freund (2004) Dendritic processing in hippocampal pyramidal cells and its modulation by inhibitory interneurons. *Proceedings of the 2004 IEEE International Joint Conference on Neural Networks* [doi:10.1109/IJCNN.2004.1379985](http://doi.org/10.1109/IJCNN.2004.1379985)", "license": "", "author": [{"family_name": "Kali", "given_name": "Szabolcs"}, {"family_name": "Freund", "given_name": "Tamas F."}], "model_scope": "single cell", "abstraction_level": "None", "id": "21d03065-38e6-4720-bec6-dec4bdaff812", "project": "", "alias": "kali-freund-2004", "private": "False", "brain_region": "hippocampus", "owner": "", "organization": "None", "species": "Rattus norvegicus", "name": "Kali_Freund"}]}

PUT https://validation-staging.brainsimulation.eu/models/

Error: 500 Internal Server Error

TypeError at /models/ string indices must be integers

apdavison commented 5 years ago

The problem is in the request body. Some of the datatypes expected by the API have changed:

  1. The "owners" field should be null, [] or absent, not ""
  2. The "private" field should be false, not "False"
appukuttan-shailesh commented 5 years ago

Yes, it works with the above changes :+1: . Thanks! Will update the client accordingly.

appukuttan-shailesh commented 5 years ago

Sorry.... following up on above: if I try to just provide the following in query body: {"models": [{"id": "21d03065-38e6-4720-bec6-dec4bdaff812", "name": "Kali_Freund_1"}]} It returns a message saying: [ "This field may not be blank." ]

It does not indicate what field cannot be blank. Also, is it right to demand even the fields that I do not wish to edit? Here, I just wished to edit the name of the model.

As you stated that I can let "owners" be absent, I would expect (and prefer) to have other un-edited fields absent.

apdavison commented 5 years ago

I might be wrong about allowing some fields to be absent. In general with PUT you are supposed to provide all fields, PATCH may be used to update only some fields, however the server doesn't currently support PATCH. Could you make a ticket for that?

appukuttan-shailesh commented 5 years ago

Closing this issue in view of #248.