repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
jazzband/django-silk | from unittest.mock import Mock, NonCallableMagicMock, NonCallableMock, patch
from django.test import TestCase
from django.utils.encoding import force_str
from silk.collector import DataCollector
from silk.models import Request, SQLQuery
from silk.sql import execute_sql
from .util import delete_all_models
_simple_mo... | mock_DataCollector().register_query.call_count) | self.assertFalse | func_call | project/tests/test_execute_sql.py | test_no_effect | TestCallSilky | 103 | null |
jazzband/django-silk | import datetime
import uuid
from django.core.management import call_command
from django.test import TestCase, override_settings
from freezegun import freeze_time
from silk import models
from silk.config import SilkyConfig
from silk.storage import ProfilerResultStorage
from .factories import RequestMinFactory, Respon... | '') | self.assertEqual | string_literal | project/tests/test_models.py | test_save_if_have_no_raw_body | RequestTest | 153 | null |
jazzband/django-silk | import cProfile
import os.path
import sys
from django.test import TestCase
from tests.util import DictStorage
from silk.collector import DataCollector
from silk.config import SilkyConfig
from .factories import RequestMinFactory
class TestCollector(TestCase):
def test_query_registration(self):
mock_quer... | list(DataCollector().queries.values())) | self.assertIn | func_call | project/tests/test_collector.py | test_query_registration | TestCollector | 24 | null |
jazzband/django-silk | import json
from unittest.mock import Mock
from django.test import TestCase
from silk.model_factory import RequestModelFactory, ResponseModelFactory
HTTP_CONTENT_TYPE = 'content-type'
class TestEncodingForResponse(TestCase):
def test_utf_plain(self):
mock = Mock()
mock.headers = {HTTP_CONTENT_T... | mock.content) | self.assertEqual | complex_expr | project/tests/test_encoding.py | test_utf_plain | TestEncodingForResponse | 95 | null |
jazzband/django-silk | import cProfile
import os
import tempfile
from contextlib import contextmanager
from unittest.mock import MagicMock
from django.test import TestCase
from networkx.drawing.nx_pydot import read_dot
from silk.views.profile_dot import (
_create_dot,
_create_profile,
_temp_file_from_file_field,
)
class Profil... | 0) | self.assertGreater | numeric_literal | project/tests/test_profile_dot.py | test_create_dot | ProfileDotViewTestCase | 91 | null |
jazzband/django-silk | from django.contrib.auth.models import User
from django.test import TestCase
from django.urls import NoReverseMatch, reverse
from silk.config import SilkyConfig, default_permissions
from silk.middleware import silky_reverse
class TestAuth(TestCase):
def test_authentication(self):
SilkyConfig().SILKY_AUTHE... | url) | self.assertIn | variable | project/tests/test_config_auth.py | test_authentication | TestAuth | 17 | null |
jazzband/django-silk | from django.core import management
from django.test import TestCase
from silk import models
from silk.config import SilkyConfig
from .factories import RequestMinFactory
class TestViewClearDB(TestCase):
def test_garbage_collect_command(self):
SilkyConfig().SILKY_MAX_RECORDED_REQUESTS = 2
RequestMi... | 1) | self.assertEqual | numeric_literal | project/tests/test_command_garbage_collect.py | test_garbage_collect_command | TestViewClearDB | 18 | null |
jazzband/django-silk | import contextlib
import cProfile
import io
import re
from django.test import TestCase
from silk.utils.profile_parser import parse_profile
class ProfileParserTestCase(TestCase):
def test_profile_parser(self):
"""
Verify that the function parse_profile produces the expected output.
"""
... | exc_header) | self.assertEqual | variable | project/tests/test_profile_parser.py | test_profile_parser | ProfileParserTestCase | 32 | null |
jazzband/django-silk | import cProfile
import os.path
import sys
from django.test import TestCase
from tests.util import DictStorage
from silk.collector import DataCollector
from silk.config import SilkyConfig
from .factories import RequestMinFactory
class TestCollector(TestCase):
def test_profile_file_name_with_long_path(self):
... | 51) | self.assertEqual | numeric_literal | project/tests/test_collector.py | test_profile_file_name_with_long_path | TestCollector | 90 | null |
jazzband/django-silk | from time import sleep
from django.test import TestCase
from silk.collector import DataCollector
from silk.models import Request, _time_taken
from silk.profiling.profiler import silk_profile
from .test_lib.mock_suite import MockSuite
class TestQueries(TestCase):
def test_no_queries_before(self):
DataCol... | 'test_no_queries_before_profile') | self.assertEqual | string_literal | project/tests/test_silky_profiler.py | test_no_queries_before | TestQueries | 105 | null |
jazzband/django-silk | import random
import unittest
from unittest.mock import Mock
from django.test import TestCase
from silk.middleware import silky_reverse
from silk.views.requests import RequestsView
from .test_lib.assertion import dict_contains
from .test_lib.mock_suite import MockSuite
class TestGetObjects(TestCase):
def assert... | getattr(nxt, sort_field)) | self.assertGreaterEqual | func_call | project/tests/test_view_requests.py | assertSorted | TestGetObjects | 125 | null |
jazzband/django-silk | import cProfile
import os.path
import sys
from django.test import TestCase
from tests.util import DictStorage
from silk.collector import DataCollector
from silk.config import SilkyConfig
from .factories import RequestMinFactory
class TestCollector(TestCase):
def test_finalise(self):
request = RequestMi... | content) | self.assertTrue | variable | project/tests/test_collector.py | test_finalise | TestCollector | 40 | null |
jazzband/django-silk | from time import sleep
from django.test import TestCase
from silk.collector import DataCollector
from silk.models import Request, _time_taken
from silk.profiling.profiler import silk_profile
from .test_lib.mock_suite import MockSuite
class TestProfilerRequests(TestCase):
def test_decorator_no_request(self):
... | profile['request']) | self.assertFalse | complex_expr | project/tests/test_silky_profiler.py | test_decorator_no_request | TestProfilerRequests | 28 | null |
jazzband/django-silk | import calendar
import random
from datetime import datetime, timedelta, timezone
from itertools import groupby
from math import floor
from django.test import TestCase
from django.utils import timezone as django_timezone
from silk import models
from silk.request_filters import (
AfterDateFilter,
BeforeDateFilt... | c) | self.assertGreaterEqual | variable | project/tests/test_filters.py | test_num_queries_filter | TestRequestFilters | 78 | null |
jazzband/django-silk | from unittest.mock import NonCallableMock
from django.test import TestCase
from silk.collector import DataCollector
from silk.config import SilkyConfig
from silk.middleware import SilkyMiddleware
from silk.models import Request
from .util import delete_all_models
def fake_get_response():
def fake_response():
... | r.meta_time) | self.assertFalse | complex_expr | project/tests/test_config_meta.py | test_disabled | TestConfigMeta | 50 | null |
jazzband/django-silk | from django.test import TestCase
from silk import models
from silk.config import SilkyConfig
from silk.middleware import silky_reverse
from .factories import RequestMinFactory
class TestViewClearDB(TestCase):
def setUpClass(cls):
super().setUpClass()
SilkyConfig().SILKY_AUTHENTICATION = False
... | 1) | self.assertEqual | numeric_literal | project/tests/test_view_clear_db.py | test_clear_all | TestViewClearDB | 19 | null |
jazzband/django-silk | from django.core import management
from django.test import TestCase
from silk import models
from silk.config import SilkyConfig
from .factories import RequestMinFactory
class TestViewClearDB(TestCase):
def test_garbage_collect_command(self):
SilkyConfig().SILKY_MAX_RECORDED_REQUESTS = 2
RequestMi... | 0) | self.assertEqual | numeric_literal | project/tests/test_command_garbage_collect.py | test_garbage_collect_command | TestViewClearDB | 22 | null |
jazzband/django-silk | from time import sleep
from django.test import TestCase
from silk.collector import DataCollector
from silk.models import Request, _time_taken
from silk.profiling.profiler import silk_profile
from .test_lib.mock_suite import MockSuite
class TestQueries(TestCase):
def test_no_queries_before(self):
DataCol... | queries) | self.assertIn | variable | project/tests/test_silky_profiler.py | test_no_queries_before | TestQueries | 109 | null |
jazzband/django-silk | from django.shortcuts import reverse
from django.test import Client, TestCase
from silk.collector import DataCollector
from silk.config import SilkyConfig
from silk.models import Request
from silk.profiling.profiler import silk_profile
from .factories import BlindFactory
class TestDbQueries(TestCase):
def setUp... | 302) | self.assertEqual | numeric_literal | project/tests/test_db.py | test_profile_request_to_db_with_constraints | TestDbQueries | 36 | null |
jazzband/django-silk | from collections import namedtuple
from django.test import TestCase
from silk.views.code import _code, _code_context, _code_context_from_request
FILE_PATH = __file__
LINE_NUM = 5
END_LINE_NUM = 10
class CodeTestCase(TestCase):
def assertActualLineEqual(self, actual_line, end_line_num=None):
expected_ac... | expected_actual_line) | self.assertEqual | variable | project/tests/test_code.py | assertActualLineEqual | CodeTestCase | 19 | null |
jazzband/django-silk | from unittest.mock import Mock
from django.test import TestCase
from django.urls import reverse
from silk.model_factory import RequestModelFactory, multipart_form
class TestMultipartForms(TestCase):
def test_no_max_request(self):
mock_request = Mock()
mock_request.headers = {'content-type': mult... | request_model.raw_body) | self.assertEqual | complex_expr | project/tests/test_multipart_forms.py | test_no_max_request | TestMultipartForms | 20 | null |
jazzband/django-silk | from django.apps import apps as proj_apps
from django.test import TestCase
from silk.apps import SilkAppConfig
class TestAppConfig(TestCase):
def test_app_config_loaded(self):
silk_app_config = proj_apps.get_app_config("silk")
self.assertIsInstance(silk_app_config, | SilkAppConfig) | self.assertIsInstance | variable | project/tests/test_app_config.py | test_app_config_loaded | TestAppConfig | 14 | null |
jazzband/django-silk | from unittest.mock import Mock
from django.test import TestCase
from silk.middleware import silky_reverse
from silk.views.profiling import ProfilingView
from .test_lib.assertion import dict_contains
from .test_lib.mock_suite import MockSuite
class TestProfilingViewDefaults(TestCase):
def test_order_by(self):
... | ProfilingView.order_by) | self.assertIn | complex_expr | project/tests/test_view_profiling.py | test_order_by | TestProfilingViewDefaults | 24 | null |
jazzband/django-silk | import json
from unittest.mock import Mock
from django.test import TestCase
from silk.model_factory import RequestModelFactory, ResponseModelFactory
HTTP_CONTENT_TYPE = 'content-type'
class TestEncodingForRequests(TestCase):
def test_utf_plain(self):
mock_request = Mock()
mock_request.headers =... | mock_request.body) | self.assertEqual | complex_expr | project/tests/test_encoding.py | test_utf_plain | TestEncodingForRequests | 24 | null |
jazzband/django-silk | from unittest.mock import Mock
from django.test import TestCase
from django.urls import reverse
from silk.collector import DataCollector
from silk.config import SilkyConfig
from silk.model_factory import RequestModelFactory, ResponseModelFactory
from silk.models import Request
class TestMaxBodySizeRequest(TestCase):... | request_model.raw_body) | self.assertTrue | complex_expr | project/tests/test_config_max_body_size.py | test_no_max_request | TestMaxBodySizeRequest | 23 | null |
jazzband/django-silk | import cProfile
import os.path
import sys
from django.test import TestCase
from tests.util import DictStorage
from silk.collector import DataCollector
from silk.config import SilkyConfig
from .factories import RequestMinFactory
class TestCollector(TestCase):
def test_finalise(self):
request = RequestMi... | file) | self.assertIsNotNone | variable | project/tests/test_collector.py | test_finalise | TestCollector | 37 | null |
jazzband/django-silk | from unittest.mock import patch
from django.test import TestCase
import silk
from silk.profiling.dynamic import (
_get_module,
_get_parent_module,
profile_function_or_method,
)
from .test_lib.assertion import dict_contains
from .util import mock_data_collector
class TestGetModule(TestCase):
def tes... | module.__name__) | self.assertEqual | complex_expr | project/tests/test_dynamic_profiling.py | test_singular | TestGetModule | 22 | null |
jazzband/django-silk | import datetime
import uuid
from django.core.management import call_command
from django.test import TestCase, override_settings
from freezegun import freeze_time
from silk import models
from silk.config import SilkyConfig
from silk.storage import ProfilerResultStorage
from .factories import RequestMinFactory, Respon... | 10.5) | self.assertEqual | numeric_literal | project/tests/test_models.py | test_total_meta_time_if_have_meta_time_spent_queries | RequestTest | 56 | null |
jazzband/django-silk | from unittest.mock import Mock
from django.test import TestCase
from django.urls import reverse
from silk.collector import DataCollector
from silk.config import SilkyConfig
from silk.model_factory import RequestModelFactory, ResponseModelFactory
from silk.models import Request
class TestMaxBodySizeResponse(TestCase)... | response_model.raw_body) | self.assertTrue | complex_expr | project/tests/test_config_max_body_size.py | test_no_max_response | TestMaxBodySizeResponse | 50 | null |
jazzband/django-silk | from unittest.mock import Mock, NonCallableMagicMock, NonCallableMock, patch
from django.test import TestCase
from django.utils.encoding import force_str
from silk.collector import DataCollector
from silk.models import Request, SQLQuery
from silk.sql import execute_sql
from .util import delete_all_models
_simple_mo... | DataCollector().request) | self.assertEqual | func_call | project/tests/test_execute_sql.py | test_request | TestCollectorInteraction | 119 | null |
jazzband/django-silk | import random
import unittest
from unittest.mock import Mock
from django.test import TestCase
from silk.middleware import silky_reverse
from silk.views.requests import RequestsView
from .test_lib.assertion import dict_contains
from .test_lib.mock_suite import MockSuite
class TestGetObjects(TestCase):
def assert... | 10) | self.assertEqual | numeric_literal | project/tests/test_view_requests.py | test_show | TestGetObjects | 141 | null |
jazzband/django-silk | from collections import namedtuple
from django.test import TestCase
from silk.views.code import _code, _code_context, _code_context_from_request
FILE_PATH = __file__
LINE_NUM = 5
END_LINE_NUM = 10
class CodeTestCase(TestCase):
def assertActualLineEqual(self, actual_line, end_line_num=None):
expected_ac... | LINE_NUM) | self.assertEqual | variable | project/tests/test_code.py | test_code_context | CodeTestCase | 38 | null |
jazzband/django-silk | from unittest.mock import Mock
from django.test import TestCase
from django.urls import reverse
from silk.model_factory import RequestModelFactory, multipart_form
class TestMultipartForms(TestCase):
def test_no_max_request(self):
mock_request = Mock()
mock_request.headers = {'content-type': mult... | request_model.body) | self.assertFalse | complex_expr | project/tests/test_multipart_forms.py | test_no_max_request | TestMultipartForms | 19 | null |
jazzband/django-silk | from unittest.mock import Mock, NonCallableMagicMock, NonCallableMock, patch
from django.test import TestCase
from django.utils.encoding import force_str
from silk.collector import DataCollector
from silk.models import Request, SQLQuery
from silk.sql import execute_sql
from .util import delete_all_models
_simple_mo... | *self.args) | assert_* | complex_expr | project/tests/test_execute_sql.py | test_called | TestCallNoRequest | 65 | null |
jazzband/django-silk | from time import sleep
from django.test import TestCase
from silk.collector import DataCollector
from silk.models import Request, _time_taken
from silk.profiling.profiler import silk_profile
from .test_lib.mock_suite import MockSuite
class TestProfilerDecorator(TestCase):
def setUpClass(cls):
super().s... | 115) | self.assertLess | numeric_literal | project/tests/test_silky_profiler.py | test_time_taken | TestProfilerDecorator | 95 | null |
jazzband/django-silk | import calendar
import random
from datetime import datetime, timedelta, timezone
from itertools import groupby
from math import floor
from django.test import TestCase
from django.utils import timezone as django_timezone
from silk import models
from silk.request_filters import (
AfterDateFilter,
BeforeDateFilt... | p.func_name == func_name) | self.assertTrue | complex_expr | project/tests/test_filters.py | test_function_name_filter | TestProfileFilters | 201 | null |
jazzband/django-silk | import json
from unittest.mock import Mock
from django.test import TestCase
from silk.config import SilkyConfig
from silk.model_factory import RequestModelFactory
HTTP_CONTENT_TYPE = 'content-type'
CLEANSED = RequestModelFactory.CLEANSED_SUBSTITUTE
DEFAULT_SENSITIVE_KEYS = {'username', 'api', 'token', 'key', 'secret... | body) | self.assertNotIn | variable | project/tests/test_sensitive_data_in_request.py | test_password_in_body | TestEncodingForRequests | 156 | null |
jazzband/django-silk | from unittest.mock import Mock
from django.test import TestCase
from silk.middleware import silky_reverse
from silk.views.profiling import ProfilingView
from .test_lib.assertion import dict_contains
from .test_lib.mock_suite import MockSuite
class TestProfilingViewDefaults(TestCase):
def test_show(self):
... | ProfilingView.show) | self.assertIn | complex_expr | project/tests/test_view_profiling.py | test_show | TestProfilingViewDefaults | 21 | null |
jazzband/django-silk | from unittest.mock import Mock, NonCallableMagicMock, NonCallableMock, patch
from django.test import TestCase
from django.utils.encoding import force_str
from silk.collector import DataCollector
from silk.models import Request, SQLQuery
from silk.sql import execute_sql
from .util import delete_all_models
_simple_mo... | DataCollector().queries.values()) | self.assertIn | func_call | project/tests/test_execute_sql.py | test_registration | TestCollectorInteraction | 126 | null |
jazzband/django-silk | import random
import unittest
from unittest.mock import Mock
from django.test import TestCase
from silk.middleware import silky_reverse
from silk.views.requests import RequestsView
from .test_lib.assertion import dict_contains
from .test_lib.mock_suite import MockSuite
class TestRootViewDefaults(TestCase):
def ... | paths) | self.assertIn | variable | project/tests/test_view_requests.py | test_path | TestRootViewDefaults | 19 | null |
jazzband/django-silk | import cProfile
import os.path
import sys
from django.test import TestCase
from tests.util import DictStorage
from silk.collector import DataCollector
from silk.config import SilkyConfig
from .factories import RequestMinFactory
class TestCollector(TestCase):
def test_configure_exception(self):
other_pr... | collector.local.pythonprofiler) | self.assertIsNotNone | complex_expr | project/tests/test_collector.py | test_configure_exception | TestCollector | 63 | null |
jazzband/django-silk | import calendar
import random
from datetime import datetime, timedelta, timezone
from itertools import groupby
from math import floor
from django.test import TestCase
from django.utils import timezone as django_timezone
from silk import models
from silk.request_filters import (
AfterDateFilter,
BeforeDateFilt... | r.path == path) | self.assertTrue | complex_expr | project/tests/test_filters.py | test_path_filter | TestRequestFilters | 67 | null |
jazzband/django-silk | from django.shortcuts import reverse
from django.test import Client, TestCase
from silk.collector import DataCollector
from silk.config import SilkyConfig
from silk.models import Request
from silk.profiling.profiler import silk_profile
from .factories import BlindFactory
class TestDbQueries(TestCase):
def setUp... | 5 | assert | numeric_literal | project/tests/test_db.py | test_profile_request_to_db | TestDbQueries | 30 | null |
jazzband/django-silk | import calendar
import random
from datetime import datetime, timedelta, timezone
from itertools import groupby
from math import floor
from django.test import TestCase
from django.utils import timezone as django_timezone
from silk import models
from silk.request_filters import (
AfterDateFilter,
BeforeDateFilt... | filtered.count()) | self.assertEqual | func_call | project/tests/test_filters.py | test_status_code_filter | TestRequestFilters | 111 | null |
jazzband/django-silk | import random
import unittest
from unittest.mock import Mock
from django.test import TestCase
from silk.middleware import silky_reverse
from silk.views.requests import RequestsView
from .test_lib.assertion import dict_contains
from .test_lib.mock_suite import MockSuite
class TestContext(TestCase):
def test_vie... | dict_contains({ 'show': show, 'order_by': order_by, 'path': path, }, context)) | self.assertTrue | func_call | project/tests/test_view_requests.py | test_view_without_session_and_auth_middlewares | TestContext | 101 | null |
jazzband/django-silk | from unittest.mock import Mock
from django.test import TestCase
from silk.model_factory import RequestModelFactory
class TestLongRequestUrl(TestCase):
def test_long_url(self):
url = '1234567890' * 200 # 2000-character URL
mock_request = Mock()
mock_request.headers = {'content-type': 'te... | f'{url[:94]}...{url[1907:]}') | self.assertEqual | string_literal | project/tests/test_config_long_urls.py | test_long_url | TestLongRequestUrl | 28 | null |
jazzband/django-silk | import calendar
import random
from datetime import datetime, timedelta, timezone
from itertools import groupby
from math import floor
from django.test import TestCase
from django.utils import timezone as django_timezone
from silk import models
from silk.request_filters import (
AfterDateFilter,
BeforeDateFilt... | r.start_time < dt) | self.assertTrue | complex_expr | project/tests/test_filters.py | assertFilter | TestRequestBeforeDateFilter | 158 | null |
jazzband/django-silk | import os
import random
from unittest.mock import patch
from django.conf import settings
from django.test import TestCase
from silk.config import SilkyConfig
from silk.middleware import silky_reverse
from silk.views.sql_detail import SQLDetailView
from .test_lib.mock_suite import MockSuite
class TestViewSQLDetail(T... | os.environ.get('VIRTUAL_ENV')) | self.assertIsNone | func_call | project/tests/test_view_sql_detail.py | test_virtualenv_not_available_no_highlight | TestViewSQLDetail | 67 | null |
jazzband/django-silk | from unittest.mock import patch
from django.test import TestCase, override_settings
from django.urls import reverse
from silk.config import SilkyConfig
from silk.errors import SilkNotConfigured
from silk.middleware import SilkyMiddleware, _should_intercept
from silk.models import Request
from .util import mock_data_... | should_intercept) | self.assertTrue | variable | project/tests/test_silky_middleware.py | test_should_intercept_non_silk_request | TestShouldIntercept | 126 | null |
jazzband/django-silk | from django.core import management
from django.test import TestCase
from silk import models
from silk.config import SilkyConfig
from .factories import RequestMinFactory
class TestViewClearDB(TestCase):
def test_garbage_collect_command(self):
SilkyConfig().SILKY_MAX_RECORDED_REQUESTS = 2
RequestMi... | 2) | self.assertEqual | numeric_literal | project/tests/test_command_garbage_collect.py | test_garbage_collect_command | TestViewClearDB | 16 | null |
jazzband/django-silk | import json
from unittest.mock import Mock
from django.test import TestCase
from silk.config import SilkyConfig
from silk.model_factory import RequestModelFactory
HTTP_CONTENT_TYPE = 'content-type'
CLEANSED = RequestModelFactory.CLEANSED_SUBSTITUTE
DEFAULT_SENSITIVE_KEYS = {'username', 'api', 'token', 'key', 'secret... | body[0]) | self.assertNotIn | complex_expr | project/tests/test_sensitive_data_in_request.py | test_password_in_batched_json | TestEncodingForRequests | 196 | null |
jazzband/django-silk | from unittest.mock import Mock
from django.test import TestCase
from silk.middleware import silky_reverse
from silk.views.profiling import ProfilingView
from .test_lib.assertion import dict_contains
from .test_lib.mock_suite import MockSuite
class TestProfilingContext(TestCase):
def test_default(self):
... | context) | self.assertNotIn | variable | project/tests/test_view_profiling.py | test_default | TestProfilingContext | 71 | null |
jazzband/django-silk | import shlex
from unittest import TestCase
from silk.code_generation.curl import curl_cmd
class TestCodeGenCurl(TestCase):
def test_post_json(self):
result = curl_cmd(
url="https://example.org/alpha/beta",
method="POST",
body={"gamma": "delta"},
content_type... | [ 'curl', '-X', 'POST', '-H', 'content-type: application/json', '-d', '{"gamma": "delta"}', 'https://example.org/alpha/beta' ]) | self.assertEqual | collection | project/tests/test_code_gen_curl.py | test_post_json | TestCodeGenCurl | 18 | null |
jazzband/django-silk | import calendar
import random
from datetime import datetime, timedelta, timezone
from itertools import groupby
from math import floor
from django.test import TestCase
from django.utils import timezone as django_timezone
from silk import models
from silk.request_filters import (
AfterDateFilter,
BeforeDateFilt... | r.start_time > dt) | self.assertTrue | complex_expr | project/tests/test_filters.py | assertFilter | TestRequestAfterDateFilter | 129 | null |
jazzband/django-silk | from time import sleep
from django.test import TestCase
from silk.collector import DataCollector
from silk.models import Request, _time_taken
from silk.profiling.profiler import silk_profile
from .test_lib.mock_suite import MockSuite
class TestProfilertContextManager(TestCase):
def setUpClass(cls):
sup... | 100) | self.assertGreaterEqual | numeric_literal | project/tests/test_silky_profiler.py | test_time_taken | TestProfilertContextManager | 68 | null |
fla-org/flash-linear-attention | import argparse
import os
import random
import sys
from functools import partial
import torch
import torch.distributed as dist
import torch.nn.functional as F
from einops import rearrange, repeat
from fla.models.utils import Cache
from fla.modules.convolution import causal_conv1d
from fla.ops.gated_delta_rule import ... | [1, 2] | assert | collection | benchmarks/cp/test_gdn_with_cp.py | a2a | 81 | null | |
fla-org/flash-linear-attention | import pytest
import torch
import torch.nn as nn
from einops import rearrange
from transformers.models.llama.modeling_llama import LlamaRMSNorm
from fla.modules import GroupNorm, GroupNormLinear, LayerNorm, LayerNormLinear, RMSNorm, RMSNormLinear
from fla.modules.layernorm import GroupNormRef
from fla.utils import ass... | 1e-3) | assert_* | numeric_literal | tests/modules/test_layernorm.py | test_layernorm | 42 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.generalized_delta_rule.dplr.fused_recurrent import fused_recurrent_dplr_delta_rule
from fla.ops.rwkv7.channel_mixing import channel_mixing_rwkv7, channel_mixing_rwkv7_torch
from fla.ops.rwkv7.fused_addcmul import fused_addcmul_rwkv7, to... | xr1) | assert_* | variable | tests/ops/test_rwkv7.py | test_fused_rwkv7_addcmul | 174 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.path_attn import naive_path_attn
from fla.ops.path_attn.parallel import parallel_path_attention
from fla.utils import IS_INTEL_ALCHEMIST, assert_close, device
@pytest.mark.parametrize(
('B', 'T', 'H', 'HQ', 'D', 'use_forget_gate', ... | 0.005) | assert_* | numeric_literal | tests/ops/test_path_attn.py | test_parallel | 76 | null | |
fla-org/flash-linear-attention | import logging
import os
import pytest
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
from fla.modules.convolution import causal_conv1d
from fla.ops.cp import build_cp_context
from fla.utils import assert_close
logging.basicConfig(level=logging.INFO, format='%(message)s')
def init_... | T | assert | variable | tests/context_parallel/test_cp_conv.py | run_cp_conv_test_worker | 100 | null | |
fla-org/flash-linear-attention | import pytest
import torch
from fla.modules.rotary import RotaryEmbedding, rotary_embedding_ref
from fla.utils import assert_close, device
@pytest.mark.parametrize("B", [2])
@pytest.mark.parametrize("T", [2048, 4096])
@pytest.mark.parametrize("H", [4])
@pytest.mark.parametrize("G", [1, 4])
@pytest.mark.parametrize("D... | tri_k) | assert_* | variable | tests/modules/test_rotary.py | test_rotary | 31 | null | |
fla-org/flash-linear-attention | import logging
import os
import pytest
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
import torch.nn.functional as F
from fla.ops.cp import build_cp_context
from fla.ops.kda import chunk_kda
from fla.ops.kda.gate import naive_kda_lowerbound_gate
from fla.ops.kda.naive import naive_r... | T | assert | variable | tests/context_parallel/test_cp_kda.py | run_cp_kda_test_worker | 170 | null | |
fla-org/flash-linear-attention | import os
import numpy as np
import pytest
import torch
from fla.ops.log_linear_attn import chunk_log_linear_attn
from fla.ops.log_linear_attn.naive import naive_log_linear_attn
from fla.utils import assert_close, device, device_platform
@pytest.mark.parametrize(
("B", "T", "H", "D", "dtype"),
[
pyte... | 0.008) | assert_* | numeric_literal | tests/ops/test_log_linear_attn.py | test_chunk_bwd | 92 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
from transformers.configuration_utils import PretrainedConfig
from fla.utils import IS_INTEL_ALCHEMIST, IS_NVIDIA_HOPPER, assert_close, device
from .test_modeling_utils import (
GENERATION_UNSUPPORTED,
HOPPER_EXCLUSIVE,
MODELING_UNSUPPORTED_VARLEN,
NOT_READY_FOR_T... | tol) | assert_* | variable | tests/models/test_modeling_base.py | run_test_generation | 127 | null | |
fla-org/flash-linear-attention | import pytest
import torch
import torch.nn.functional as F
from fla.modules import FusedKLDivLoss
from fla.utils import assert_close, device, device_platform
@pytest.mark.parametrize("B", [2])
@pytest.mark.parametrize("T", [16, 32])
@pytest.mark.parametrize("D", [1024, 2048])
@pytest.mark.parametrize("V", [32000, 100... | 1e-2) | assert_* | numeric_literal | tests/modules/test_kl_div.py | test_fused | 42 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.comba import chunk_comba, fused_recurrent_comba
from fla.ops.comba.naive import naive_chunk_comba
from fla.ops.comba.utils import chunk_comba_cumsum_scalar_fwd
from fla.utils import IS_INTEL_ALCHEMIST, assert_close, device
def cumsum_c... | 0.008) | assert_* | numeric_literal | tests/ops/test_comba.py | test_chunk | 194 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.path_attn import naive_path_attn
from fla.ops.path_attn.parallel import parallel_path_attention
from fla.utils import IS_INTEL_ALCHEMIST, assert_close, device
@pytest.mark.parametrize(
('B', 'T', 'H', 'HQ', 'D', 'use_forget_gate', ... | 0.02) | assert_* | numeric_literal | tests/ops/test_path_attn.py | test_parallel | 83 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.mesa_net import chunk_mesa_net, mesa_net_decoding_one_step, naive_mesa_net_decoding_one_step, naive_mesa_net_exact
from fla.utils import IS_INTEL_ALCHEMIST, assert_close, device, device_platform
@pytest.mark.parametrize(
('B', 'T',... | 0.008) | assert_* | numeric_literal | tests/ops/test_mesa.py | test_chunk | 92 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.generalized_delta_rule.dplr.fused_recurrent import fused_recurrent_dplr_delta_rule
from fla.ops.rwkv7.channel_mixing import channel_mixing_rwkv7, channel_mixing_rwkv7_torch
from fla.ops.rwkv7.fused_addcmul import fused_addcmul_rwkv7, to... | ka.grad) | assert_* | complex_expr | tests/ops/test_rwkv7.py | test_fused_k_update | 260 | null | |
fla-org/flash-linear-attention | import pytest
import torch
from fla.modules.token_shift import token_shift, token_shift_ref
from fla.utils import assert_close, device
test_b_list = [4]
test_t_list = [512, 4100, 8192]
test_h_list = [2560, 4096]
test_cu_seqlens_list = [
None,
[0, 4, 7, 40, 128],
[0, 10, 20, 64],
[0, 32],
[0, 1, 3,... | None | assert | none_literal | tests/modules/test_token_shift.py | test_all_with_and_without_varlen | 132 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from einops import rearrange
from fla.ops.gated_oja_rule import chunk_gated_oja_rule, fused_recurrent_gated_oja_rule
from fla.utils import assert_close, device, is_intel_alchemist
def recurrent_oja_ref(
q: torch.Tensor,
k: torch.Tensor,
... | 0 | assert | numeric_literal | tests/ops/test_oja.py | chunk_oja_ref | 81 | null | |
fla-org/flash-linear-attention | import pytest
import torch
import fla.ops.common.intracard_cp as intracard_cp_mod
from fla.ops.common.intracard_cp import _intracard_cache
from fla.ops.kda import chunk_kda
from fla.utils import device
def clear_intracard_cache():
_intracard_cache.clear()
yield
_intracard_cache.clear()
@pytest.mark.skipi... | id(cu_seqlens) | assert | func_call | tests/ops/test_intracard_cache.py | test_chunk_kda_intracard_cache_hit_same_cu_seqlens_object | 88 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.generalized_delta_rule.dplr.fused_recurrent import fused_recurrent_dplr_delta_rule
from fla.ops.rwkv7.channel_mixing import channel_mixing_rwkv7, channel_mixing_rwkv7_torch
from fla.ops.rwkv7.fused_addcmul import fused_addcmul_rwkv7, to... | xv1) | assert_* | variable | tests/ops/test_rwkv7.py | test_fused_rwkv7_addcmul | 177 | null | |
fla-org/flash-linear-attention | import pytest
import torch
from fla.models.utils import FLACache
from fla.utils import device
def test_cache_get_seq_length_nonexistent_layer():
"""
Test that get_seq_length returns 0 for non-existent layers
and handles None layer_idx correctly for populated caches.
"""
cache = FLACache()
# S... | 10 | assert | numeric_literal | tests/models/test_cache.py | test_cache_get_seq_length_nonexistent_layer | 134 | null | |
fla-org/flash-linear-attention | import pytest
import torch
from fla.ops.utils.index import (
prepare_chunk_indices,
prepare_chunk_offsets,
prepare_position_ids,
prepare_sequence_ids,
prepare_split_cu_seqlens,
prepare_token_indices,
)
from fla.utils import device
def ref_prepare_sequence_ids(cu_seqlens):
seqlens = (cu_seq... | opt_split_var) | assert_* | variable | tests/ops/test_index.py | test_split_cu_seqlens_correctness | 156 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.generalized_delta_rule.dplr.fused_recurrent import fused_recurrent_dplr_delta_rule
from fla.ops.rwkv7.channel_mixing import channel_mixing_rwkv7, channel_mixing_rwkv7_torch
from fla.ops.rwkv7.fused_addcmul import fused_addcmul_rwkv7, to... | x_k2.grad) | assert_* | complex_expr | tests/ops/test_rwkv7.py | test_channel_mixing_gradients | 70 | null | |
fla-org/flash-linear-attention | import pytest
import torch
from fla.ops.deltaformer import deltaformer_attn
from fla.ops.deltaformer.naive import naive_deltaformer_attn
from fla.utils import IS_INTEL_ALCHEMIST, assert_close, device
@pytest.mark.parametrize(
('B', 'T', 'H', 'D', 'dtype'),
[
pytest.param(*test, id="B{}-T{}-H{}-D{}-{}"... | 0.006) | assert_* | numeric_literal | tests/ops/test_deltaformer.py | test_deltaformer_attn | 60 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from einops import repeat
from fla.ops.gated_delta_rule import chunk_gated_delta_rule, fused_recurrent_gated_delta_rule
from fla.ops.gated_delta_rule.naive import naive_recurrent_gated_delta_rule
from fla.utils import IS_INTEL_ALCHEMIST, assert_clos... | 0.002) | assert_* | numeric_literal | tests/ops/test_gated_delta.py | test_fused_recurrent | 71 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.mesa_net import chunk_mesa_net, mesa_net_decoding_one_step, naive_mesa_net_decoding_one_step, naive_mesa_net_exact
from fla.utils import IS_INTEL_ALCHEMIST, assert_close, device, device_platform
@pytest.mark.parametrize(
('B', 'T',... | 0.006) | assert_* | numeric_literal | tests/ops/test_mesa.py | test_chunk | 91 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.generalized_delta_rule.dplr.fused_recurrent import fused_recurrent_dplr_delta_rule
from fla.ops.rwkv7.channel_mixing import channel_mixing_rwkv7, channel_mixing_rwkv7_torch
from fla.ops.rwkv7.fused_addcmul import fused_addcmul_rwkv7, to... | K_2.grad) | assert_* | complex_expr | tests/ops/test_rwkv7.py | test_channel_mixing_gradients | 71 | null | |
fla-org/flash-linear-attention | import pytest
import torch
import torch.nn.functional as F
from fla.ops.kda import chunk_kda, fused_recurrent_kda
from fla.ops.kda.fused_recurrent import fused_recurrent_kda_fwd
from fla.ops.kda.gate import fused_kda_gate, naive_kda_gate, naive_kda_lowerbound_gate
from fla.ops.kda.naive import naive_chunk_kda, naive_r... | dtype | assert | variable | tests/ops/test_kda.py | test_chunk_return_intermediate_states | 711 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.mesa_net import chunk_mesa_net, mesa_net_decoding_one_step, naive_mesa_net_decoding_one_step, naive_mesa_net_exact
from fla.utils import IS_INTEL_ALCHEMIST, assert_close, device, device_platform
@pytest.mark.parametrize(
('B', 'H',... | 0.005) | assert_* | numeric_literal | tests/ops/test_mesa.py | test_decoding_one_step | 275 | null | |
fla-org/flash-linear-attention | import pytest
import torch
import torch.nn.functional as F
from einops import rearrange
from fla.modules.convolution import ShortConvolution, causal_conv1d, causal_conv1d_update
from fla.utils import assert_close, device
def causal_conv1d_ref_torch(
x,
weight,
bias=None,
initial_state=None,
output... | False | assert | bool_literal | tests/modules/test_conv.py | test_fast_conv_varlen | 798 | null | |
fla-org/flash-linear-attention | import pytest
import torch
from fla.modules.grpo import fused_grpo_loss, grpo_loss_torch
from fla.utils import IS_NVIDIA_HOPPER, assert_close, device, device_torch_lib
@pytest.mark.parametrize("B", [2])
@pytest.mark.parametrize("T", [16, 1024, 4096])
@pytest.mark.parametrize("V", [32000, 65536])
@pytest.mark.parametr... | 3e-3) | assert_* | numeric_literal | tests/modules/test_grpo.py | test_fused_grpos | 57 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
from fla.ops.utils import chunk_global_cumsum, chunk_local_cumsum, mean_pooling
from fla.ops.utils.index import prepare_lens
from fla.ops.utils.pack import pack_sequence, unpack_sequence
from fla.utils import assert_close, device
def reversed_cumsum(x, dim=-1):
dtype = x.dtyp... | 1e-3) | assert_* | numeric_literal | tests/ops/test_utils.py | test_global_cumsum | 45 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.rwkv6 import chunk_rwkv6
from fla.ops.rwkv6.fused_recurrent import fused_recurrent_rwkv6
from fla.utils import assert_close, device, device_platform
@pytest.mark.skipif(
device_platform == 'intel',
reason="Intel Triton Failure"... | 0.005) | assert_* | numeric_literal | tests/ops/test_rwkv6.py | test_chunk | 99 | null | |
fla-org/flash-linear-attention | import pytest
import torch
import torch.nn as nn
import torch.nn.functional as F
from fla.modules import FusedLayerNormGated, FusedRMSNormGated
from fla.utils import assert_close, device
@pytest.mark.parametrize(
('B', 'H', 'T', 'D', 'elementwise_affine', 'activation', 'bias'),
[
pytest.param(*test, i... | 1e-3) | assert_* | numeric_literal | tests/modules/test_layernorm_gated.py | test_layernorm_gated | 50 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.generalized_delta_rule.dplr.fused_recurrent import fused_recurrent_dplr_delta_rule
from fla.ops.rwkv7.channel_mixing import channel_mixing_rwkv7, channel_mixing_rwkv7_torch
from fla.ops.rwkv7.fused_addcmul import fused_addcmul_rwkv7, to... | V_2.grad) | assert_* | complex_expr | tests/ops/test_rwkv7.py | test_channel_mixing_gradients | 72 | null | |
fla-org/flash-linear-attention | import pytest
import torch
from fla.modules.rotary import RotaryEmbedding, rotary_embedding_ref
from fla.utils import assert_close, device
@pytest.mark.parametrize("B", [2])
@pytest.mark.parametrize("T", [2048, 4096])
@pytest.mark.parametrize("H", [4])
@pytest.mark.parametrize("G", [1, 4])
@pytest.mark.parametrize("D... | tri_dk) | assert_* | variable | tests/modules/test_rotary.py | test_rotary | 33 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.simple_gla.chunk import chunk_simple_gla
from fla.ops.simple_gla.fused_chunk import fused_chunk_simple_gla
from fla.ops.simple_gla.fused_recurrent import fused_recurrent_simple_gla
from fla.ops.simple_gla.naive import naive_parallel_sim... | 0.005) | assert_* | numeric_literal | tests/ops/test_simple_gla.py | test_fused_recurrent | 83 | null | |
fla-org/flash-linear-attention | import pytest
import torch
from fla.ops.utils.index import (
prepare_chunk_indices,
prepare_chunk_offsets,
prepare_position_ids,
prepare_sequence_ids,
prepare_split_cu_seqlens,
prepare_token_indices,
)
from fla.utils import device
def ref_prepare_sequence_ids(cu_seqlens):
seqlens = (cu_seq... | opt_seq) | assert_* | variable | tests/ops/test_index.py | test_prepare_ids_correctness | 88 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.gla import chunk_gla, fused_recurrent_gla
from fla.ops.gla.naive import naive_recurrent_gla
from fla.utils import assert_close, device, device_platform
@pytest.mark.parametrize(
('B', 'T', 'H', 'D', 'gate_logit_normalizer', 'dtype'... | 0.004) | assert_* | numeric_literal | tests/ops/test_gla.py | test_chunk | 241 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from einops import repeat
from fla.ops.gated_delta_rule import chunk_gated_delta_rule, fused_recurrent_gated_delta_rule
from fla.ops.gated_delta_rule.naive import naive_recurrent_gated_delta_rule
from fla.utils import IS_INTEL_ALCHEMIST, assert_clos... | 0.007) | assert_* | numeric_literal | tests/ops/test_gated_delta.py | test_chunk_varlen | 240 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.ttt import chunk_ttt_linear, fused_chunk_ttt_linear
from fla.ops.ttt.naive import chunk_ttt_linear_ref
from fla.utils import assert_close, check_shared_mem, device
@pytest.mark.parametrize(
('B', 'T', 'H', 'D', 'scale', 'dtype'),
... | 0.005) | assert_* | numeric_literal | tests/ops/test_ttt.py | test_chunk | 87 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
from fla.models import LogLinearMamba2Config, LogLinearMamba2ForCausalLM
from fla.utils import device
@pytest.mark.parametrize(
['L', 'B', 'T', 'H', 'D', 'dtype', 'conv_backend'],
[
pytest.param(*test, id="L{}-B{}-T{}-H{}-D{}-{}-conv-{}".format(*test))
for... | (B, T, config.vocab_size) | assert | collection | tests/models/test_modeling_log_linear_mamba2.py | test_modeling | 65 | null | |
fla-org/flash-linear-attention | import pytest
import torch
import torch.nn.functional as F
from fla.ops.gated_delta_product import chunk_gated_delta_product
from fla.ops.gated_delta_product.chunk_ref import chunk_gated_delta_product_ref
from fla.ops.gated_delta_product.naive import naive_recurrent_gated_delta_product
from fla.utils import assert_clo... | 0.005) | assert_* | numeric_literal | tests/ops/test_delta_product.py | test_chunk | 82 | null | |
fla-org/flash-linear-attention | import pytest
import torch
import torch.nn.functional as F
from fla.ops.kda import chunk_kda, fused_recurrent_kda
from fla.ops.kda.fused_recurrent import fused_recurrent_kda_fwd
from fla.ops.kda.gate import fused_kda_gate, naive_kda_gate, naive_kda_lowerbound_gate
from fla.ops.kda.naive import naive_chunk_kda, naive_r... | 0.005) | assert_* | numeric_literal | tests/ops/test_kda.py | test_naive_chunk | 72 | null | |
fla-org/flash-linear-attention | import pytest
import torch
import torch.nn.functional as F
from fla.ops.kda import chunk_kda, fused_recurrent_kda
from fla.ops.kda.fused_recurrent import fused_recurrent_kda_fwd
from fla.ops.kda.gate import fused_kda_gate, naive_kda_gate, naive_kda_lowerbound_gate
from fla.ops.kda.naive import naive_chunk_kda, naive_r... | 0.0) | assert_* | numeric_literal | tests/ops/test_kda.py | test_fused_recurrent_vllm_decode | 270 | null | |
fla-org/flash-linear-attention | import logging
import os
import pytest
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
import torch.nn.functional as F
from fla.ops.cp import build_cp_context
from fla.ops.gated_delta_rule import chunk_gated_delta_rule
from fla.utils import assert_close
logging.basicConfig(level=logg... | cp) | assert_* | variable | tests/context_parallel/test_cp_gdn.py | run_cp_gdn_test_worker | 255 | null | |
fla-org/flash-linear-attention | import os
import pytest
import torch
import torch.nn.functional as F
from fla.ops.generalized_delta_rule.dplr.fused_recurrent import fused_recurrent_dplr_delta_rule
from fla.ops.rwkv7.channel_mixing import channel_mixing_rwkv7, channel_mixing_rwkv7_torch
from fla.ops.rwkv7.fused_addcmul import fused_addcmul_rwkv7, to... | a.grad) | assert_* | complex_expr | tests/ops/test_rwkv7.py | test_fused_k_update | 259 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.