Skip to content

by default, only list owner's subjects#303

Open
carmichaelong wants to merge 4 commits into
devfrom
update_admin_subject_view
Open

by default, only list owner's subjects#303
carmichaelong wants to merge 4 commits into
devfrom
update_admin_subject_view

Conversation

@carmichaelong

Copy link
Copy Markdown
Contributor

Addresses #291.

@AlbertoCasasOrtiz or @Seeeeeyo It's a small PR, and only one of you should need to review, but maybe @Seeeeeyo if you want to be the one that merges to make sure we don't merge while you all are making substantive changes that could be helpful?

suhlrich and others added 4 commits June 25, 2026 23:28
do not dequeue a trial that is saved_local after 15 minutes
reduce cpu load on dequeue (hopefully) with saved-local trials
@AlbertoCasasOrtiz

Copy link
Copy Markdown
Member

I tested and I can only see my own Subjects. I saw you modified a test, so I run tests and got this output. Look like the permission tests are related to my computer not being able to access the Temp folder:

(venv) (base) PS C:\Workspaces\opencap\opencap-api> python .\manage.py test .\tests\                   
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
...........................<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
...........014acfc9-100b-4785-b301-bf8e364a4e08
7912ed58-ad07-40df-a4a1-7ad394fbbda5
ef6f49df-ba31-4446-8711-d1735b9556b9
10c9e035-c5fe-4b64-849c-d70ffeb3b981
......................two
two
two
...two
two
two
........tag2
tag2
tag2
tag2
tag2
tag2
.........[Errno 2] No such file or directory: 'archive.zip'
F[Errno 2] No such file or directory: 'archive.zip'
F[Errno 2] No such file or directory: 'archive.zip'
F...FFF..E........F...........E..........FE
======================================================================
ERROR: test_download (test_permissions.SessionsPermissionsTests) (role='owner', public=False)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 408, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmpgu6isgkv.zip'

======================================================================
ERROR: test_download (test_permissions.SessionsPermissionsTests) (role='admin', public=False)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 408, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmpre09gicz.zip'

======================================================================
ERROR: test_download (test_permissions.SessionsPermissionsTests) (role='backend', public=False)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 408, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmp73vkt1xd.zip'

======================================================================
ERROR: test_download (test_permissions.SessionsPermissionsTests) (role='other', public=False)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 408, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmp509bpni0.zip'

======================================================================
ERROR: test_download (test_permissions.SessionsPermissionsTests) (role='unverified', public=False)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 408, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmpps98sb1l.zip'

======================================================================
ERROR: test_download (test_permissions.SessionsPermissionsTests) (role='owner', public=True)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 408, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmpwnb0a7vf.zip'

======================================================================
ERROR: test_download (test_permissions.SessionsPermissionsTests) (role='admin', public=True)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 408, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmpkggujllh.zip'

======================================================================
ERROR: test_download (test_permissions.SessionsPermissionsTests) (role='backend', public=True)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 408, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmpvzfhdpyg.zip'

======================================================================
ERROR: test_download (test_permissions.SessionsPermissionsTests) (role='other', public=True)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 408, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmp42a3qn9n.zip'

======================================================================
ERROR: test_download (test_permissions.SessionsPermissionsTests) (role='unverified', public=True)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 408, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmpbtrvqw3g.zip'

======================================================================
ERROR: test_download (test_permissions.SubjectPermissionsTests) (role='owner')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 1084, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmpgex8_d0y.zip'

======================================================================
ERROR: test_download (test_permissions.SubjectPermissionsTests) (role='admin')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 1084, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmpee0gje4i.zip'

======================================================================
ERROR: test_download (test_permissions.SubjectPermissionsTests) (role='backend')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 1084, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmps75qr290.zip'

======================================================================
ERROR: test_download (test_permissions.SubjectPermissionsTests) (role='other')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 1084, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmpgilbqzsu.zip'

======================================================================
ERROR: test_download (test_permissions.SubjectPermissionsTests) (role='unverified')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_permissions.py", line 1084, in test_download
    with zipfile.ZipFile(tmp_zip.name, 'w') as zf:
  File "C:\Users\NMBL\anaconda3\lib\zipfile.py", line 1248, in __init__
    self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmp_nxb7fmv.zip'

======================================================================
ERROR: test_analysis_function_api_view_list_only_active_functions (test_views.ViewsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_views.py", line 75, in test_analysis_function_api_view_list_only_active_functions
    qs = view.get_queryset()
  File "C:\Workspaces\opencap\opencap-api\mcserver\views.py", line 2678, in get_queryset
    user = self.request.user
AttributeError: 'AnalysisFunctionsListAPIView' object has no attribute 'request'

======================================================================
ERROR: test_collect_docs (test_zipsession.SessionDirectoryConstructorTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_zipsession.py", line 455, in test_collect_docs
    SessionDirectoryConstructor().collect_docs(trial)
  File "C:\Workspaces\opencap\opencap-api\mcserver\zipsession_v2.py", line 233, in collect_docs
    self.download_file_from_s3(
  File "C:\Workspaces\opencap\opencap-api\mcserver\zipsession_v2.py", line 69, in download_file_from_s3
    with open(dist, "wb") as dist_file:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\NMBL\\AppData\\Local\\Temp\\tmpquw04tm9\\sessionMetadata.yaml'

======================================================================
ERROR: test_integration (test_integration.TestIntegration)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\urllib3\connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\urllib3\util\connection.py", line 95, in create_connection
    raise err
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\urllib3\util\connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\urllib3\connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\urllib3\connection.py", line 239, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "C:\Users\NMBL\anaconda3\lib\http\client.py", line 1285, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\NMBL\anaconda3\lib\http\client.py", line 1331, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\NMBL\anaconda3\lib\http\client.py", line 1280, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\NMBL\anaconda3\lib\http\client.py", line 1040, in _send_output
    self.send(msg)
  File "C:\Users\NMBL\anaconda3\lib\http\client.py", line 980, in send
    self.connect()
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\urllib3\connection.py", line 205, in connect
    conn = self._new_conn()
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\urllib3\connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000002DC2B944DF0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\requests\adapters.py", line 489, in send
    resp = conn.urlopen(
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=8000): Max retries exceeded with url: /sessions/new/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002DC2B944DF0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_integration.py", line 10, in test_integration
    r = requests.get('{}/sessions/new/'.format(api_url))
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\requests\api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\requests\sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\requests\sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "C:\Workspaces\opencap\opencap-api\venv\lib\site-packages\requests\adapters.py", line 565, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=8000): Max retries exceeded with url: /sessions/new/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002DC2B944DF0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

======================================================================
FAIL: test_download_session_archive_creates_archive_and_logs_action (test_tasks.TasksTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\NMBL\anaconda3\lib\unittest\mock.py", line 1336, in patched
    return func(*newargs, **newkeywargs)
  File "C:\Workspaces\opencap\opencap-api\tests\test_tasks.py", line 67, in test_download_session_archive_creates_archive_and_logs_action
    self.assertEqual(after_logs, before_logs + 1)
AssertionError: 0 != 1

======================================================================
FAIL: test_download_session_archive_creates_archive_and_logs_action_for_anon_user (test_tasks.TasksTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\NMBL\anaconda3\lib\unittest\mock.py", line 1336, in patched
    return func(*newargs, **newkeywargs)
  File "C:\Workspaces\opencap\opencap-api\tests\test_tasks.py", line 87, in test_download_session_archive_creates_archive_and_logs_action_for_anon_user
    self.assertEqual(after_logs, before_logs + 1)
AssertionError: 0 != 1

======================================================================
FAIL: test_download_subject_archive_creates_archive_and_logs_action (test_tasks.TasksTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\NMBL\anaconda3\lib\unittest\mock.py", line 1336, in patched
    return func(*newargs, **newkeywargs)
  File "C:\Workspaces\opencap\opencap-api\tests\test_tasks.py", line 107, in test_download_subject_archive_creates_archive_and_logs_action
    self.assertEqual(after_logs, before_logs + 1)
AssertionError: 0 != 1

======================================================================
FAIL: test_invoke_aws_lambda_function_commits_successful_analysis_result (test_tasks.TasksTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\NMBL\anaconda3\lib\unittest\mock.py", line 1336, in patched
    return func(*newargs, **newkeywargs)
  File "C:\Workspaces\opencap\opencap-api\tests\test_tasks.py", line 165, in test_invoke_aws_lambda_function_commits_successful_analysis_result
    self.assertEqual(result.tag, function.title)
AssertionError: 'analysis_function_result:4' != 'func 0'
- analysis_function_result:4
+ func 0


======================================================================
FAIL: test_invoke_aws_lambda_function_re_run_analysis_function_in_the_same_result_instance (test_tasks.TasksTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\NMBL\anaconda3\lib\unittest\mock.py", line 1336, in patched
    return func(*newargs, **newkeywargs)
  File "C:\Workspaces\opencap\opencap-api\tests\test_tasks.py", line 281, in test_invoke_aws_lambda_function_re_run_analysis_function_in_the_same_result_instance
    self.assertEqual(after_results, before_results)
AssertionError: 3 != 2

======================================================================
FAIL: test_analysis_function_serializer_represents_correct_fields (test_views.SerializersTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_views.py", line 23, in test_analysis_function_serializer_represents_correct_fields
    self.assertEqual(
AssertionError: Items in the first set but not the second:
'info'

======================================================================
FAIL: test_invoke_analysis_function_endpoint_calls_correct_celery_task_for_func (test_views.ViewsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\NMBL\anaconda3\lib\unittest\mock.py", line 1336, in patched
    return func(*newargs, **newkeywargs)
  File "C:\Workspaces\opencap\opencap-api\tests\test_views.py", line 92, in test_invoke_analysis_function_endpoint_calls_correct_celery_task_for_func
    mock_celery_task.assert_called_once_with(
  File "C:\Users\NMBL\anaconda3\lib\unittest\mock.py", line 919, in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
  File "C:\Users\NMBL\anaconda3\lib\unittest\mock.py", line 907, in assert_called_with
    raise AssertionError(_error_message()) from cause
AssertionError: expected call not found.
Expected: delay(20, 352, {'session_id': 'fdffa654-523b-4940-948a-b4178bb3fc65'})
Actual: delay(352, 20, {'session_id': 'fdffa654-523b-4940-948a-b4178bb3fc65'})

======================================================================
FAIL: test_build_subject_directory_with_session_data (test_zipsession.SubjectDirectoryConstructorTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Workspaces\opencap\opencap-api\tests\test_zipsession.py", line 533, in test_build_subject_directory_with_session_data
    self.assertFalse(
AssertionError: True is not false

----------------------------------------------------------------------
Ran 127 tests in 514.099s

FAILED (failures=8, errors=18)
Destroying test database for alias 'default'...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants