codalab / codabench

Codabench is a flexible, easy-to-use and reproducible benchmarking platform. Check our paper at Patterns Cell Press https://hubs.li/Q01fwRWB0
Apache License 2.0
76 stars 28 forks source link

Give superuser privileges to a user #1530

Closed ihsaan-ullah closed 4 months ago

ihsaan-ullah commented 4 months ago

When I try to use shell_plus as mentioned here: https://github.com/codalab/codabench/wiki/Administrator-procedures#give-superuser-privileges-to-an-user

docker-compose exec django ./manage.py shell_plus

I get this error:

# Shell Plus Model Imports
from analytics.models import AdminStorageDataPoint, CompetitionStorageDataPoint, StorageUsageHistory, UserStorageDataPoint
from announcements.models import Announcement, NewsPost
from competitions.models import Competition, CompetitionCreationTaskStatus, CompetitionDump, CompetitionParticipant, CompetitionWhiteListEmail, Page, Phase, PhaseTaskInstance, Submission, SubmissionDetails
from datasets.models import Data, DataGroup
from django.contrib.admin.models import LogEntry
from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType
from django.contrib.sessions.models import Session
from django.contrib.sites.models import Site
from forums.models import Forum, Post, Thread
from leaderboards.models import Column, Leaderboard, SubmissionScore
from oauth2_provider.models import AccessToken, Application, Grant, RefreshToken
from oidc_configurations.models import Auth_Organization
from profiles.models import GithubUserInfo, Membership, Organization, User
from queues.models import Queue
from rest_framework.authtoken.models import Token
from social_django.models import Association, Code, Nonce, Partial, UserSocialAuth
from tasks.models import Solution, Task
# Shell Plus Django Imports
from django.core.cache import cache
from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import transaction
from django.db.models import Avg, Case, Count, F, Max, Min, Prefetch, Q, Sum, When, Exists, OuterRef, Subquery
from django.utils import timezone
from django.urls import reverse

Traceback (most recent call last):
  File "/app/./manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.9/site-packages/django_extensions/management/commands/shell_plus.py", line 125, in run_from_argv
    return super(Command, self).run_from_argv(argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.9/site-packages/django_extensions/management/utils.py", line 62, in inner
    ret = func(self, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django_extensions/management/commands/shell_plus.py", line 517, in handle
    shell()
  File "/usr/local/lib/python3.9/site-packages/django_extensions/management/commands/shell_plus.py", line 322, in run_bpython
    embed(imported_objects, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/bpython/__init__.py", line 38, in embed
    return main(args, locals_, banner)
  File "/usr/local/lib/python3.9/site-packages/bpython/curtsies.py", line 191, in main
    exit_value = repl.mainloop(True, paste)
  File "/usr/local/lib/python3.9/site-packages/bpython/curtsies.py", line 108, in mainloop
    self.initialize_interp()
  File "/usr/local/lib/python3.9/site-packages/bpython/curtsiesfrontend/repl.py", line 1713, in initialize_interp
    del self.coderunner.interp.locals['_Helper']
KeyError: '_Helper'

I can use ipython flavour:

docker-compose exec django ./manage.py shell_plus --ipython
Didayolo commented 4 months ago

Yes, I had to use docker-compose exec django ./manage.py shell_plus --plain to make it work.

It was supposed to be solved by #814.

ihsaan-ullah commented 4 months ago

Do we want to fix this or update the documentation with --plain flag?

Didayolo commented 4 months ago

Maybe we want to understand what it is broken, it was working in the past.