Dataset Viewer
Auto-converted to Parquet Duplicate
uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
c7183a932a431416aa5d0df6
train
class
class FakeDriver(log_driver_base.DriverBase): @staticmethod def create(): return FakeDriver( name='fake_driver', vif_types=[], vnic_types=[], supported_logging_types=['security_group'], requires_rpc=True )
class FakeDriver(log_driver_base.DriverBase): @staticmethod
def create(): return FakeDriver( name='fake_driver', vif_types=[], vnic_types=[], supported_logging_types=['security_group'], requires_rpc=True )
resources from neutron.services.logapi.common import sg_callback from neutron.services.logapi.drivers import base as log_driver_base from neutron.services.logapi.drivers import manager as driver_mgr from neutron.tests import base FAKE_DRIVER = None class FakeDriver(log_driver_base.DriverBase): @staticmethod
64
64
54
13
50
congnt95/neutron
neutron/tests/unit/services/logapi/common/test_sg_callback.py
Python
FakeDriver
FakeDriver
30
40
30
32
449232f753acc54ea1c1fe619e4d36a2d99c7fa5
bigcode/the-stack
train
0cc48661c407ab0595bbb6f3
train
class
class TestSecurityGroupRuleCallback(base.BaseTestCase): def setUp(self): super(TestSecurityGroupRuleCallback, self).setUp() self.driver_manager = driver_mgr.LoggingServiceDriverManager() @mock.patch.object(sg_callback.SecurityGroupRuleCallBack, 'handle_event') def test_handle_event(self, m...
class TestSecurityGroupRuleCallback(base.BaseTestCase):
def setUp(self): super(TestSecurityGroupRuleCallback, self).setUp() self.driver_manager = driver_mgr.LoggingServiceDriverManager() @mock.patch.object(sg_callback.SecurityGroupRuleCallBack, 'handle_event') def test_handle_event(self, mock_sg_cb): fake_register() self.driver_m...
'], requires_rpc=True ) def fake_register(): global FAKE_DRIVER if not FAKE_DRIVER: FAKE_DRIVER = FakeDriver.create() driver_mgr.register(resources.SECURITY_GROUP_RULE, sg_callback.SecurityGroupRuleCallBack) class TestSecurityGroupRuleCallback(base.BaseT...
64
64
210
11
53
congnt95/neutron
neutron/tests/unit/services/logapi/common/test_sg_callback.py
Python
TestSecurityGroupRuleCallback
TestSecurityGroupRuleCallback
51
72
51
52
9a81d52be4fe80290df7de4b8f7b243e66cea47a
bigcode/the-stack
train
d4f4b62d3518c1e2cffd46d8
train
function
def fake_register(): global FAKE_DRIVER if not FAKE_DRIVER: FAKE_DRIVER = FakeDriver.create() driver_mgr.register(resources.SECURITY_GROUP_RULE, sg_callback.SecurityGroupRuleCallBack)
def fake_register():
global FAKE_DRIVER if not FAKE_DRIVER: FAKE_DRIVER = FakeDriver.create() driver_mgr.register(resources.SECURITY_GROUP_RULE, sg_callback.SecurityGroupRuleCallBack)
FAKE_DRIVER = None class FakeDriver(log_driver_base.DriverBase): @staticmethod def create(): return FakeDriver( name='fake_driver', vif_types=[], vnic_types=[], supported_logging_types=['security_group'], requires_rpc=True ) def fake...
64
64
45
4
60
congnt95/neutron
neutron/tests/unit/services/logapi/common/test_sg_callback.py
Python
fake_register
fake_register
43
48
43
43
b92837861a4a6b7fad7ff59a63c71307ee45ad1a
bigcode/the-stack
train
672a8b5362b9a1913107606c
train
class
class KoubeiMarketingCampaignItemMerchantactivityModifyRequest(object): def __init__(self, biz_model=None): self._biz_model = biz_model self._biz_content = None self._version = "1.0" self._terminal_type = None self._terminal_info = None self._prod_code = None ...
class KoubeiMarketingCampaignItemMerchantactivityModifyRequest(object):
def __init__(self, biz_model=None): self._biz_model = biz_model self._biz_content = None self._version = "1.0" self._terminal_type = None self._terminal_info = None self._prod_code = None self._notify_url = None self._return_url = None self._ud...
#!/usr/bin/env python # -*- coding: utf-8 -*- import json from alipay.aop.api.FileItem import FileItem from alipay.aop.api.constant.ParamConstants import * from alipay.aop.api.domain.KoubeiMarketingCampaignItemMerchantactivityModifyModel import KoubeiMarketingCampaignItemMerchantactivityModifyModel class KoubeiMarket...
80
255
851
12
67
snowxmas/alipay-sdk-python-all
alipay/aop/api/request/KoubeiMarketingCampaignItemMerchantactivityModifyRequest.py
Python
KoubeiMarketingCampaignItemMerchantactivityModifyRequest
KoubeiMarketingCampaignItemMerchantactivityModifyRequest
12
144
12
13
d43177f1dded56ca909b1c7c85dcef1a963934a9
bigcode/the-stack
train
e15d9e07ffd3a0de225ef61a
train
class
class ZeroRobotFactory(JSConfigBase): def __init__(self): self.__jslocation__ = "j.servers.zrobot" JSConfigBase.__init__(self, ZeroRobotServer)
class ZeroRobotFactory(JSConfigBase):
def __init__(self): self.__jslocation__ = "j.servers.zrobot" JSConfigBase.__init__(self, ZeroRobotServer)
from js9 import j from .ZeroRobotServer import ZeroRobotServer JSConfigBase = j.tools.configmanager.base_class_configs class ZeroRobotFactory(JSConfigBase):
36
64
42
8
27
PeterNashaat/0-robot
JumpScale9Zrobot/servers/zerorobot/ZeroRobotFactory.py
Python
ZeroRobotFactory
ZeroRobotFactory
8
12
8
9
4593d273f5427913deffdfae028ae48e6d737d06
bigcode/the-stack
train
e64038a76670ab66d4959619
train
function
def edit_pipeline(full_dataset_path, laz_path, tif_path, output_epsg, bound, polygon_input): fetch_json = open_json("./pipeline.json") fetch_json['pipeline'][0]['filename'] = full_dataset_path fetch_json['pipeline'][0]['bounds'] = bound fetch_json['pipeline'][1]['polygon'] = polygon_input fetch_json...
def edit_pipeline(full_dataset_path, laz_path, tif_path, output_epsg, bound, polygon_input):
fetch_json = open_json("./pipeline.json") fetch_json['pipeline'][0]['filename'] = full_dataset_path fetch_json['pipeline'][0]['bounds'] = bound fetch_json['pipeline'][1]['polygon'] = polygon_input fetch_json['pipeline'][3]['out_srs'] = f'EPSG:{output_epsg}' fetch_json['pipeline'][4]['filename'] ...
import json def open_json(path): with open(path, 'r')as json_file: dict_ob = json.load(json_file) return dict_ob def edit_pipeline(full_dataset_path, laz_path, tif_path, output_epsg, bound, polygon_input):
56
64
137
22
33
Bethelsis/AgriTech-USGS-LIDAR-Challenge
scripts/edit_pipeline.py
Python
edit_pipeline
edit_pipeline
8
18
8
8
642efbc4ae6611ddf2cd8e45a49144b900c01568
bigcode/the-stack
train
f6d7ef29acda709b13ded2c1
train
function
def open_json(path): with open(path, 'r')as json_file: dict_ob = json.load(json_file) return dict_ob
def open_json(path):
with open(path, 'r')as json_file: dict_ob = json.load(json_file) return dict_ob
import json def open_json(path):
8
64
31
5
2
Bethelsis/AgriTech-USGS-LIDAR-Challenge
scripts/edit_pipeline.py
Python
open_json
open_json
3
6
3
3
a10112c653964921fcf5c5c89cdeb808e98189bb
bigcode/the-stack
train
906ed902324ba134fcb362af
train
function
def test_dynamic_sidecar_env_vars(monkeypatch: MonkeyPatch) -> None: for key, value in MOCKED_BASE_REGISTRY_ENV_VARS.items(): monkeypatch.setenv(key, value) registry_settings = RegistrySettings() dynamic_sidecar_env_vars = get_dynamic_sidecar_env_vars(registry_settings) print("dynamic_sidecar_...
def test_dynamic_sidecar_env_vars(monkeypatch: MonkeyPatch) -> None:
for key, value in MOCKED_BASE_REGISTRY_ENV_VARS.items(): monkeypatch.setenv(key, value) registry_settings = RegistrySettings() dynamic_sidecar_env_vars = get_dynamic_sidecar_env_vars(registry_settings) print("dynamic_sidecar_env_vars:", dynamic_sidecar_env_vars) assert len(dynamic_sidecar...
_USER": "usr", "REGISTRY_PW": MOCKED_PASSWORD, "REGISTRY_SSL": "False", } EXPECTED_DYNAMIC_SIDECAR_ENV_VAR_NAMES = { "REGISTRY_AUTH", "REGISTRY_PATH", "REGISTRY_URL", "REGISTRY_USER", "REGISTRY_PW", "REGISTRY_SSL", } def test_dynamic_sidecar_env_vars(monkeypatch: MonkeyPatch) -> None:
92
92
307
17
75
colinRawlings/osparc-simcore
services/director-v2/tests/unit/test_utils_registry.py
Python
test_dynamic_sidecar_env_vars
test_dynamic_sidecar_env_vars
26
58
26
26
d54cad9f6ea15bbff36abe9889a32a97515c3bc5
bigcode/the-stack
train
9f346370a32a905b62dacf3f
train
class
class clean_versions(AppCommand): """Delete old version directories. Warning: This command will result in the destruction of the following files: 1) Table data for previous versions of the app. """ async def run(self) -> None: """Execute command.""" self.remove_old...
class clean_versions(AppCommand):
"""Delete old version directories. Warning: This command will result in the destruction of the following files: 1) Table data for previous versions of the app. """ async def run(self) -> None: """Execute command.""" self.remove_old_versiondirs() def remove_old...
"""Program ``faust reset`` used to delete local table state.""" from shutil import rmtree from .base import AppCommand __all__ = ['clean_versions'] class clean_versions(AppCommand):
41
64
119
6
35
spencerpomme/Public-Transit-Status-with-Apache-Kafka
consumers/venv/lib/python3.7/site-packages/faust/cli/clean_versions.py
Python
clean_versions
clean_versions
8
25
8
8
cf9c1eb8e8f128942889db4afb0ad149a7229e3e
bigcode/the-stack
train
891606af602f3c400845a078
train
class
class read_writeTest(unittest.TestCase): filename = os.path.join( os.path.dirname(os.path.abspath(__file__)), "test_file.nc" ) broken_bounds = os.path.join( os.path.dirname(os.path.abspath(__file__)), "broken_bounds.cdl" ) string_filename = os.path.join( os.path.dirname(os....
class read_writeTest(unittest.TestCase):
filename = os.path.join( os.path.dirname(os.path.abspath(__file__)), "test_file.nc" ) broken_bounds = os.path.join( os.path.dirname(os.path.abspath(__file__)), "broken_bounds.cdl" ) string_filename = os.path.join( os.path.dirname(os.path.abspath(__file__)), "string_char.nc"...
import atexit import datetime import faulthandler import inspect import os import shutil import subprocess import tempfile import unittest import numpy faulthandler.enable() # to debug seg faults and timeouts import cf n_tmpfiles = 8 tmpfiles = [ tempfile.mkstemp("_test_read_write.nc", dir=os.getcwd())[1] ...
197
256
7,239
8
189
sadielbartholomew/cf-python
cf/test/test_read_write.py
Python
read_writeTest
read_writeTest
46
880
46
46
dd9b7bf0883c947cc34c7fc645af07eb94869e59
bigcode/the-stack
train
48b0359be12c2be18730f21e
train
function
def _remove_tmpfiles(): """Try to remove defined temporary files by deleting their paths.""" for f in tmpfiles: try: os.remove(f) except OSError: pass
def _remove_tmpfiles():
"""Try to remove defined temporary files by deleting their paths.""" for f in tmpfiles: try: os.remove(f) except OSError: pass
] for i in range(n_tmpfiles) ] ( tmpfile, tmpfileh, tmpfileh2, tmpfilec, tmpfilec2, tmpfile0, tmpfile1, tmpfile2, ) = tmpfiles def _remove_tmpfiles():
64
64
42
6
57
sadielbartholomew/cf-python
cf/test/test_read_write.py
Python
_remove_tmpfiles
_remove_tmpfiles
34
40
34
34
210576a2a02df2443b5751ef1c2d02f113b24e19
bigcode/the-stack
train
88d5845dfe7641ca5c8c189d
train
class
class Cert_9_2_19_PendingDatasetGet(thread_cert.TestCase): SUPPORT_NCP = False TOPOLOGY = { COMMISSIONER: { 'name': 'COMMISSIONER', 'mode': 'rdn', 'allowlist': [LEADER] }, LEADER: { 'name': 'LEADER', 'mode': 'rdn', ...
class Cert_9_2_19_PendingDatasetGet(thread_cert.TestCase):
SUPPORT_NCP = False TOPOLOGY = { COMMISSIONER: { 'name': 'COMMISSIONER', 'mode': 'rdn', 'allowlist': [LEADER] }, LEADER: { 'name': 'LEADER', 'mode': 'rdn', 'allowlist': [COMMISSIONER] }, } def test(...
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # import unittest import config import mesh_cop import thread_cert from pktverify.consts import MGMT_PENDING_GET_URI, MGMT_PENDING_SET_URI, NM_CHANNEL_TLV, NM_PAN_ID_TLV, NM_NETWORK_NAME_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_PSKC_TLV, NM...
256
256
2,201
17
238
sarah-iot/openthread
tests/scripts/thread-cert/Cert_9_2_19_PendingDatasetGet.py
Python
Cert_9_2_19_PendingDatasetGet
Cert_9_2_19_PendingDatasetGet
59
289
59
59
eaf1fd414d21478dde6e31edd5ff9a489b211f51
bigcode/the-stack
train
203cdfc09a85c2a956e5ec19
train
function
def smart_divide(func): def inner(a, b): print("I am going to divide", a, "and", b) if b == 0: print("Whoops! cannot divide") return return func(a, b) return inner
def smart_divide(func):
def inner(a, b): print("I am going to divide", a, "and", b) if b == 0: print("Whoops! cannot divide") return return func(a, b) return inner
decorator's arg func..!!****") # print(num + 1) # my_decorator(test_in) @my_decorator # this is exactly similar to: my_decorator(test_in) def test_in(): print("***I m decorator's arg func..!!****") def smart_divide(func):
64
64
59
6
58
PranaliRPatil/Python_OOP_Basics
decorators_test.py
Python
smart_divide
smart_divide
17
25
17
17
4584ce0226f3227d821ba5f5941b10ea282b3488
bigcode/the-stack
train
a9011d59fc6f85e06b4af0e4
train
function
def my_decorator(func): print("Inside decorator") func() print("End decorator\n*******###*********")
def my_decorator(func):
print("Inside decorator") func() print("End decorator\n*******###*********")
#https://www.programiz.com/python-programming/decorator #https://realpython.com/primer-on-python-decorators/ def my_decorator(func):
33
64
26
6
27
PranaliRPatil/Python_OOP_Basics
decorators_test.py
Python
my_decorator
my_decorator
3
6
3
3
c74833b8703fbbb5a38a20d7bf7b8c544f8b86df
bigcode/the-stack
train
988999e8887e0129f9aeda8e
train
function
@my_decorator # this is exactly similar to: my_decorator(test_in) def test_in(): print("***I m decorator's arg func..!!****")
@my_decorator # this is exactly similar to: my_decorator(test_in) def test_in():
print("***I m decorator's arg func..!!****")
print("End decorator\n*******###*********") def test_in(): print("***I m decorator's arg func..!!****") # print(num + 1) # my_decorator(test_in) @my_decorator # this is exactly similar to: my_decorator(test_in) def test_in():
64
64
35
22
42
PranaliRPatil/Python_OOP_Basics
decorators_test.py
Python
test_in
test_in
13
15
13
14
cf834679d00d7475b32019af94d3d809caa84296
bigcode/the-stack
train
bd28bac8f37b1fc1ceceaab5
train
function
@smart_divide def divide(a, b): print(a/b)
@smart_divide def divide(a, b):
print(a/b)
def inner(a, b): print("I am going to divide", a, "and", b) if b == 0: print("Whoops! cannot divide") return return func(a, b) return inner @smart_divide def divide(a, b):
64
64
16
11
52
PranaliRPatil/Python_OOP_Basics
decorators_test.py
Python
divide
divide
27
29
27
28
4b06f8312c9a22bfc7446f3a3b3d8b38774022a8
bigcode/the-stack
train
85df27105305de8deead856d
train
function
def test_in(): print("***I m decorator's arg func..!!****")
def test_in():
print("***I m decorator's arg func..!!****")
#https://www.programiz.com/python-programming/decorator #https://realpython.com/primer-on-python-decorators/ def my_decorator(func): print("Inside decorator") func() print("End decorator\n*******###*********") def test_in():
57
64
17
4
53
PranaliRPatil/Python_OOP_Basics
decorators_test.py
Python
test_in
test_in
8
9
8
8
ebb7f168ef587e1fbc6d7e49e4ce6a96f53ba193
bigcode/the-stack
train
92db5ecf77e50fd36452954c
train
class
class CustomObjectReference(Reference): "Corresponding marshmallow schema is :class:`commercetools.schemas.CustomObjectReferenceSchema`." #: Optional :class:`commercetools.types.CustomObject` obj: typing.Optional["CustomObject"] def __init__( self, *, type_id: typing.Optional["R...
class CustomObjectReference(Reference):
"Corresponding marshmallow schema is :class:`commercetools.schemas.CustomObjectReferenceSchema`." #: Optional :class:`commercetools.types.CustomObject` obj: typing.Optional["CustomObject"] def __init__( self, *, type_id: typing.Optional["ReferenceTypeId"] = None, id: typ...
super().__init__() def __repr__(self) -> str: return ( "CustomObjectPagedQueryResponse(count=%r, total=%r, offset=%r, results=%r)" % (self.count, self.total, self.offset, self.results) ) class CustomObjectReference(Reference):
64
64
173
7
57
mbarga/commercetools-python-sdk
src/commercetools/types/_custom_object.py
Python
CustomObjectReference
CustomObjectReference
128
148
128
128
813d14344e928eb8510aacfd40770791f03d33bc
bigcode/the-stack
train
38de8e39e987e4963b446536
train
class
class CustomObjectPagedQueryResponse(_BaseType): "Corresponding marshmallow schema is :class:`commercetools.schemas.CustomObjectPagedQueryResponseSchema`." #: :class:`int` count: typing.Optional[int] #: Optional :class:`int` total: typing.Optional[int] #: :class:`int` offset: typing.Optional...
class CustomObjectPagedQueryResponse(_BaseType):
"Corresponding marshmallow schema is :class:`commercetools.schemas.CustomObjectPagedQueryResponseSchema`." #: :class:`int` count: typing.Optional[int] #: Optional :class:`int` total: typing.Optional[int] #: :class:`int` offset: typing.Optional[int] #: List of :class:`commercetools.types....
self.version = version super().__init__() def __repr__(self) -> str: return "CustomObjectDraft(container=%r, key=%r, value=%r, version=%r)" % ( self.container, self.key, self.value, self.version, ) class CustomObjectPagedQueryResponse...
74
74
247
10
64
mbarga/commercetools-python-sdk
src/commercetools/types/_custom_object.py
Python
CustomObjectPagedQueryResponse
CustomObjectPagedQueryResponse
96
125
96
96
dc335f00b3a13aa9078cc2e66f33a947cd40615f
bigcode/the-stack
train
2fd2bc707b5f305238274e8d
train
class
class CustomObject(BaseResource): "Corresponding marshmallow schema is :class:`commercetools.schemas.CustomObjectSchema`." #: :class:`str` container: typing.Optional[str] #: :class:`str` key: typing.Optional[str] #: :class:`typing.Any` value: typing.Optional[typing.Any] def __init__( ...
class CustomObject(BaseResource):
"Corresponding marshmallow schema is :class:`commercetools.schemas.CustomObjectSchema`." #: :class:`str` container: typing.Optional[str] #: :class:`str` key: typing.Optional[str] #: :class:`typing.Any` value: typing.Optional[typing.Any] def __init__( self, *, id:...
# DO NOT EDIT! This file is automatically generated import datetime import typing from commercetools.types._abstract import _BaseType from commercetools.types._common import BaseResource, Reference, ReferenceTypeId __all__ = [ "CustomObject", "CustomObjectDraft", "CustomObjectPagedQueryResponse", "Cu...
83
90
302
6
77
mbarga/commercetools-python-sdk
src/commercetools/types/_custom_object.py
Python
CustomObject
CustomObject
17
59
17
17
aed84af0826e5cece6e1ed81243e6ff42dc91c45
bigcode/the-stack
train
6237f3f1baa62866a70c392c
train
class
class CustomObjectDraft(_BaseType): "Corresponding marshmallow schema is :class:`commercetools.schemas.CustomObjectDraftSchema`." #: :class:`str` container: typing.Optional[str] #: :class:`str` key: typing.Optional[str] #: :class:`typing.Any` value: typing.Optional[typing.Any] #: Optiona...
class CustomObjectDraft(_BaseType):
"Corresponding marshmallow schema is :class:`commercetools.schemas.CustomObjectDraftSchema`." #: :class:`str` container: typing.Optional[str] #: :class:`str` key: typing.Optional[str] #: :class:`typing.Any` value: typing.Optional[typing.Any] #: Optional :class:`int` version: typing.O...
_at=%r, last_modified_at=%r, container=%r, key=%r, value=%r)" % ( self.id, self.version, self.created_at, self.last_modified_at, self.container, self.key, self.value, ) ) class...
68
68
228
8
60
mbarga/commercetools-python-sdk
src/commercetools/types/_custom_object.py
Python
CustomObjectDraft
CustomObjectDraft
62
93
62
62
5518241639ba5d7934bf67a93a570e2238138aed
bigcode/the-stack
train
713c277a58726b0028b71be0
train
class
class MathguideConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'mathguide'
class MathguideConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField' name = 'mathguide'
from django.apps import AppConfig class MathguideConfig(AppConfig):
14
64
27
7
6
LHY-42/matholympiadguide
mathguide/apps.py
Python
MathguideConfig
MathguideConfig
4
6
4
4
e570e7403525b68f466cf955d2ecd7b25e128f57
bigcode/the-stack
train
abcc56f695aa2c9784e172c4
train
function
def requires_backends(obj, backends): if not isinstance(backends, (list, tuple)): backends = [backends] name = obj.__name__ if hasattr(obj, "__name__") else obj.__class__.__name__ if not all(BACKENDS_MAPPING[backend][0]() for backend in backends): raise ImportError("".join([BACKENDS_MAPPING...
def requires_backends(obj, backends):
if not isinstance(backends, (list, tuple)): backends = [backends] name = obj.__name__ if hasattr(obj, "__name__") else obj.__class__.__name__ if not all(BACKENDS_MAPPING[backend][0]() for backend in backends): raise ImportError("".join([BACKENDS_MAPPING[backend][1].format(name) for backend ...
ERS_IMPORT_ERROR)), ("torch", (is_torch_available, PYTORCH_IMPORT_ERROR)), ("vision", (is_vision_available, VISION_IMPORT_ERROR)), ("scipy", (is_scipy_available, SCIPY_IMPORT_ERROR)), ] ) def requires_backends(obj, backends):
64
64
95
9
55
MichalPitr/transformers
src/transformers/file_utils.py
Python
requires_backends
requires_backends
606
612
606
606
88d69d1aa3b100daffa968f95914fc5d9933c3ac
bigcode/the-stack
train
c0dc29117101bd5011b8ce72
train
function
def is_py3nvml_available(): return importlib.util.find_spec("py3nvml") is not None
def is_py3nvml_available():
return importlib.util.find_spec("py3nvml") is not None
return False return importlib.util.find_spec("torch_xla.core.xla_model") is not None def is_datasets_available(): return _datasets_available def is_psutil_available(): return importlib.util.find_spec("psutil") is not None def is_py3nvml_available():
64
64
25
8
55
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_py3nvml_available
is_py3nvml_available
322
323
322
322
733e4e4957712a033378e6e79e3a4753555fd362
bigcode/the-stack
train
95553f892e5f558acb030445
train
function
def is_vision_available(): return importlib.util.find_spec("PIL") is not None
def is_vision_available():
return importlib.util.find_spec("PIL") is not None
is_protobuf_available(): if importlib.util.find_spec("google") is None: return False return importlib.util.find_spec("google.protobuf") is not None def is_tokenizers_available(): return importlib.util.find_spec("tokenizers") is not None def is_vision_available():
64
64
21
6
57
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_vision_available
is_vision_available
358
359
358
358
0a480f980adf3eed65c4fa7d63937c44b12383ec
bigcode/the-stack
train
354221589fb308c21d68e553
train
function
def is_pandas_available(): return importlib.util.find_spec("pandas") is not None
def is_pandas_available():
return importlib.util.find_spec("pandas") is not None
ODE_PID" in os.environ: raise ImportError("vscode") return importlib.util.find_spec("IPython") is not None except (AttributeError, ImportError, KeyError): return False def is_scatter_available(): return _scatter_available def is_pandas_available():
64
64
21
6
57
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_pandas_available
is_pandas_available
380
381
380
380
9a4b7708f8a9a86d73b803805fbbd3df3624fd85
bigcode/the-stack
train
7131ea6b7951f9c68abed206
train
function
def is_remote_url(url_or_filename): parsed = urlparse(url_or_filename) return parsed.scheme in ("http", "https")
def is_remote_url(url_or_filename):
parsed = urlparse(url_or_filename) return parsed.scheme in ("http", "https")
f"The function {fn} should have an empty 'Return:' or 'Returns:' in its docstring as placeholder, current docstring is:\n{docstrings}" ) fn.__doc__ = docstrings return fn return docstring_decorator def is_remote_url(url_or_filename):
64
64
28
8
55
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_remote_url
is_remote_url
1,162
1,164
1,162
1,162
f3d38666696ad6c7d2f2f7ee2862f92d0868be91
bigcode/the-stack
train
1909346ac296c20976e0627c
train
function
def is_offline_mode(): return _is_offline_mode
def is_offline_mode():
return _is_offline_mode
This is the version of torch required to run torch.fx features. TORCH_FX_REQUIRED_VERSION = version.parse("1.8") _is_offline_mode = True if os.environ.get("TRANSFORMERS_OFFLINE", "0").upper() in ENV_VARS_TRUE_VALUES else False def is_offline_mode():
64
64
14
6
57
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_offline_mode
is_offline_mode
261
262
261
261
ccae0a114ab4dd2827891bc2eb5fca9d5eac4877
bigcode/the-stack
train
4a6cfa1e4d02cef39d51bc09
train
function
def is_scipy_available(): return importlib.util.find_spec("scipy") is not None
def is_scipy_available():
return importlib.util.find_spec("scipy") is not None
3nvml_available(): return importlib.util.find_spec("py3nvml") is not None def is_apex_available(): return importlib.util.find_spec("apex") is not None def is_faiss_available(): return _faiss_available def is_scipy_available():
64
64
22
7
56
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_scipy_available
is_scipy_available
334
335
334
334
1678d3a35d7f95019f92512779ed6f806d996ff7
bigcode/the-stack
train
031286ad73bff9f7b09cc568
train
class
class PaddingStrategy(ExplicitEnum): """ Possible values for the ``padding`` argument in :meth:`PreTrainedTokenizerBase.__call__`. Useful for tab-completion in an IDE. """ LONGEST = "longest" MAX_LENGTH = "max_length" DO_NOT_PAD = "do_not_pad"
class PaddingStrategy(ExplicitEnum):
""" Possible values for the ``padding`` argument in :meth:`PreTrainedTokenizerBase.__call__`. Useful for tab-completion in an IDE. """ LONGEST = "longest" MAX_LENGTH = "max_length" DO_NOT_PAD = "do_not_pad"
for missing values. """ @classmethod def _missing_(cls, value): raise ValueError( f"{value} is not a valid {cls.__name__}, please select one of {list(cls._value2member_map_.keys())}" ) class PaddingStrategy(ExplicitEnum):
64
64
70
7
57
MichalPitr/transformers
src/transformers/file_utils.py
Python
PaddingStrategy
PaddingStrategy
1,841
1,849
1,841
1,841
0571de3418fbc68866dfa7038d5f664080d7b80c
bigcode/the-stack
train
77fdd81937ee922d78bd1fe9
train
function
def torch_only_method(fn): def wrapper(*args, **kwargs): if not _torch_available: raise ImportError( "You need to install pytorch to use this method or class, " "or activate it with environment variables USE_TORCH=1 and USE_TF=0." ) else: ...
def torch_only_method(fn):
def wrapper(*args, **kwargs): if not _torch_available: raise ImportError( "You need to install pytorch to use this method or class, " "or activate it with environment variables USE_TORCH=1 and USE_TF=0." ) else: return fn(*args, **k...
(): return _timm_available def is_torchaudio_available(): return _torchaudio_available def is_speech_available(): # For now this depends on torchaudio but the exact dependency might evolve in the future. return _torchaudio_available def torch_only_method(fn):
64
64
82
6
57
MichalPitr/transformers
src/transformers/file_utils.py
Python
torch_only_method
torch_only_method
443
453
443
443
580dab927089513f2cea7476bd29b1c570244d39
bigcode/the-stack
train
50905e2d449fbff3c27dce72
train
class
class TensorType(ExplicitEnum): """ Possible values for the ``return_tensors`` argument in :meth:`PreTrainedTokenizerBase.__call__`. Useful for tab-completion in an IDE. """ PYTORCH = "pt" TENSORFLOW = "tf" NUMPY = "np" JAX = "jax"
class TensorType(ExplicitEnum):
""" Possible values for the ``return_tensors`` argument in :meth:`PreTrainedTokenizerBase.__call__`. Useful for tab-completion in an IDE. """ PYTORCH = "pt" TENSORFLOW = "tf" NUMPY = "np" JAX = "jax"
the ``padding`` argument in :meth:`PreTrainedTokenizerBase.__call__`. Useful for tab-completion in an IDE. """ LONGEST = "longest" MAX_LENGTH = "max_length" DO_NOT_PAD = "do_not_pad" class TensorType(ExplicitEnum):
64
64
76
7
57
MichalPitr/transformers
src/transformers/file_utils.py
Python
TensorType
TensorType
1,852
1,861
1,852
1,852
440fd0142ee6e97a41834a048921f5792191e8b5
bigcode/the-stack
train
ccebc3ba9765725823169245
train
function
def is_torch_cuda_available(): if is_torch_available(): import torch return torch.cuda.is_available() else: return False
def is_torch_cuda_available():
if is_torch_available(): import torch return torch.cuda.is_available() else: return False
_is_offline_mode = True if os.environ.get("TRANSFORMERS_OFFLINE", "0").upper() in ENV_VARS_TRUE_VALUES else False def is_offline_mode(): return _is_offline_mode def is_torch_available(): return _torch_available def is_torch_cuda_available():
64
64
32
7
56
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_torch_cuda_available
is_torch_cuda_available
269
275
269
269
8d8d803792bd336bd8570b4b79c7544ac5c4231d
bigcode/the-stack
train
17b33f290e3402b90f4f8cc0
train
function
def add_start_docstrings_to_model_forward(*docstr): def docstring_decorator(fn): class_name = f":class:`~transformers.{fn.__qualname__.split('.')[0]}`" intro = f" The {class_name} forward method, overrides the :func:`__call__` special method." note = r""" .. note:: Although th...
def add_start_docstrings_to_model_forward(*docstr):
def docstring_decorator(fn): class_name = f":class:`~transformers.{fn.__qualname__.split('.')[0]}`" intro = f" The {class_name} forward method, overrides the :func:`__call__` special method." note = r""" .. note:: Although the recipe for forward pass needs to be defined within...
_docstrings(*docstr): def docstring_decorator(fn): fn.__doc__ = "".join(docstr) + (fn.__doc__ if fn.__doc__ is not None else "") return fn return docstring_decorator def add_start_docstrings_to_model_forward(*docstr):
64
64
175
12
51
MichalPitr/transformers
src/transformers/file_utils.py
Python
add_start_docstrings_to_model_forward
add_start_docstrings_to_model_forward
623
637
623
623
37029ffbb65332e71ad3d6f67df1f56ff56306cd
bigcode/the-stack
train
130bf754440381a3e00a1778
train
function
def is_training_run_on_sagemaker(): return "SAGEMAKER_JOB_NAME" in os.environ
def is_training_run_on_sagemaker():
return "SAGEMAKER_JOB_NAME" in os.environ
_mpi_enabled", False): return False except json.JSONDecodeError: return False # Lastly, check if the `smdistributed` module is present. return importlib.util.find_spec("smdistributed") is not None def is_training_run_on_sagemaker():
64
64
22
9
54
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_training_run_on_sagemaker
is_training_run_on_sagemaker
422
423
422
422
8746f77794007988a9cda868d1ecd680d29ef352
bigcode/the-stack
train
3d674ed696f538aece200322
train
function
def is_local_clone(repo_path, repo_url): """ Checks if the folder in `repo_path` is a local clone of `repo_url`. """ # First double-check that `repo_path` is a git repo if not os.path.exists(os.path.join(repo_path, ".git")): return False test_git = subprocess.run("git branch".split(), cw...
def is_local_clone(repo_path, repo_url):
""" Checks if the folder in `repo_path` is a local clone of `repo_url`. """ # First double-check that `repo_path` is a git repo if not os.path.exists(os.path.join(repo_path, ".git")): return False test_git = subprocess.run("git branch".split(), cwd=repo_path) if test_git.returncode !...
= types.FunctionType(f.__code__, f.__globals__, name=f.__name__, argdefs=f.__defaults__, closure=f.__closure__) g = functools.update_wrapper(g, f) g.__kwdefaults__ = f.__kwdefaults__ return g def is_local_clone(repo_path, repo_url):
64
64
164
10
53
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_local_clone
is_local_clone
1,910
1,931
1,910
1,910
8210980e76df9c226f0dbb374c8d33a35e107088
bigcode/the-stack
train
e169eaab5624d010e0b2f5f8
train
function
def url_to_filename(url: str, etag: Optional[str] = None) -> str: """ Convert `url` into a hashed filename in a repeatable way. If `etag` is specified, append its hash to the url's, delimited by a period. If the url ends with .h5 (Keras HDF5 weights) adds '.h5' to the name so that TF 2.0 can identify it...
def url_to_filename(url: str, etag: Optional[str] = None) -> str:
""" Convert `url` into a hashed filename in a repeatable way. If `etag` is specified, append its hash to the url's, delimited by a period. If the url ends with .h5 (Keras HDF5 weights) adds '.h5' to the name so that TF 2.0 can identify it as a HDF5 file (see https://github.com/tensorflow/tensorflow/...
else: return f"{endpoint}/{model_id}/{filename}" if revision is None: revision = "main" return HUGGINGFACE_CO_PREFIX.format(model_id=model_id, revision=revision, filename=filename) def url_to_filename(url: str, etag: Optional[str] = None) -> str:
68
68
228
20
48
MichalPitr/transformers
src/transformers/file_utils.py
Python
url_to_filename
url_to_filename
1,202
1,219
1,202
1,202
7131a09d9632574cb72a52f510651ba31d0de858
bigcode/the-stack
train
3aebf2f4d53d8a4c7a995a03
train
function
def hf_bucket_url( model_id: str, filename: str, subfolder: Optional[str] = None, revision: Optional[str] = None, mirror=None ) -> str: """ Resolve a model identifier, a file name, and an optional revision id, to a huggingface.co-hosted url, redirecting to Cloudfront (a Content Delivery Network, or CDN)...
def hf_bucket_url( model_id: str, filename: str, subfolder: Optional[str] = None, revision: Optional[str] = None, mirror=None ) -> str:
""" Resolve a model identifier, a file name, and an optional revision id, to a huggingface.co-hosted url, redirecting to Cloudfront (a Content Delivery Network, or CDN) for large files. Cloudfront is replicated over the globe so downloads are way faster for the end user (and it also lowers our band...
fn} should have an empty 'Return:' or 'Returns:' in its docstring as placeholder, current docstring is:\n{docstrings}" ) fn.__doc__ = docstrings return fn return docstring_decorator def is_remote_url(url_or_filename): parsed = urlparse(url_or_filename) return parsed.scheme in ...
119
119
398
39
80
MichalPitr/transformers
src/transformers/file_utils.py
Python
hf_bucket_url
hf_bucket_url
1,167
1,199
1,167
1,169
827271e1c7ae4159b8c569e5e2d2998c8312ec8e
bigcode/the-stack
train
f53baf9aef8e89059fbb37cf
train
function
def replace_return_docstrings(output_type=None, config_class=None): def docstring_decorator(fn): docstrings = fn.__doc__ lines = docstrings.split("\n") i = 0 while i < len(lines) and re.search(r"^\s*Returns?:\s*$", lines[i]) is None: i += 1 if i < len(lines): ...
def replace_return_docstrings(output_type=None, config_class=None):
def docstring_decorator(fn): docstrings = fn.__doc__ lines = docstrings.split("\n") i = 0 while i < len(lines) and re.search(r"^\s*Returns?:\s*$", lines[i]) is None: i += 1 if i < len(lines): lines[i] = _prepare_output_docstrings(output_type, config_cl...
None else "" built_doc = code_sample.format(**doc_kwargs) fn.__doc__ = (fn.__doc__ or "") + "".join(docstr) + output_doc + built_doc return fn return docstring_decorator def replace_return_docstrings(output_type=None, config_class=None):
64
64
175
13
50
MichalPitr/transformers
src/transformers/file_utils.py
Python
replace_return_docstrings
replace_return_docstrings
1,142
1,159
1,142
1,142
c2b64c48cd5623797a030ba3c6ca5e3316d0a5c2
bigcode/the-stack
train
d85b2b0bde97505bfb67e440
train
function
def is_sentencepiece_available(): return importlib.util.find_spec("sentencepiece") is not None
def is_sentencepiece_available():
return importlib.util.find_spec("sentencepiece") is not None
return importlib.util.find_spec("scipy") is not None def is_sklearn_available(): if importlib.util.find_spec("sklearn") is None: return False return is_scipy_available() and importlib.util.find_spec("sklearn.metrics") def is_sentencepiece_available():
64
64
21
6
58
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_sentencepiece_available
is_sentencepiece_available
344
345
344
344
39d75ce2c2893fa209351b0e474035f05b935977
bigcode/the-stack
train
d9ad2c822d02b1309cf3ce3c
train
function
def is_tf_available(): return _tf_available
def is_tf_available():
return _tf_available
lib_metadata.version("torch")) _torch_fx_available = (torch_version.major, torch_version.minor) == ( TORCH_FX_REQUIRED_VERSION.major, TORCH_FX_REQUIRED_VERSION.minor, ) def is_torch_fx_available(): return _torch_fx_available def is_tf_available():
64
64
11
5
58
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_tf_available
is_tf_available
291
292
291
291
b26f8e8e3187e91dfb6aebaf4b4bac49cb792332
bigcode/the-stack
train
2a1dcdae6c1462617be8d608
train
function
def is_faiss_available(): return _faiss_available
def is_faiss_available():
return _faiss_available
.util.find_spec("psutil") is not None def is_py3nvml_available(): return importlib.util.find_spec("py3nvml") is not None def is_apex_available(): return importlib.util.find_spec("apex") is not None def is_faiss_available():
64
64
14
7
56
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_faiss_available
is_faiss_available
330
331
330
330
39ac0eb3d413850a67aa53e601115725829b49b4
bigcode/the-stack
train
875d025d95a9b13baeeb634d
train
class
class PushToHubMixin: """ A Mixin containing the functionality to push a model or tokenizer to the hub. """ def push_to_hub( self, repo_path_or_name: Optional[str] = None, repo_url: Optional[str] = None, use_temp_dir: bool = False, commit_message: Optional[str] =...
class PushToHubMixin:
""" A Mixin containing the functionality to push a model or tokenizer to the hub. """ def push_to_hub( self, repo_path_or_name: Optional[str] = None, repo_url: Optional[str] = None, use_temp_dir: bool = False, commit_message: Optional[str] = None, organiz...
Returns a copy of a function f.""" # Based on http://stackoverflow.com/a/6528148/190597 (Glenn Maynard) g = types.FunctionType(f.__code__, f.__globals__, name=f.__name__, argdefs=f.__defaults__, closure=f.__closure__) g = functools.update_wrapper(g, f) g.__kwdefaults__ = f.__kwdefaults__ return g ...
256
256
1,710
6
250
MichalPitr/transformers
src/transformers/file_utils.py
Python
PushToHubMixin
PushToHubMixin
1,934
2,107
1,934
1,934
398445593a3cb822410223285f100309d7adcc0d
bigcode/the-stack
train
0e39dfd11810ab12692f1fac
train
function
def is_in_notebook(): try: # Test adapted from tqdm.autonotebook: https://github.com/tqdm/tqdm/blob/master/tqdm/autonotebook.py get_ipython = sys.modules["IPython"].get_ipython if "IPKernelApp" not in get_ipython().config: raise ImportError("console") if "VSCODE_PID" in o...
def is_in_notebook():
try: # Test adapted from tqdm.autonotebook: https://github.com/tqdm/tqdm/blob/master/tqdm/autonotebook.py get_ipython = sys.modules["IPython"].get_ipython if "IPKernelApp" not in get_ipython().config: raise ImportError("console") if "VSCODE_PID" in os.environ: ...
return importlib.util.find_spec("google.protobuf") is not None def is_tokenizers_available(): return importlib.util.find_spec("tokenizers") is not None def is_vision_available(): return importlib.util.find_spec("PIL") is not None def is_in_notebook():
64
64
129
6
57
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_in_notebook
is_in_notebook
362
373
362
362
8bffd1a5f7c87c343973803c1d57b3d47f4ea148
bigcode/the-stack
train
a98c4c378ff033d45806d1a4
train
function
def is_soundfile_availble(): return _soundfile_available
def is_soundfile_availble():
return _soundfile_available
# Lastly, check if the `smdistributed` module is present. return importlib.util.find_spec("smdistributed") is not None def is_training_run_on_sagemaker(): return "SAGEMAKER_JOB_NAME" in os.environ def is_soundfile_availble():
64
64
15
8
55
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_soundfile_availble
is_soundfile_availble
426
427
426
426
2a9269df79dadda8e9c1ff4622a5d361d3bf218b
bigcode/the-stack
train
5f58c1a6c56b5daf4fae0420
train
function
def http_user_agent(user_agent: Union[Dict, str, None] = None) -> str: """ Formats a user-agent string with basic info about a request. """ ua = f"transformers/{__version__}; python/{sys.version.split()[0]}; session_id/{SESSION_ID}" if is_torch_available(): ua += f"; torch/{_torch_version}" ...
def http_user_agent(user_agent: Union[Dict, str, None] = None) -> str:
""" Formats a user-agent string with basic info about a request. """ ua = f"transformers/{__version__}; python/{sys.version.split()[0]}; session_id/{SESSION_ID}" if is_torch_available(): ua += f"; torch/{_torch_version}" if is_tf_available(): ua += f"; tensorflow/{_tf_version}" ...
sm_distributed_training": runs_distributed_training, "sm_deep_learning_container": dlc_container_used, "sm_deep_learning_container_tag": dlc_tag, "sm_account_id": account_id, } return sagemaker_object def http_user_agent(user_agent: Union[Dict, str, None] = None) -> str:
75
75
250
21
53
MichalPitr/transformers
src/transformers/file_utils.py
Python
http_user_agent
http_user_agent
1,409
1,429
1,409
1,409
d54dd3a06aea76865f046203880dbd165e8c9749
bigcode/the-stack
train
eae3d4d3c5ff399270521e3c
train
function
def is_timm_available(): return _timm_available
def is_timm_available():
return _timm_available
module is present. return importlib.util.find_spec("smdistributed") is not None def is_training_run_on_sagemaker(): return "SAGEMAKER_JOB_NAME" in os.environ def is_soundfile_availble(): return _soundfile_available def is_timm_available():
64
64
13
6
57
MichalPitr/transformers
src/transformers/file_utils.py
Python
is_timm_available
is_timm_available
430
431
430
430
1fb8d68e94d097a99f1d5d85739ca687387508d8
bigcode/the-stack
train
ce4d74c9b6bad4164ad19fc4
train
function
def _get_indent(t): """Returns the indentation in the first line of t""" search = re.search(r"^(\s*)\S", t) return "" if search is None else search.groups()[0]
def _get_indent(t):
"""Returns the indentation in the first line of t""" search = re.search(r"^(\s*)\S", t) return "" if search is None else search.groups()[0]
full_output_type}` or a tuple of :obj:`tf.Tensor` (if ``return_dict=False`` is passed or when ``config.return_dict=False``) comprising various elements depending on the configuration (:class:`~transformers.{config_class}`) and inputs. """ def _get_indent(t):
64
64
47
6
58
MichalPitr/transformers
src/transformers/file_utils.py
Python
_get_indent
_get_indent
666
669
666
666
6dddb0600b5fad3f5a5d327c4be89fb717bc5b88
bigcode/the-stack
train
4616a685f4604b33500ff5cd
train
function
def define_sagemaker_information(): try: instance_data = requests.get(os.environ["ECS_CONTAINER_METADATA_URI"]).json() dlc_container_used = instance_data["Image"] dlc_tag = instance_data["Image"].split(":")[1] except Exception: dlc_container_used = None dlc_tag = None ...
def define_sagemaker_information():
try: instance_data = requests.get(os.environ["ECS_CONTAINER_METADATA_URI"]).json() dlc_container_used = instance_data["Image"] dlc_tag = instance_data["Image"].split(":")[1] except Exception: dlc_container_used = None dlc_tag = None sagemaker_params = json.loads(os.g...
tracted) zip_file.close() elif tarfile.is_tarfile(output_path): tar_file = tarfile.open(output_path) tar_file.extractall(output_path_extracted) tar_file.close() else: raise EnvironmentError(f"Archive format of {o...
82
82
274
7
74
MichalPitr/transformers
src/transformers/file_utils.py
Python
define_sagemaker_information
define_sagemaker_information
1,383
1,406
1,383
1,383
2f1bd4e925b907e024d25a05ac053067be394934
bigcode/the-stack
train
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
29