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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
da223876d36819d5ad9d9712 | train | function | def publish_messages(message_list, topic):
with topic.batch() as batch:
for message in message_list:
msg = message['message']
attrs = {}
if 'attributes' in message:
attrs = message['attributes']
batch.publish(bytes(msg), **attrs)
return Tru... | def publish_messages(message_list, topic):
| with topic.batch() as batch:
for message in message_list:
msg = message['message']
attrs = {}
if 'attributes' in message:
attrs = message['attributes']
batch.publish(bytes(msg), **attrs)
return True
| _utils.gcp import check_min_pkg_version, get_google_cloud_credentials
CLOUD_CLIENT = 'google-cloud-pubsub'
CLOUD_CLIENT_MINIMUM_VERSION = '0.22.0'
CLOUD_CLIENT_USER_AGENT = 'ansible-pubsub-0.1'
def publish_messages(message_list, topic):
| 64 | 64 | 62 | 8 | 56 | cjsteel/python3-venv-ansible-2.10.5 | lib/python3.8/site-packages/ansible_collections/community/general/plugins/modules/gcpubsub.py | Python | publish_messages | publish_messages | 212 | 220 | 212 | 212 | 91bb00c1f1c5fa77098973dae6f705abf0a49728 | bigcode/the-stack | train |
fe4dd908a6cd0d377c9e2b11 | train | function | def main():
module = AnsibleModule(
argument_spec=dict(
topic=dict(type='str', required=True),
state=dict(type='str', default='present', choices=['absent', 'present']),
publish=dict(type='list'),
subscription=dict(type='dict'),
service_account_ema... | def main():
| module = AnsibleModule(
argument_spec=dict(
topic=dict(type='str', required=True),
state=dict(type='str', default='present', choices=['absent', 'present']),
publish=dict(type='list'),
subscription=dict(type='dict'),
service_account_email=dict(type=... | with topic.batch() as batch:
for message in message_list:
msg = message['message']
attrs = {}
if 'attributes' in message:
attrs = message['attributes']
batch.publish(bytes(msg), **attrs)
return True
def pull_messages(pull_params, sub):
... | 245 | 245 | 817 | 3 | 242 | cjsteel/python3-venv-ansible-2.10.5 | lib/python3.8/site-packages/ansible_collections/community/general/plugins/modules/gcpubsub.py | Python | main | main | 250 | 345 | 250 | 251 | 97bf279335a9afd64cc946c17feb63e0256141d9 | bigcode/the-stack | train |
e684600e1ae8fe0b1da8d704 | train | function | def pull_messages(pull_params, sub):
"""
:rtype: tuple (output, changed)
"""
changed = False
max_messages = pull_params.get('max_messages', None)
message_ack = pull_params.get('message_ack', 'no')
return_immediately = pull_params.get('return_immediately', False)
output = []
pulled =... | def pull_messages(pull_params, sub):
| """
:rtype: tuple (output, changed)
"""
changed = False
max_messages = pull_params.get('max_messages', None)
message_ack = pull_params.get('message_ack', 'no')
return_immediately = pull_params.get('return_immediately', False)
output = []
pulled = sub.pull(return_immediately=return_i... | ):
with topic.batch() as batch:
for message in message_list:
msg = message['message']
attrs = {}
if 'attributes' in message:
attrs = message['attributes']
batch.publish(bytes(msg), **attrs)
return True
def pull_messages(pull_params, sub):
| 64 | 64 | 188 | 9 | 54 | cjsteel/python3-venv-ansible-2.10.5 | lib/python3.8/site-packages/ansible_collections/community/general/plugins/modules/gcpubsub.py | Python | pull_messages | pull_messages | 223 | 247 | 223 | 223 | 78e33431f775d11660198b17516f2ddd13d5ce30 | bigcode/the-stack | train |
cb35dcf392579484fc257a2b | train | function | def make_nodes_ip_map(dcos_api_session: DcosApiSession) -> dict:
"""
a helper function to make a map detected_ip -> external_ip
"""
node_private_public_ip_map = {}
for node in dcos_api_session.masters:
detected_ip = check_json(dcos_api_session.health.get('/', node=node))['ip']
node_p... | def make_nodes_ip_map(dcos_api_session: DcosApiSession) -> dict:
| """
a helper function to make a map detected_ip -> external_ip
"""
node_private_public_ip_map = {}
for node in dcos_api_session.masters:
detected_ip = check_json(dcos_api_session.health.get('/', node=node))['ip']
node_private_public_ip_map[detected_ip] = node
for node in dcos_ap... | .open(expected_gzipped_file)
return gzip.decompress(gzipped_state_output.read())
raise AssertionError("Not found {} nor {} in {}".format(unzipped_file, expected_gzipped_file, archived_items))
def make_nodes_ip_map(dcos_api_session: DcosApiSession) -> dict:
| 64 | 64 | 141 | 18 | 46 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | make_nodes_ip_map | make_nodes_ip_map | 589 | 602 | 589 | 589 | 22ab31959597db1e8c0b1dd4a28a3740ba304fb3 | bigcode/the-stack | train |
3adaa946d56c5a079f4bb3bc | train | function | @retrying.retry(wait_fixed=2000, stop_max_delay=LATENCY * 1000)
def test_dcos_diagnostics_units(dcos_api_session: DcosApiSession) -> None:
"""
test a list of collected units, endpoint /system/health/v1/units
"""
# get all unique unit names
all_units = set()
for node in dcos_api_session.masters:
... | @retrying.retry(wait_fixed=2000, stop_max_delay=LATENCY * 1000)
def test_dcos_diagnostics_units(dcos_api_session: DcosApiSession) -> None:
| """
test a list of collected units, endpoint /system/health/v1/units
"""
# get all unique unit names
all_units = set()
for node in dcos_api_session.masters:
node_response = check_json(dcos_api_session.health.get('/', node=node))
for unit in node_response['units']:
all... | _response['units'])) # type: ignore
for unit_id in unit_ids:
validate_unit(
check_json(dcos_api_session.health.get('/nodes/{}/units/{}'.format(node, unit_id), node=master)))
@retrying.retry(wait_fixed=2000, stop_max_delay=LATENCY * 1000)
def test_dcos_diagnostics_units(... | 89 | 90 | 301 | 41 | 48 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | test_dcos_diagnostics_units | test_dcos_diagnostics_units | 155 | 181 | 155 | 156 | b44b87a7927583a4de3feea40e591dafb3a38eb5 | bigcode/the-stack | train |
14aa1c2ab7414b1bb18a5b6b | train | function | def validate_node(nodes: list) -> None:
assert isinstance(nodes, list), 'input argument must be a list'
assert len(nodes) > 0, 'input argument cannot be empty'
required_fields = ['host_ip', 'health', 'role']
for node in nodes:
assert len(node) == len(required_fields), 'node should have the foll... | def validate_node(nodes: list) -> None:
| assert isinstance(nodes, list), 'input argument must be a list'
assert len(nodes) > 0, 'input argument cannot be empty'
required_fields = ['host_ip', 'health', 'role']
for node in nodes:
assert len(node) == len(required_fields), 'node should have the following fields: {}. Actual: {}'.format(
... |
for node in dcos_api_session.all_slaves:
detected_ip = check_json(dcos_api_session.health.get('/', node=node))['ip']
node_private_public_ip_map[detected_ip] = node
return node_private_public_ip_map
def validate_node(nodes: list) -> None:
| 64 | 64 | 187 | 10 | 53 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | validate_node | validate_node | 605 | 619 | 605 | 605 | b9a6d5b285bc21de04a0f9614962ceeda5504f8d | bigcode/the-stack | train |
17098a994e8612582615e7d3 | train | function | def test_dcos_diagnostics_nodes_node_units_unit(dcos_api_session: DcosApiSession) -> None:
"""
test a specific unit for a specific node, endpoint /system/health/v1/nodes/<node>/units/<unit>
"""
for master in dcos_api_session.masters:
response = check_json(dcos_api_session.health.get('/nodes', no... | def test_dcos_diagnostics_nodes_node_units_unit(dcos_api_session: DcosApiSession) -> None:
| """
test a specific unit for a specific node, endpoint /system/health/v1/nodes/<node>/units/<unit>
"""
for master in dcos_api_session.masters:
response = check_json(dcos_api_session.health.get('/nodes', node=master))
nodes = list(map(lambda node: node['host_ip'], response['nodes'])) # t... | len(units_response) == 1, 'unit response should have only 1 field `units`'
assert 'units' in units_response
validate_units(units_response['units'])
def test_dcos_diagnostics_nodes_node_units_unit(dcos_api_session: DcosApiSession) -> None:
| 63 | 64 | 198 | 23 | 40 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | test_dcos_diagnostics_nodes_node_units_unit | test_dcos_diagnostics_nodes_node_units_unit | 139 | 152 | 139 | 139 | 9ace9ee9ad95b2eec9a8e36d571a75c3603954fb | bigcode/the-stack | train |
ee0e036111e2499a2c635a21 | train | function | def test_dcos_diagnostics_nodes_node(dcos_api_session: DcosApiSession) -> None:
"""
test a specific node enpoint /system/health/v1/nodes/<node>
"""
for master in dcos_api_session.masters:
# get a list of nodes
response = check_json(dcos_api_session.health.get('/nodes', node=master))
... | def test_dcos_diagnostics_nodes_node(dcos_api_session: DcosApiSession) -> None:
| """
test a specific node enpoint /system/health/v1/nodes/<node>
"""
for master in dcos_api_session.masters:
# get a list of nodes
response = check_json(dcos_api_session.health.get('/nodes', node=master))
nodes = list(map(lambda node: node['host_ip'], response['nodes'])) # type: ... | ('a number of nodes in response must be {}'.
format(len(dcos_api_session.masters + dcos_api_session.all_slaves)))
# test nodes
validate_node(response['nodes'])
def test_dcos_diagnostics_nodes_node(dcos_api_session: DcosApiSession) -> None:
| 63 | 64 | 139 | 21 | 42 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | test_dcos_diagnostics_nodes_node | test_dcos_diagnostics_nodes_node | 108 | 119 | 108 | 108 | 0bee124d097001d57e19cadf00e2efe9922c19e1 | bigcode/the-stack | train |
860bc7c899e2e8cb9957a349 | train | function | def get_file_content(unzipped_file: str, z: zipfile.ZipFile) -> bytes:
archived_items = z.namelist()
if unzipped_file in archived_items:
return z.open(unzipped_file).read()
expected_gzipped_file = (unzipped_file + '.gz')
if expected_gzipped_file in archived_items:
gzipped_state_output = ... | def get_file_content(unzipped_file: str, z: zipfile.ZipFile) -> bytes:
| archived_items = z.namelist()
if unzipped_file in archived_items:
return z.open(unzipped_file).read()
expected_gzipped_file = (unzipped_file + '.gz')
if expected_gzipped_file in archived_items:
gzipped_state_output = z.open(expected_gzipped_file)
return gzip.decompress(gzipped_st... | _public_folder + 'dcos-mesos-slave-public.service', z)
verify_unit_response(unit_output, 100)
verify_archived_items(agent_public_folder, archived_items, expected_public_agent_files)
def get_file_content(unzipped_file: str, z: zipfile.ZipFile) -> bytes:
| 64 | 64 | 130 | 21 | 43 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | get_file_content | get_file_content | 578 | 586 | 578 | 578 | 024fd7f8787fef7a88f28a3dcda62975d154c7ea | bigcode/the-stack | train |
e62dd605bc780d98f52d22c2 | train | function | @retrying.retry(wait_fixed=2000, stop_max_delay=LATENCY * 1000)
def test_systemd_units_health(dcos_api_session: DcosApiSession) -> None:
"""
test all units and make sure the units are healthy. This test will fail if any of systemd unit is unhealthy,
meaning it focuses on making sure the dcos_api_session is ... | @retrying.retry(wait_fixed=2000, stop_max_delay=LATENCY * 1000)
def test_systemd_units_health(dcos_api_session: DcosApiSession) -> None:
| """
test all units and make sure the units are healthy. This test will fail if any of systemd unit is unhealthy,
meaning it focuses on making sure the dcos_api_session is healthy, rather then testing dcos-diagnostics itself.
"""
unhealthy_output = []
assert dcos_api_session.masters, "Must have a... | validate_units(units_response['units'])
pulled_units = list(map(lambda unit: unit['id'], units_response['units'])) # type: ignore
logging.info('collected units: {}'.format(pulled_units))
diff = set(pulled_units).symmetric_difference(all_units)
assert set(pulled_units) == all_units, ('... | 138 | 138 | 460 | 40 | 98 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | test_systemd_units_health | test_systemd_units_health | 184 | 212 | 184 | 185 | 3323a3dcd74c2c7bfe0a2743e2cdefbeab94a8c9 | bigcode/the-stack | train |
9cc9f070ba34c17df850ece8 | train | function | @pytest.mark.parametrize('use_legacy_api', [
pytest.param(False),
pytest.param(True)])
def test_dcos_diagnostics_bundle_create_download_delete(dcos_api_session: DcosApiSession, use_legacy_api: bool) -> None:
"""
test bundle create, read, delete workflow
"""
health_url = dcos_api_session.default... | @pytest.mark.parametrize('use_legacy_api', [
pytest.param(False),
pytest.param(True)])
def test_dcos_diagnostics_bundle_create_download_delete(dcos_api_session: DcosApiSession, use_legacy_api: bool) -> None:
| """
test bundle create, read, delete workflow
"""
health_url = dcos_api_session.default_url.copy(
query='cache=0',
path='system/health/v1',
)
diagnostics = Diagnostics(
default_url=health_url,
masters=dcos_api_session.masters,
all_slaves=dcos_api_session... | > 0
assert 'Nodes' in report_response
assert len(report_response['Nodes']) > 0
@pytest.mark.parametrize('use_legacy_api', [
pytest.param(False),
pytest.param(True)])
def test_dcos_diagnostics_bundle_create_download_delete(dcos_api_session: DcosApiSession, use_legacy_api: bool) -> None:
| 75 | 75 | 253 | 50 | 24 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | test_dcos_diagnostics_bundle_create_download_delete | test_dcos_diagnostics_bundle_create_download_delete | 314 | 341 | 314 | 317 | ebbf5a08146b067eb63680c746e0976a945f2309 | bigcode/the-stack | train |
677ace7f82e8a8983c943e3b | train | function | @retrying.retry(wait_fixed=2000, stop_max_delay=LATENCY * 1000)
def test_dcos_diagnostics_units_unit_nodes(dcos_api_session: DcosApiSession) -> None:
"""
test a list of nodes for a specific unit, endpoint /system/health/v1/units/<unit>/nodes
"""
def get_nodes_from_response(response: Any) -> List[Option... | @retrying.retry(wait_fixed=2000, stop_max_delay=LATENCY * 1000)
def test_dcos_diagnostics_units_unit_nodes(dcos_api_session: DcosApiSession) -> None:
| """
test a list of nodes for a specific unit, endpoint /system/health/v1/units/<unit>/nodes
"""
def get_nodes_from_response(response: Any) -> List[Optional[str]]:
assert 'nodes' in response, 'response must have field `nodes`. Got {}'.format(response)
nodes_ip_map = make_nodes_ip_map(dco... | ) -> None:
"""
test a unit response in a right format, endpoint: /system/health/v1/units/<unit>
"""
for master in dcos_api_session.masters:
units_response = check_json(dcos_api_session.health.get('/units', node=master))
pulled_units = list(map(lambda unit: unit['id'], units_response['uni... | 165 | 165 | 552 | 43 | 122 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | test_dcos_diagnostics_units_unit_nodes | test_dcos_diagnostics_units_unit_nodes | 227 | 269 | 227 | 228 | 82102cea924829c8cd023cea81c3f353d13673bf | bigcode/the-stack | train |
a17ca0c2af00397fa22ce5e0 | train | function | def verify_unit_response(unit_output: bytes, min_lines: int) -> None:
assert len(unit_output.decode().split('\n')) >= min_lines, 'Expect at least {} lines. Full unit output {}'.format(
min_lines, unit_output.decode())
| def verify_unit_response(unit_output: bytes, min_lines: int) -> None:
| assert len(unit_output.decode().split('\n')) >= min_lines, 'Expect at least {} lines. Full unit output {}'.format(
min_lines, unit_output.decode())
| = expected_gzipped_file in archived_items
message = ('expecting {} or {} in {}'.format(expected_file, expected_gzipped_file, archived_items))
assert (unzipped_exists or gzipped_exists), message
def verify_unit_response(unit_output: bytes, min_lines: int) -> None:
| 64 | 64 | 53 | 17 | 46 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | verify_unit_response | verify_unit_response | 685 | 687 | 685 | 685 | 61f91a9e32418af618c790b830dae6784df88827 | bigcode/the-stack | train |
0861adb9cc01e1e935e9e202 | train | function | def verify_archived_items(folder: str, archived_items: list, expected_files: list) -> None:
for expected_file in expected_files:
expected_file = folder + expected_file
# We don't know in advance whether the file will be gzipped or not,
# because that depends on the size of the diagnostics f... | def verify_archived_items(folder: str, archived_items: list, expected_files: list) -> None:
| for expected_file in expected_files:
expected_file = folder + expected_file
# We don't know in advance whether the file will be gzipped or not,
# because that depends on the size of the diagnostics file, which can
# be influenced by multiple factors that are not under our control
... | s"]) > 1, "bundle must contain information about frameworks"
task_count = sum([len(f["tasks"]) for f in state["frameworks"]])
assert task_count > 0, "bundle must contains information about tasks"
def verify_archived_items(folder: str, archived_items: list, expected_files: list) -> None:
| 72 | 72 | 242 | 22 | 50 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | verify_archived_items | verify_archived_items | 665 | 682 | 665 | 665 | d0405f091bf665d3798c9f445dc988b3b21b89ac | bigcode/the-stack | train |
c38a2f905e3bdb464bcfe237 | train | function | def _download_bundle_from_master(dcos_api_session: DcosApiSession, master_index: Any, bundle: str,
diagnostics: Diagnostics) -> None:
""" Download DC/OS diagnostics bundle from a master
:param dcos_api_session: dcos_api_session fixture
:param master_index: master index from... | def _download_bundle_from_master(dcos_api_session: DcosApiSession, master_index: Any, bundle: str,
diagnostics: Diagnostics) -> None:
| """ Download DC/OS diagnostics bundle from a master
:param dcos_api_session: dcos_api_session fixture
:param master_index: master index from dcos_api_session.masters array
:param bundle: bundle name to download from master
:param diagnostics: DCOS Diagnostics client
"""
bundles = diagnostic... | .get('id') # type: str
if not bundle_name:
bundle_name = create_response['extra']['bundle_name']
assert bundle_name in bundles
return bundle_name
def _delete_bundle(diagnostics: Diagnostics, bundle: str) -> None:
bundles = diagnostics.get_diagnostics_reports()
assert bundle in bundles, '... | 256 | 256 | 1,876 | 33 | 223 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | _download_bundle_from_master | _download_bundle_from_master | 398 | 575 | 398 | 399 | e53eb3f108e94bdb2b98bf895020b3751ca9c386 | bigcode/the-stack | train |
c54698899501abd774feafd8 | train | function | def _download_and_extract_bundle_from_another_master(dcos_api_session: DcosApiSession, bundle: str,
diagnostics: Diagnostics) -> None:
if len(dcos_api_session.masters) > 1:
_download_bundle_from_master(dcos_api_session, 1, bundle, diagnostics)
| def _download_and_extract_bundle_from_another_master(dcos_api_session: DcosApiSession, bundle: str,
diagnostics: Diagnostics) -> None:
| if len(dcos_api_session.masters) > 1:
_download_bundle_from_master(dcos_api_session, 1, bundle, diagnostics)
| ApiSession, bundle: str, diagnostics: Diagnostics) -> None:
_download_bundle_from_master(dcos_api_session, 0, bundle, diagnostics)
def _download_and_extract_bundle_from_another_master(dcos_api_session: DcosApiSession, bundle: str,
diagnostics: Diagnostics) -> Non... | 64 | 64 | 64 | 32 | 32 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | _download_and_extract_bundle_from_another_master | _download_and_extract_bundle_from_another_master | 392 | 395 | 392 | 393 | 241aafad52b3a2f498ff6e099371fd41ebe31bd9 | bigcode/the-stack | train |
0e5a3cac5607122bd2e107e9 | train | function | def test_dcos_diagnostics_units_unit(dcos_api_session: DcosApiSession) -> None:
"""
test a unit response in a right format, endpoint: /system/health/v1/units/<unit>
"""
for master in dcos_api_session.masters:
units_response = check_json(dcos_api_session.health.get('/units', node=master))
... | def test_dcos_diagnostics_units_unit(dcos_api_session: DcosApiSession) -> None:
| """
test a unit response in a right format, endpoint: /system/health/v1/units/<unit>
"""
for master in dcos_api_session.masters:
units_response = check_json(dcos_api_session.health.get('/units', node=master))
pulled_units = list(map(lambda unit: unit['id'], units_response['units'])) # t... | journalctl output {}'.format(
unit_name, node['IP'], unit_props['Health'], node['Output'][unit_name]))
if unhealthy_output:
raise AssertionError('\n'.join(unhealthy_output))
def test_dcos_diagnostics_units_unit(dcos_api_session: DcosApiSession) -> None:
| 64 | 64 | 139 | 21 | 43 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | test_dcos_diagnostics_units_unit | test_dcos_diagnostics_units_unit | 215 | 224 | 215 | 215 | bbdf5e423389fd68efbfc2094f60b86def82ee0f | bigcode/the-stack | train |
eff8edac41f8458e12987f4b | train | function | def _delete_bundle(diagnostics: Diagnostics, bundle: str) -> None:
bundles = diagnostics.get_diagnostics_reports()
assert bundle in bundles, 'not found {} in {}'.format(bundle, bundles)
diagnostics.delete_bundle(bundle)
bundles = diagnostics.get_diagnostics_reports()
assert bundle not in bundles, ... | def _delete_bundle(diagnostics: Diagnostics, bundle: str) -> None:
| bundles = diagnostics.get_diagnostics_reports()
assert bundle in bundles, 'not found {} in {}'.format(bundle, bundles)
diagnostics.delete_bundle(bundle)
bundles = diagnostics.get_diagnostics_reports()
assert bundle not in bundles, 'found {} in {}'.format(bundle, bundles)
| found'
bundle_name = create_response.get('id') # type: str
if not bundle_name:
bundle_name = create_response['extra']['bundle_name']
assert bundle_name in bundles
return bundle_name
def _delete_bundle(diagnostics: Diagnostics, bundle: str) -> None:
| 64 | 64 | 74 | 16 | 47 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | _delete_bundle | _delete_bundle | 378 | 385 | 378 | 378 | 75b37f0fdb6ed1cceb63e677d9fd465f1216b637 | bigcode/the-stack | train |
d51374dfa97eeebe67dfe5bb | train | function | def validate_units(units: list) -> None:
assert isinstance(units, list), 'input argument must be list'
assert len(units) > 0, 'input argument cannot be empty'
required_fields = ['id', 'name', 'health', 'description']
for unit in units:
assert len(unit) == len(required_fields), 'a unit must have... | def validate_units(units: list) -> None:
| assert isinstance(units, list), 'input argument must be list'
assert len(units) > 0, 'input argument cannot be empty'
required_fields = ['id', 'name', 'health', 'description']
for unit in units:
assert len(unit) == len(required_fields), 'a unit must have the following fields: {}. Actual: {}'.fo... | cannot be empty
assert node['health'] in [0, 1], 'health must be 0 or 1'
assert node['host_ip'], 'host_ip cannot be empty'
assert node['role'], 'role cannot be empty'
def validate_units(units: list) -> None:
| 64 | 64 | 216 | 11 | 53 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | validate_units | validate_units | 622 | 637 | 622 | 622 | 16127f8098878a634211c70ca8137cce8d7a6d0f | bigcode/the-stack | train |
95c8bf55b8b0a9b9a30464b3 | train | function | def test_dcos_diagnostics_report(dcos_api_session: DcosApiSession) -> None:
"""
test dcos-diagnostics report endpoint /system/health/v1/report
"""
for master in dcos_api_session.masters:
report_response = check_json(dcos_api_session.health.get('/report', node=master))
assert 'Units' in r... | def test_dcos_diagnostics_report(dcos_api_session: DcosApiSession) -> None:
| """
test dcos-diagnostics report endpoint /system/health/v1/report
"""
for master in dcos_api_session.masters:
report_response = check_json(dcos_api_session.health.get('/report', node=master))
assert 'Units' in report_response
assert len(report_response['Units']) > 0
ass... | [0, 1], 'health must be 0 or 1'
assert node_response['role'], 'role field cannot be empty'
assert node_response['help'], 'help field cannot be empty'
def test_dcos_diagnostics_report(dcos_api_session: DcosApiSession) -> None:
| 64 | 64 | 112 | 20 | 44 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | test_dcos_diagnostics_report | test_dcos_diagnostics_report | 301 | 311 | 301 | 301 | f179753714cfc8e241b2b6e0ade27b76d5068ebe | bigcode/the-stack | train |
82ff19a457f7c9a92b1a5467 | train | function | @retrying.retry(wait_fixed=2000, stop_max_delay=LATENCY * 1000)
def test_dcos_diagnostics_health(dcos_api_session: DcosApiSession) -> None:
"""
test health endpoint /system/health/v1
"""
required_fields = ['units', 'hostname', 'ip', 'dcos_version', 'node_role', 'mesos_id', 'dcos_diagnostics_version']
... | @retrying.retry(wait_fixed=2000, stop_max_delay=LATENCY * 1000)
def test_dcos_diagnostics_health(dcos_api_session: DcosApiSession) -> None:
| """
test health endpoint /system/health/v1
"""
required_fields = ['units', 'hostname', 'ip', 'dcos_version', 'node_role', 'mesos_id', 'dcos_diagnostics_version']
required_fields_unit = ['id', 'health', 'output', 'description', 'help', 'name']
# Check all masters dcos-diagnostics instances on ba... | import gzip
import json
import logging
import os
import tempfile
import zipfile
from typing import Any, List, Optional
import pytest
import retrying
import test_helpers
from dcos_test_utils.dcos_api import DcosApiSession
from dcos_test_utils.diagnostics import Diagnostics
from dcos_test_utils.helpers import check_jso... | 183 | 222 | 740 | 41 | 141 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | test_dcos_diagnostics_health | test_dcos_diagnostics_health | 25 | 87 | 25 | 26 | f45a639dd13820f244cd682a093ab0e412585475 | bigcode/the-stack | train |
129f85dc78e9ead200115579 | train | function | def test_dcos_diagnostics_units_unit_nodes_node(dcos_api_session: DcosApiSession) -> None:
"""
test a specific node for a specific unit, endpoint /system/health/v1/units/<unit>/nodes/<node>
"""
required_node_fields = ['host_ip', 'health', 'role', 'output', 'help']
for master in dcos_api_session.mas... | def test_dcos_diagnostics_units_unit_nodes_node(dcos_api_session: DcosApiSession) -> None:
| """
test a specific node for a specific unit, endpoint /system/health/v1/units/<unit>/nodes/<node>
"""
required_node_fields = ['host_ip', 'health', 'role', 'output', 'help']
for master in dcos_api_session.masters:
units_response = check_json(dcos_api_session.health.get('/units', node=master... | ()
if 'dcos-mesos-slave.service' in pulled_units:
agent_nodes_response = check_json(
dcos_api_session.health.get('/units/dcos-mesos-slave.service/nodes', node=master))
agent_nodes = get_nodes_from_response(agent_nodes_response)
assert len(agent_nodes) == len(dcos... | 113 | 113 | 377 | 23 | 90 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | test_dcos_diagnostics_units_unit_nodes_node | test_dcos_diagnostics_units_unit_nodes_node | 272 | 298 | 272 | 272 | 3cda9b1444561362046acb2469f1eeff52694a3f | bigcode/the-stack | train |
cd4b9774b6cf968db1435726 | train | function | def validate_unit(unit: dict) -> None:
assert isinstance(unit, dict), 'input argument must be a dict'
required_fields = ['id', 'health', 'output', 'description', 'help', 'name']
assert len(unit) == len(required_fields), 'unit must have the following fields: {}. Actual: {}'.format(
', '.join(require... | def validate_unit(unit: dict) -> None:
| assert isinstance(unit, dict), 'input argument must be a dict'
required_fields = ['id', 'health', 'output', 'description', 'help', 'name']
assert len(unit) == len(required_fields), 'unit must have the following fields: {}. Actual: {}'.format(
', '.join(required_fields), unit)
for required_field... | ['name'], 'name field cannot be empty in {}'.format(unit)
assert unit['health'] in [0, 1], 'health must be 0 or 1'
assert unit['description'], 'description field cannot be empty in {}'.format(unit)
def validate_unit(unit: dict) -> None:
| 64 | 64 | 207 | 10 | 54 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | validate_unit | validate_unit | 640 | 654 | 640 | 640 | f36197625ffe00a846baf5837c6c7535cc4355b1 | bigcode/the-stack | train |
363b25b37f2255cb5087ce72 | train | function | def _check_diagnostics_bundle_status(dcos_api_session: DcosApiSession) -> None:
# validate diagnostics job status response
diagnostics_bundle_status = check_json(dcos_api_session.health.get('/report/diagnostics/status/all'))
required_status_fields = ['is_running', 'status', 'last_bundle_dir', 'job_started',... | def _check_diagnostics_bundle_status(dcos_api_session: DcosApiSession) -> None:
# validate diagnostics job status response
| diagnostics_bundle_status = check_json(dcos_api_session.health.get('/report/diagnostics/status/all'))
required_status_fields = ['is_running', 'status', 'last_bundle_dir', 'job_started',
'diagnostics_bundle_dir', 'diagnostics_job_timeout_min',
'journald... | cos_api_session, bundle, diagnostics)
_download_and_extract_bundle_from_another_master(dcos_api_session, bundle, diagnostics)
_delete_bundle(diagnostics, bundle)
def _check_diagnostics_bundle_status(dcos_api_session: DcosApiSession) -> None:
# validate diagnostics job status response
| 64 | 64 | 162 | 28 | 36 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | _check_diagnostics_bundle_status | _check_diagnostics_bundle_status | 344 | 355 | 344 | 345 | b33e35307d16e14dad1d637549ad3f111297e8eb | bigcode/the-stack | train |
b9837aeff45eea834da76efa | train | function | def _create_bundle(diagnostics: Diagnostics) -> str:
last_datapoint = {
'time': None,
'value': 0
}
create_response = diagnostics.start_diagnostics_job().json()
diagnostics.wait_for_diagnostics_job(last_datapoint=last_datapoint)
diagnostics.wait_for_diagnostics_reports()
bundles ... | def _create_bundle(diagnostics: Diagnostics) -> str:
| last_datapoint = {
'time': None,
'value': 0
}
create_response = diagnostics.start_diagnostics_job().json()
diagnostics.wait_for_diagnostics_job(last_datapoint=last_datapoint)
diagnostics.wait_for_diagnostics_reports()
bundles = diagnostics.get_diagnostics_reports()
assert le... | diagnostics_partition_disk_usage_percent',
'job_progress_percentage']
for _, properties in diagnostics_bundle_status.items():
for required_status_field in required_status_fields:
assert required_status_field in properties, 'property {} not found'.format(required_st... | 64 | 64 | 143 | 12 | 52 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | _create_bundle | _create_bundle | 358 | 375 | 358 | 358 | 31dbc7601dd92e6ec14979a37dfcd71e2366f1a7 | bigcode/the-stack | train |
7c53415238cd93cb82357a10 | train | function | def test_dcos_diagnostics_nodes_node_units(dcos_api_session: DcosApiSession) -> None:
"""
test a list of units from a specific node, endpoint /system/health/v1/nodes/<node>/units
"""
for master in dcos_api_session.masters:
# get a list of nodes
response = check_json(dcos_api_session.heal... | def test_dcos_diagnostics_nodes_node_units(dcos_api_session: DcosApiSession) -> None:
| """
test a list of units from a specific node, endpoint /system/health/v1/nodes/<node>/units
"""
for master in dcos_api_session.masters:
# get a list of nodes
response = check_json(dcos_api_session.health.get('/nodes', node=master))
nodes = list(map(lambda node: node['host_ip'], ... | # type: ignore
for node in nodes:
node_response = check_json(dcos_api_session.health.get('/nodes/{}'.format(node), node=master))
validate_node([node_response])
def test_dcos_diagnostics_nodes_node_units(dcos_api_session: DcosApiSession) -> None:
| 64 | 64 | 184 | 22 | 42 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | test_dcos_diagnostics_nodes_node_units | test_dcos_diagnostics_nodes_node_units | 122 | 136 | 122 | 122 | af66f2e7a98ab14a3de301e6dedf20ce39ef3b14 | bigcode/the-stack | train |
d46f7d8878e0bb3da68cf50d | train | function | def validate_state(state_output: Any) -> None:
state = json.loads(state_output)
assert len(state["frameworks"]) > 1, "bundle must contain information about frameworks"
task_count = sum([len(f["tasks"]) for f in state["frameworks"]])
assert task_count > 0, "bundle must contains information about tasks"
| def validate_state(state_output: Any) -> None:
| state = json.loads(state_output)
assert len(state["frameworks"]) > 1, "bundle must contain information about frameworks"
task_count = sum([len(f["tasks"]) for f in state["frameworks"]])
assert task_count > 0, "bundle must contains information about tasks"
| {}'.format(unit)
assert unit['health'] in [0, 1], 'health must be 0 or 1'
assert unit['description'], 'description field cannot be empty'
assert unit['help'], 'help field cannot be empty'
def validate_state(state_output: Any) -> None:
| 64 | 64 | 75 | 11 | 53 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | validate_state | validate_state | 657 | 662 | 657 | 657 | b6ea281abda30094acfd229b79abcc05bdbb2128 | bigcode/the-stack | train |
bfd0cd89bdb2e41c147ddda9 | train | function | @retrying.retry(wait_fixed=2000, stop_max_delay=LATENCY * 1000)
def test_dcos_diagnostics_nodes(dcos_api_session: DcosApiSession) -> None:
"""
test a list of nodes with statuses endpoint /system/health/v1/nodes
"""
for master in dcos_api_session.masters:
response = check_json(dcos_api_session.he... | @retrying.retry(wait_fixed=2000, stop_max_delay=LATENCY * 1000)
def test_dcos_diagnostics_nodes(dcos_api_session: DcosApiSession) -> None:
| """
test a list of nodes with statuses endpoint /system/health/v1/nodes
"""
for master in dcos_api_session.masters:
response = check_json(dcos_api_session.health.get('/nodes', node=master))
assert len(response) == 1, 'nodes response must have only one field: nodes'
assert 'nodes'... | not found'.format(required_field)
assert response[required_field], '{} cannot be empty'.format(required_field)
@retrying.retry(wait_fixed=2000, stop_max_delay=LATENCY * 1000)
def test_dcos_diagnostics_nodes(dcos_api_session: DcosApiSession) -> None:
| 64 | 64 | 196 | 41 | 23 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | test_dcos_diagnostics_nodes | test_dcos_diagnostics_nodes | 90 | 105 | 90 | 91 | 194b387fa1197c3935fd99740c78f1fc3223e991 | bigcode/the-stack | train |
6133b66e7c902c1ea791902e | train | function | def _download_and_extract_bundle(dcos_api_session: DcosApiSession, bundle: str, diagnostics: Diagnostics) -> None:
_download_bundle_from_master(dcos_api_session, 0, bundle, diagnostics)
| def _download_and_extract_bundle(dcos_api_session: DcosApiSession, bundle: str, diagnostics: Diagnostics) -> None:
| _download_bundle_from_master(dcos_api_session, 0, bundle, diagnostics)
| format(bundle, bundles)
diagnostics.delete_bundle(bundle)
bundles = diagnostics.get_diagnostics_reports()
assert bundle not in bundles, 'found {} in {}'.format(bundle, bundles)
def _download_and_extract_bundle(dcos_api_session: DcosApiSession, bundle: str, diagnostics: Diagnostics) -> None:
| 64 | 64 | 45 | 27 | 37 | cgawron1/windows-gh | packages/dcos-integration-test/extra/test_dcos_diagnostics.py | Python | _download_and_extract_bundle | _download_and_extract_bundle | 388 | 389 | 388 | 388 | 7aa0f037fbdbdae495d911e60f115364fcdf83fe | bigcode/the-stack | train |
a6efc1ca9a8d63d1ed68cee1 | train | class | class PduActions(object):
""" Defines persistence actions that relate to handling PDUs.
"""
def __init__(self, datastore):
self.store = datastore
@log_function
def mark_as_processed(self, pdu):
""" Persist the fact that we have fully processed the given `Pdu`
Returns:
... | class PduActions(object):
| """ Defines persistence actions that relate to handling PDUs.
"""
def __init__(self, datastore):
self.store = datastore
@log_function
def mark_as_processed(self, pdu):
""" Persist the fact that we have fully processed the given `Pdu`
Returns:
Deferred
"... | /licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations... | 147 | 147 | 491 | 6 | 141 | uroborus/synapse | synapse/federation/persistence.py | Python | PduActions | PduActions | 35 | 102 | 35 | 35 | b359d41cee51ba7b5d7948e82748e21524a53407 | bigcode/the-stack | train |
74e6212cc25c1e2e2de799c9 | train | class | class TransactionActions(object):
""" Defines persistence actions that relate to handling Transactions.
"""
def __init__(self, datastore):
self.store = datastore
@log_function
def have_responded(self, transaction):
""" Have we already responded to a transaction with the same id and... | class TransactionActions(object):
| """ Defines persistence actions that relate to handling Transactions.
"""
def __init__(self, datastore):
self.store = datastore
@log_function
def have_responded(self, transaction):
""" Have we already responded to a transaction with the same id and
origin?
Returns:... | results])
@log_function
def is_new(self, pdu):
""" When we receive a `Pdu` from a remote home server, we want to
figure out whether it is `new`, i.e. it is not some historic PDU that
we haven't seen simply because we haven't backfilled back that far.
Returns:
Defer... | 129 | 129 | 432 | 5 | 124 | uroborus/synapse | synapse/federation/persistence.py | Python | TransactionActions | TransactionActions | 105 | 177 | 105 | 105 | 790911dd6a8f0a500e7a9917a0e0cea49f66a947 | bigcode/the-stack | train |
7fa66495d0773f4d5ebbb6ec | train | class | class Migration(migrations.Migration):
dependencies = [
('catalog', '0002_language'),
]
operations = [
migrations.AddField(
model_name='book',
name='language',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='catalog.L... | class Migration(migrations.Migration):
| dependencies = [
('catalog', '0002_language'),
]
operations = [
migrations.AddField(
model_name='book',
name='language',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='catalog.Language'),
),
]
| # Generated by Django 2.2.5 on 2019-09-27 16:38
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
| 45 | 64 | 70 | 7 | 37 | ltcperera/LocalLibrary | locallibrary/catalog/migrations/0003_book_language.py | Python | Migration | Migration | 7 | 19 | 7 | 8 | b7268eb053e17398aa6f6c064d375e706974dce7 | bigcode/the-stack | train |
e72957725fcc94d83e89af82 | train | function | def get_simple_module_name(obj):
return dr.BASE_MODULE_NAMES.get(obj, None)
| def get_simple_module_name(obj):
| return dr.BASE_MODULE_NAMES.get(obj, None)
|
from collections import defaultdict
from ..formats import Formatter
from ..specs import Specs
from ..combiners.hostname import hostname as combiner_hostname
from ..parsers.branch_info import BranchInfo
from . import dr, plugins
log = logging.getLogger(__name__)
def get_simple_module_name(obj):
| 64 | 64 | 18 | 7 | 57 | ritwik12/insights-core | insights/core/evaluators.py | Python | get_simple_module_name | get_simple_module_name | 16 | 17 | 16 | 16 | bd1f878bb9343bbaa1332d02faa90bc4dffaef63 | bigcode/the-stack | train |
970584852bf2b3cfaf084f7e | train | class | class SingleEvaluator(Evaluator):
def append_metadata(self, r):
for k, v in r.items():
if k != "type":
self.metadata[k] = v
def format_response(self, response):
return response
def get_response(self):
r = dict(self.metadata_keys)
r.update({
... | class SingleEvaluator(Evaluator):
| def append_metadata(self, r):
for k, v in r.items():
if k != "type":
self.metadata[k] = v
def format_response(self, response):
return response
def get_response(self):
r = dict(self.metadata_keys)
r.update({
"system": {
... | the
client.
"""
return response
def format_result(self, result):
"""
To be overridden by subclasses to format individual rule results.
"""
return result
def process(self, graph=None):
with self:
if self.incremental:
s... | 85 | 85 | 284 | 6 | 79 | ritwik12/insights-core | insights/core/evaluators.py | Python | SingleEvaluator | SingleEvaluator | 69 | 110 | 69 | 69 | 822d390a4f0acb3066c3c49199b745957679a610 | bigcode/the-stack | train |
ba0e13b1900f30f81f9165d7 | train | class | class InsightsEvaluator(SingleEvaluator):
def __init__(self, broker=None, system_id=None, stream=sys.stdout, incremental=False):
super(InsightsEvaluator, self).__init__(broker, stream=sys.stdout, incremental=incremental)
self.system_id = system_id
self.branch_info = {}
self.product =... | class InsightsEvaluator(SingleEvaluator):
| def __init__(self, broker=None, system_id=None, stream=sys.stdout, incremental=False):
super(InsightsEvaluator, self).__init__(broker, stream=sys.stdout, incremental=incremental)
self.system_id = system_id
self.branch_info = {}
self.product = "rhel"
self.type = "host"
... | (r)
elif type_ == "metadata":
self.append_metadata(r)
elif type_ == "metadata_key":
self.metadata_keys[r.get_key()] = r["value"]
else:
response_id = "%s_id" % r.response_type
self.results[type_].append(self.format_result({
response_... | 101 | 102 | 340 | 7 | 94 | ritwik12/insights-core | insights/core/evaluators.py | Python | InsightsEvaluator | InsightsEvaluator | 113 | 152 | 113 | 113 | 0e26fd7e3d142a547fd4f54480ef1135ebe175f8 | bigcode/the-stack | train |
108966dd9d5443d77e109fa5 | train | class | class Evaluator(Formatter):
def __init__(self, broker=None, stream=sys.stdout, incremental=False):
super(Evaluator, self).__init__(broker or dr.Broker(), stream)
self.results = defaultdict(list)
self.rule_skips = []
self.hostname = None
self.metadata = {}
self.metadat... | class Evaluator(Formatter):
| def __init__(self, broker=None, stream=sys.stdout, incremental=False):
super(Evaluator, self).__init__(broker or dr.Broker(), stream)
self.results = defaultdict(list)
self.rule_skips = []
self.hostname = None
self.metadata = {}
self.metadata_keys = {}
self.inc... | import logging
import six
import sys
from collections import defaultdict
from ..formats import Formatter
from ..specs import Specs
from ..combiners.hostname import hostname as combiner_hostname
from ..parsers.branch_info import BranchInfo
from . import dr, plugins
log = logging.getLogger(__name__)
def get_simple_m... | 89 | 95 | 319 | 6 | 83 | ritwik12/insights-core | insights/core/evaluators.py | Python | Evaluator | Evaluator | 20 | 66 | 20 | 20 | c847b95a2052cda12d5346f915c1b529cdc512e0 | bigcode/the-stack | train |
93a7be123c6c4897b7c84843 | train | function | def get_ppx_ndx(dune, ppxs, ppx):
try:
ppxs.index(ppx)
except:
print("In dune file " + dune +
", the preprocessing clause does not contain " +
(sexpdata.dumps(ppx)))
global exit_code
exit_code = 1
| def get_ppx_ndx(dune, ppxs, ppx):
| try:
ppxs.index(ppx)
except:
print("In dune file " + dune +
", the preprocessing clause does not contain " +
(sexpdata.dumps(ppx)))
global exit_code
exit_code = 1
| ):
print(
"In dune file " + dune +
", the preprocessing clause indicates no preprocessing, but it should include "
+ (sexpdata.dumps(ppx)))
global exit_code
exit_code = 1
def get_ppx_ndx(dune, ppxs, ppx):
| 64 | 64 | 70 | 16 | 47 | phreelyfe/mina | scripts/require-ppx-version.py | Python | get_ppx_ndx | get_ppx_ndx | 59 | 67 | 59 | 59 | 5d65675aae54f7989febb89292e0a9ab278680ac | bigcode/the-stack | train |
f5e9d69f0a5baa3b45a46eb2 | train | function | def no_ppx_error(dune, ppx):
print(
"In dune file " + dune +
", the preprocessing clause indicates no preprocessing, but it should include "
+ (sexpdata.dumps(ppx)))
global exit_code
exit_code = 1
| def no_ppx_error(dune, ppx):
| print(
"In dune file " + dune +
", the preprocessing clause indicates no preprocessing, but it should include "
+ (sexpdata.dumps(ppx)))
global exit_code
exit_code = 1
| (dune, ppx):
print(
"In dune file " + dune +
", the preprocessing clause is missing; there should be one containing "
+ (sexpdata.dumps(ppx)))
global exit_code
exit_code = 1
def no_ppx_error(dune, ppx):
| 64 | 64 | 58 | 11 | 52 | phreelyfe/mina | scripts/require-ppx-version.py | Python | no_ppx_error | no_ppx_error | 50 | 56 | 50 | 50 | 1363970b74c6f0ded6b0c83be2039828d53eeb2e | bigcode/the-stack | train |
1dd27a74f2c2f5d850133d51 | train | function | def dune_paths_ok(dune):
path = dune.split('/')
path_prefix2 = path[1:2]
path_prefix3 = path[1:3]
return (not (path_prefix2 == ['_build'] or path_prefix2 == ['external']
or path_prefix3 == ['lib', 'zexe']
or path_prefix3 == ['lib', 'snarky']
or path_pre... | def dune_paths_ok(dune):
| path = dune.split('/')
path_prefix2 = path[1:2]
path_prefix3 = path[1:3]
return (not (path_prefix2 == ['_build'] or path_prefix2 == ['external']
or path_prefix3 == ['lib', 'zexe']
or path_prefix3 == ['lib', 'snarky']
or path_prefix3 == ['lib', 'ppx_vers... |
import string
import sexpdata
dune_string = subprocess.check_output(['find', 'src', '-name', 'dune'])
dune_paths_raw = dune_string.decode('utf-8').split('\n')
# filter out dune paths where we don't require linting
def dune_paths_ok(dune):
| 64 | 64 | 125 | 7 | 56 | phreelyfe/mina | scripts/require-ppx-version.py | Python | dune_paths_ok | dune_paths_ok | 15 | 24 | 15 | 15 | a74f3b7e121c4431664ade33a0b041b7b23bb325 | bigcode/the-stack | train |
7ae1d7e426c7b63d4f0bff66 | train | function | def missing_ppx_error(dune, ppx):
print(
"In dune file " + dune +
", the preprocessing clause is missing; there should be one containing "
+ (sexpdata.dumps(ppx)))
global exit_code
exit_code = 1
| def missing_ppx_error(dune, ppx):
| print(
"In dune file " + dune +
", the preprocessing clause is missing; there should be one containing "
+ (sexpdata.dumps(ppx)))
global exit_code
exit_code = 1
| ('executable')
preprocess = sexpdata.loads('preprocess')
pps = sexpdata.loads('pps')
no_preprocessing = sexpdata.loads('no_preprocessing')
ppx_lint = sexpdata.loads('ppx_version')
exit_code = 0
def missing_ppx_error(dune, ppx):
| 64 | 64 | 58 | 11 | 52 | phreelyfe/mina | scripts/require-ppx-version.py | Python | missing_ppx_error | missing_ppx_error | 41 | 47 | 41 | 41 | 0b72f8c4de07737f7283a61ee3d092b2d7a21c6c | bigcode/the-stack | train |
8f5d192675e0ca66efc94301 | train | class | class Migration(migrations.Migration):
initial = True
dependencies = [
('shopping', '0006_auto_20200727_1824'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Address',
fields=[
... | class Migration(migrations.Migration):
| initial = True
dependencies = [
('shopping', '0006_auto_20200727_1824'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Address',
fields=[
('id', models.AutoField(auto_created=Tru... | # Generated by Django 3.0.8 on 2020-07-27 19:51
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django_countries.fields
class Migration(migrations.Migration):
| 57 | 193 | 645 | 7 | 49 | abdellatifLabr/MyStore | order/migrations/0001_initial.py | Python | Migration | Migration | 9 | 67 | 9 | 10 | 0101303dfb0b04c6322e87af07fd5c272d3dbf7e | bigcode/the-stack | train |
160610818da3812edd67fd8b | train | function | def estimate_gradient(f: Callable[[Vector], float],
v: Vector,
h: float = 0.0001):
return [partial_difference_quotient(f, v, i, h)
for i in range(len(v))]
| def estimate_gradient(f: Callable[[Vector], float],
v: Vector,
h: float = 0.0001):
| return [partial_difference_quotient(f, v, i, h)
for i in range(len(v))]
| f(x)) / h
def square(x: float) -> float:
return x * x
def derivative(x: float) -> float:
return 2 * x
def estimate_gradient(f: Callable[[Vector], float],
v: Vector,
h: float = 0.0001):
| 64 | 64 | 51 | 27 | 36 | dichangyan/dscourse | scratch/scratch/gradient_descent.py | Python | estimate_gradient | estimate_gradient | 20 | 24 | 20 | 22 | 03365b85922036be7907745119e6af3397de813f | bigcode/the-stack | train |
d0b0ef93fd299f522410c126 | train | function | def main():
xs = range(-10, 11)
actuals = [derivative(x) for x in xs]
estimates = [difference_quotient(square, x, h=0.001) for x in xs]
# plot to show they're basically the same
import matplotlib.pyplot as plt
plt.title("Actual Derivatives vs. Estimates")
plt.plot(xs, actuals, 'rx', lab... | def main():
| xs = range(-10, 11)
actuals = [derivative(x) for x in xs]
estimates = [difference_quotient(square, x, h=0.001) for x in xs]
# plot to show they're basically the same
import matplotlib.pyplot as plt
plt.title("Actual Derivatives vs. Estimates")
plt.plot(xs, actuals, 'rx', label='Actual')... | (x: float, y: float, theta: Vector) -> Vector:
slope, intercept = theta
predicted = slope * x + intercept # The prediction of the model.
error = (predicted - y) # error is (predicted - actual)
squared_error = error ** 2 # We'll minimize squared error
grad = [2 * error * x, ... | 247 | 247 | 824 | 3 | 244 | dichangyan/dscourse | scratch/scratch/gradient_descent.py | Python | main | main | 66 | 154 | 66 | 66 | 98d5abf2bcd821945af4376c00e954ca84c09294 | bigcode/the-stack | train |
40fee7714a684b0a492822b7 | train | function | def derivative(x: float) -> float:
return 2 * x
| def derivative(x: float) -> float:
| return 2 * x
| difference_quotient(f: Callable[[float], float],
x: float,
h: float) -> float:
return (f(x + h) - f(x)) / h
def square(x: float) -> float:
return x * x
def derivative(x: float) -> float:
| 64 | 64 | 16 | 9 | 54 | dichangyan/dscourse | scratch/scratch/gradient_descent.py | Python | derivative | derivative | 17 | 18 | 17 | 17 | ce068ec203dde0d6d0440e548097b82a7cb0abba | bigcode/the-stack | train |
36ff4ae9037b9783ee2eb633 | train | function | def linear_gradient(x: float, y: float, theta: Vector) -> Vector:
slope, intercept = theta
predicted = slope * x + intercept # The prediction of the model.
error = (predicted - y) # error is (predicted - actual)
squared_error = error ** 2 # We'll minimize squared error
grad... | def linear_gradient(x: float, y: float, theta: Vector) -> Vector:
| slope, intercept = theta
predicted = slope * x + intercept # The prediction of the model.
error = (predicted - y) # error is (predicted - actual)
squared_error = error ** 2 # We'll minimize squared error
grad = [2 * error * x, 2 * error] # using its gradient.
return ... | v]
# x ranges from -50 to 49, y is always 20 * x + 5
inputs = [(x, 20 * x + 5) for x in range(-50, 50)]
def linear_gradient(x: float, y: float, theta: Vector) -> Vector:
| 64 | 64 | 100 | 18 | 46 | dichangyan/dscourse | scratch/scratch/gradient_descent.py | Python | linear_gradient | linear_gradient | 41 | 47 | 41 | 41 | 581f48d3ccbcc57ca845bdaf3ffa2c6067dab468 | bigcode/the-stack | train |
5b7779623b95e3da68b88303 | train | function | def difference_quotient(f: Callable[[float], float],
x: float,
h: float) -> float:
return (f(x + h) - f(x)) / h
| def difference_quotient(f: Callable[[float], float],
x: float,
h: float) -> float:
| return (f(x + h) - f(x)) / h
| dot
def sum_of_squares(v: Vector) -> float:
"""Computes the sum of squared elements in v"""
return dot(v, v)
from typing import Callable
def difference_quotient(f: Callable[[float], float],
x: float,
h: float) -> float:
| 64 | 64 | 41 | 26 | 37 | dichangyan/dscourse | scratch/scratch/gradient_descent.py | Python | difference_quotient | difference_quotient | 9 | 12 | 9 | 11 | b3bf2f6ca327ea3ad50fe20d3db5c36df374c957 | bigcode/the-stack | train |
74e83a51bd19c45bddee39dd | train | function | def sum_of_squares(v: Vector) -> float:
"""Computes the sum of squared elements in v"""
return dot(v, v)
| def sum_of_squares(v: Vector) -> float:
| """Computes the sum of squared elements in v"""
return dot(v, v)
| from code.scratch.scratch.scratch.linear_algebra import Vector, dot
def sum_of_squares(v: Vector) -> float:
| 28 | 64 | 31 | 12 | 15 | dichangyan/dscourse | scratch/scratch/gradient_descent.py | Python | sum_of_squares | sum_of_squares | 3 | 5 | 3 | 3 | 7c9a9c60f47bc13732cf8c9cb095c5d73de4ee99 | bigcode/the-stack | train |
d18de8807ebfbc7eacc65659 | train | function | def gradient_step(v: Vector, gradient: Vector, step_size: float) -> Vector:
"""Moves `step_size` in the `gradient` direction from `v`"""
assert len(v) == len(gradient)
step = scalar_multiply(step_size, gradient)
return add(v, step)
| def gradient_step(v: Vector, gradient: Vector, step_size: float) -> Vector:
| """Moves `step_size` in the `gradient` direction from `v`"""
assert len(v) == len(gradient)
step = scalar_multiply(step_size, gradient)
return add(v, step)
| partial_difference_quotient(f, v, i, h)
for i in range(len(v))]
import random
from code.scratch.scratch.scratch.linear_algebra import distance, add, scalar_multiply
def gradient_step(v: Vector, gradient: Vector, step_size: float) -> Vector:
| 64 | 64 | 65 | 19 | 44 | dichangyan/dscourse | scratch/scratch/gradient_descent.py | Python | gradient_step | gradient_step | 29 | 33 | 29 | 29 | 14aace2847ea081479d9e7b9ba7333e4510f304c | bigcode/the-stack | train |
31ef4954b2218943e0c16d06 | train | function | def sum_of_squares_gradient(v: Vector) -> Vector:
return [2 * v_i for v_i in v]
| def sum_of_squares_gradient(v: Vector) -> Vector:
| return [2 * v_i for v_i in v]
| float) -> Vector:
"""Moves `step_size` in the `gradient` direction from `v`"""
assert len(v) == len(gradient)
step = scalar_multiply(step_size, gradient)
return add(v, step)
def sum_of_squares_gradient(v: Vector) -> Vector:
| 64 | 64 | 26 | 13 | 51 | dichangyan/dscourse | scratch/scratch/gradient_descent.py | Python | sum_of_squares_gradient | sum_of_squares_gradient | 35 | 36 | 35 | 35 | fd6b6c2d1eba11fff9248814a0859a5c90e2cf4b | bigcode/the-stack | train |
ec8ce90c8c642bef7f6085b2 | train | function | def minibatches(dataset: List[T],
batch_size: int,
shuffle: bool = True) -> Iterator[List[T]]:
"""Generates `batch_size`-sized minibatches from the dataset"""
# Start indexes 0, batch_size, 2 * batch_size, ...
batch_starts = [start for start in range(0, len(dataset), batch_si... | def minibatches(dataset: List[T],
batch_size: int,
shuffle: bool = True) -> Iterator[List[T]]:
| """Generates `batch_size`-sized minibatches from the dataset"""
# Start indexes 0, batch_size, 2 * batch_size, ...
batch_starts = [start for start in range(0, len(dataset), batch_size)]
if shuffle: random.shuffle(batch_starts) # shuffle the batches
for start in batch_starts:
end = start +... | # using its gradient.
return grad
from typing import TypeVar, List, Iterator
T = TypeVar('T') # this allows us to type "generic" functions
def minibatches(dataset: List[T],
batch_size: int,
shuffle: bool = True) -> Iterator[List[T]]:
| 64 | 64 | 118 | 26 | 37 | dichangyan/dscourse | scratch/scratch/gradient_descent.py | Python | minibatches | minibatches | 53 | 64 | 53 | 55 | bcfe578b258085be3047f4b56df17331f02f1fbc | bigcode/the-stack | train |
18f487ad831f170d876ee849 | train | function | def square(x: float) -> float:
return x * x
| def square(x: float) -> float:
| return x * x
| v"""
return dot(v, v)
from typing import Callable
def difference_quotient(f: Callable[[float], float],
x: float,
h: float) -> float:
return (f(x + h) - f(x)) / h
def square(x: float) -> float:
| 64 | 64 | 15 | 9 | 54 | dichangyan/dscourse | scratch/scratch/gradient_descent.py | Python | square | square | 14 | 15 | 14 | 14 | 538c906b6cc65f2b29f63d82a3fb9df31be081c7 | bigcode/the-stack | train |
e913ef577aa6bb8984721c4e | train | function | def _daal4py_predict(self, X):
X = make2d(X)
_fptype = getFPType(self.coef_)
lr_pred = daal4py.linear_regression_prediction(
fptype=_fptype,
method='defaultDense'
)
try:
lr_res = lr_pred.compute(X, self.daal_model_)
except RuntimeError:
raise ValueError('Input dat... | def _daal4py_predict(self, X):
| X = make2d(X)
_fptype = getFPType(self.coef_)
lr_pred = daal4py.linear_regression_prediction(
fptype=_fptype,
method='defaultDense'
)
try:
lr_res = lr_pred.compute(X, self.daal_model_)
except RuntimeError:
raise ValueError('Input data shape {} is inconsistent with... | .nan)
if self.coef_.shape[0] == 1 and y_.ndim == 1:
self.coef_ = np.ravel(self.coef_)
self.intercept_ = self.intercept_[0]
return self
def _daal4py_predict(self, X):
| 64 | 64 | 142 | 11 | 52 | makart19/daal4py | daal4py/sklearn/linear_model/_linear_0_23.py | Python | _daal4py_predict | _daal4py_predict | 85 | 101 | 85 | 85 | 29d4d2046979a95e632d439593d5aa8b911fa23e | bigcode/the-stack | train |
68552e7d93cc5d0074632224 | train | function | def fit(self, X, y, sample_weight=None):
"""
Fit linear model.
Parameters
----------
X : numpy array or sparse matrix of shape [n_samples,n_features]
Training data
y : numpy array of shape [n_samples, n_targets]
Target values
sample_weight : numpy array of shape [n_samples... | def fit(self, X, y, sample_weight=None):
| """
Fit linear model.
Parameters
----------
X : numpy array or sparse matrix of shape [n_samples,n_features]
Training data
y : numpy array of shape [n_samples, n_targets]
Target values
sample_weight : numpy array of shape [n_samples]
Individual weights for each sam... | (order='C')
self.n_features_in_ = X.shape[1]
self.rank_ = X.shape[1]
self.singular_ = np.full((X.shape[1],), np.nan)
if self.coef_.shape[0] == 1 and y_.ndim == 1:
self.coef_ = np.ravel(self.coef_)
self.intercept_ = self.intercept_[0]
return self
def _daal4py_predict(self, X):
... | 249 | 249 | 830 | 12 | 236 | makart19/daal4py | daal4py/sklearn/linear_model/_linear_0_23.py | Python | fit | fit | 104 | 197 | 104 | 104 | 6f3a24f9e8173558689c433eebb84007045e4b59 | bigcode/the-stack | train |
a51fede4cd91e52d711188f0 | train | function | def _daal4py_fit(self, X, y_):
y = make2d(y_)
X_fptype = getFPType(X)
try:
lr_algorithm = daal4py.linear_regression_training(
fptype=X_fptype,
interceptFlag=bool(self.fit_intercept),
method='defaultDense'
)
lr_res = lr_algorithm.compute(X, y)
... | def _daal4py_fit(self, X, y_):
| y = make2d(y_)
X_fptype = getFPType(X)
try:
lr_algorithm = daal4py.linear_regression_training(
fptype=X_fptype,
interceptFlag=bool(self.fit_intercept),
method='defaultDense'
)
lr_res = lr_algorithm.compute(X, y)
except RuntimeError:
# ... | .utils._joblib import Parallel, delayed
except ImportError:
from sklearn.externals.joblib import Parallel, delayed
import daal4py
from .._utils import (make2d, getFPType, method_uses_sklearn, \
method_uses_daal, method_uses_sklearn_arter_daal,
is_DataFrame, get_dtype)
import... | 96 | 96 | 320 | 14 | 81 | makart19/daal4py | daal4py/sklearn/linear_model/_linear_0_23.py | Python | _daal4py_fit | _daal4py_fit | 43 | 82 | 43 | 43 | 58cdcccdbfa3ec6360d42c45370f9f5b1c595834 | bigcode/the-stack | train |
2ec5bb33d6b052c5637050bd | train | function | def predict(self, X):
"""Predict using the linear model
Parameters
----------
X : {array-like, sparse matrix}, shape = (n_samples, n_features)
Samples.
Returns
-------
C : array, shape = (n_samples,)
Returns predicted values.
"""
is_df = is_DataFrame(X)
X = np.a... | def predict(self, X):
| """Predict using the linear model
Parameters
----------
X : {array-like, sparse matrix}, shape = (n_samples, n_features)
Samples.
Returns
-------
C : array, shape = (n_samples,)
Returns predicted values.
"""
is_df = is_DataFrame(X)
X = np.asarray(X) if not sp.is... | ef_, self._residues, self.rank_, self.singular_ = \
linalg.lstsq(X, y)
self.coef_ = self.coef_.T
if y.ndim == 1:
self.coef_ = np.ravel(self.coef_)
self._set_intercept(X_offset, y_offset, X_scale)
return self
def predict(self, X):
| 86 | 86 | 289 | 6 | 79 | makart19/daal4py | daal4py/sklearn/linear_model/_linear_0_23.py | Python | predict | predict | 199 | 227 | 199 | 199 | 5b1832014a1b26ae0fc942b5e1d03bcf7bc2fcdd | bigcode/the-stack | train |
e1337fcc9e2ac0d1bafd88f8 | train | class | class LinearRegression(LinearRegression_original):
__doc__ = LinearRegression_original.__doc__
def __init__(self, fit_intercept=True, normalize=False, copy_X=True,
n_jobs=None):
super(LinearRegression, self).__init__(
fit_intercept=fit_intercept, normalize=normalize,
... | class LinearRegression(LinearRegression_original):
| __doc__ = LinearRegression_original.__doc__
def __init__(self, fit_intercept=True, normalize=False, copy_X=True,
n_jobs=None):
super(LinearRegression, self).__init__(
fit_intercept=fit_intercept, normalize=normalize,
copy_X=copy_X, n_jobs=n_jobs)
def fit(se... | _function(X)
logging.info("sklearn.linar_model.LinearRegression.predict: " + method_uses_daal)
X = _daal_check_array(X)
return _daal4py_predict(self, X)
_fit_copy = fit
_predict_copy = predict
class LinearRegression(LinearRegression_original):
| 64 | 64 | 124 | 8 | 55 | makart19/daal4py | daal4py/sklearn/linear_model/_linear_0_23.py | Python | LinearRegression | LinearRegression | 233 | 246 | 233 | 233 | af0e2b36c288fade7f4afde5383fbb244c1ba48a | bigcode/the-stack | train |
a5b736fd232f15024b1883bd | train | function | def parse_args(argv, default_config_files=None, configure_db=True,
init_rpc=True):
log.register_options(CONF)
# We use the oslo.log default log levels which includes suds=INFO
# and add only the extra levels that Nova needs
if CONF.glance.debug:
extra_default_log_levels = ['glance... | def parse_args(argv, default_config_files=None, configure_db=True,
init_rpc=True):
| log.register_options(CONF)
# We use the oslo.log default log levels which includes suds=INFO
# and add only the extra levels that Nova needs
if CONF.glance.debug:
extra_default_log_levels = ['glanceclient=DEBUG']
else:
extra_default_log_levels = ['glanceclient=WARN']
# NOTE(danm... | _db
from nova.common import config
import nova.conf
from nova.db.sqlalchemy import api as sqlalchemy_api
from nova import rpc
from nova import version
profiler = importutils.try_import('osprofiler.opts')
CONF = nova.conf.CONF
def parse_args(argv, default_config_files=None, configure_db=True,
init_rpc=... | 72 | 72 | 241 | 19 | 52 | lixiaoy1/nova | nova/config.py | Python | parse_args | parse_args | 34 | 65 | 34 | 35 | 2af4d62e7dd10417c92557c3438b70ab58ce0dcd | bigcode/the-stack | train |
55b4c26cd56aee1433936198 | train | class | class SearchInputMixin(unittest.TestCase):
def setUp(self):
self.input_list = [12,34,23,56,45,67]
| class SearchInputMixin(unittest.TestCase):
| def setUp(self):
self.input_list = [12,34,23,56,45,67]
| from .context import *
import unittest
class SearchInputMixin(unittest.TestCase):
| 16 | 64 | 32 | 8 | 7 | Chitrank-Dixit/PyAlgo | tests/test_searching.py | Python | SearchInputMixin | SearchInputMixin | 5 | 7 | 5 | 5 | e3ca1388103fff17f19254002287ac63ff8cc5f9 | bigcode/the-stack | train |
f11d29b138788ffbc361fe6c | train | class | class LinearSearchTestSuite(SearchInputMixin):
"""
Linear Search Test Case
"""
def test_linear_search(self):
instance = LinearSearch(self.input_list)
index = instance.search_item(23)
self.assertEqual(self.input_list.index(23), index)
| class LinearSearchTestSuite(SearchInputMixin):
| """
Linear Search Test Case
"""
def test_linear_search(self):
instance = LinearSearch(self.input_list)
index = instance.search_item(23)
self.assertEqual(self.input_list.index(23), index)
| from .context import *
import unittest
class SearchInputMixin(unittest.TestCase):
def setUp(self):
self.input_list = [12,34,23,56,45,67]
class LinearSearchTestSuite(SearchInputMixin):
| 49 | 64 | 57 | 9 | 40 | Chitrank-Dixit/PyAlgo | tests/test_searching.py | Python | LinearSearchTestSuite | LinearSearchTestSuite | 10 | 18 | 10 | 10 | c715a1b5df7d5f2d38b35c9a961e0a4b2dc112d8 | bigcode/the-stack | train |
57a91c1247a96165f926c84e | train | function | def growingPlant(upSpeed, downSpeed, desiredHeight):
height = upSpeed
difference = upSpeed - downSpeed
day = 1
while height < desiredHeight:
# print(f"Day: {day}, Height: {height}")
height += difference
day += 1
# print(f"Day: {day}, Height: {height}")
return day
| def growingPlant(upSpeed, downSpeed, desiredHeight):
| height = upSpeed
difference = upSpeed - downSpeed
day = 1
while height < desiredHeight:
# print(f"Day: {day}, Height: {height}")
height += difference
day += 1
# print(f"Day: {day}, Height: {height}")
return day
| def growingPlant(upSpeed, downSpeed, desiredHeight):
| 12 | 64 | 85 | 12 | 0 | shanemichaelarcaro/codesignal | Intro/Dark Wilderness/growingPlant.py | Python | growingPlant | growingPlant | 1 | 11 | 1 | 1 | 7ee93a236b3d92480b5493976e4445c7cb4ab9b2 | bigcode/the-stack | train |
d33881b13b9ea890590bc682 | train | class | class DensePoseOutputsVVisualizer(DensePoseOutputsVisualizer):
def __init__(self, inplace=True, cmap=cv2.COLORMAP_PARULA, alpha=0.7):
super().__init__(inplace=inplace, cmap=cmap, alpha=alpha, to_visualize="V")
| class DensePoseOutputsVVisualizer(DensePoseOutputsVisualizer):
| def __init__(self, inplace=True, cmap=cv2.COLORMAP_PARULA, alpha=0.7):
super().__init__(inplace=inplace, cmap=cmap, alpha=alpha, to_visualize="V")
| PoseOutputsVisualizer):
def __init__(self, inplace=True, cmap=cv2.COLORMAP_PARULA, alpha=0.7):
super().__init__(inplace=inplace, cmap=cmap, alpha=alpha, to_visualize="U")
class DensePoseOutputsVVisualizer(DensePoseOutputsVisualizer):
| 64 | 64 | 60 | 11 | 53 | YangLiu14/detectron2-training | projects/DensePose/densepose/vis/densepose_outputs.py | Python | DensePoseOutputsVVisualizer | DensePoseOutputsVVisualizer | 90 | 92 | 90 | 90 | 3e985c0d801470e1588c2f8d706aa082955d64f1 | bigcode/the-stack | train |
4e6a19f8d30cbbb7faed08fa | train | class | class DensePoseOutputsFineSegmentationVisualizer(DensePoseOutputsVisualizer):
def __init__(self, inplace=True, cmap=cv2.COLORMAP_PARULA, alpha=0.7):
super().__init__(inplace=inplace, cmap=cmap, alpha=alpha, to_visualize="I")
| class DensePoseOutputsFineSegmentationVisualizer(DensePoseOutputsVisualizer):
| def __init__(self, inplace=True, cmap=cv2.COLORMAP_PARULA, alpha=0.7):
super().__init__(inplace=inplace, cmap=cmap, alpha=alpha, to_visualize="I")
| Visualizer):
def __init__(self, inplace=True, cmap=cv2.COLORMAP_PARULA, alpha=0.7):
super().__init__(inplace=inplace, cmap=cmap, alpha=alpha, to_visualize="V")
class DensePoseOutputsFineSegmentationVisualizer(DensePoseOutputsVisualizer):
| 64 | 64 | 62 | 13 | 51 | YangLiu14/detectron2-training | projects/DensePose/densepose/vis/densepose_outputs.py | Python | DensePoseOutputsFineSegmentationVisualizer | DensePoseOutputsFineSegmentationVisualizer | 95 | 97 | 95 | 95 | 3612effd220991011a1fc989ea405e667023193c | bigcode/the-stack | train |
0577c1862c29e5e739a0943f | train | class | class DensePoseOutputsVisualizer(object):
def __init__(self, inplace=True, cmap=cv2.COLORMAP_PARULA, alpha=0.7, to_visualize=None):
assert to_visualize in "IUV", "can only visualize IUV"
self.to_visualize = to_visualize
if self.to_visualize == "I":
val_scale = 255.0 / DensePoseD... | class DensePoseOutputsVisualizer(object):
| def __init__(self, inplace=True, cmap=cv2.COLORMAP_PARULA, alpha=0.7, to_visualize=None):
assert to_visualize in "IUV", "can only visualize IUV"
self.to_visualize = to_visualize
if self.to_visualize == "I":
val_scale = 255.0 / DensePoseDataRelative.N_PART_LABELS
else:
... | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import numpy as np
from typing import Optional, Tuple
import cv2
from ..data.structures import DensePoseDataRelative
from ..structures import DensePoseChartPredictorOutput
from .base import Boxes, Image, MatrixVisualizer
class DensePoseOutputsVisua... | 73 | 211 | 706 | 7 | 65 | YangLiu14/detectron2-training | projects/DensePose/densepose/vis/densepose_outputs.py | Python | DensePoseOutputsVisualizer | DensePoseOutputsVisualizer | 11 | 82 | 11 | 11 | 98e6a4b6b1693b9a198230927ff26af028e42a77 | bigcode/the-stack | train |
bfcaf6fafaaeaf00d96532d0 | train | class | class DensePoseOutputsUVisualizer(DensePoseOutputsVisualizer):
def __init__(self, inplace=True, cmap=cv2.COLORMAP_PARULA, alpha=0.7):
super().__init__(inplace=inplace, cmap=cmap, alpha=alpha, to_visualize="U")
| class DensePoseOutputsUVisualizer(DensePoseOutputsVisualizer):
| def __init__(self, inplace=True, cmap=cv2.COLORMAP_PARULA, alpha=0.7):
super().__init__(inplace=inplace, cmap=cmap, alpha=alpha, to_visualize="U")
| n[partId][segmentation == partId].clip(0, 1) * 255
)
image_bgr = self.mask_visualizer.visualize(image_bgr, mask, vis, bbox_xywh)
return image_bgr
class DensePoseOutputsUVisualizer(DensePoseOutputsVisualizer):
| 64 | 64 | 60 | 11 | 52 | YangLiu14/detectron2-training | projects/DensePose/densepose/vis/densepose_outputs.py | Python | DensePoseOutputsUVisualizer | DensePoseOutputsUVisualizer | 85 | 87 | 85 | 85 | 6747baa348c7011f314ab741772c59867d407771 | bigcode/the-stack | train |
1fd667167527ff293164fda6 | train | class | class test_profile(PybindBase):
"""
This class was auto-generated by the PythonClass plugin for PYANG
from YANG module brocade-dot1ag-operational - based on the path /cfm-state/cfm-y1731/test-profile. Each member element of
the container is represented as a class variable - with a specific
YANG type.
YANG ... | class test_profile(PybindBase):
| """
This class was auto-generated by the PythonClass plugin for PYANG
from YANG module brocade-dot1ag-operational - based on the path /cfm-state/cfm-y1731/test-profile. Each member element of
the container is represented as a class variable - with a specific
YANG type.
YANG Description: CFM Test Profile De... |
from operator import attrgetter
import pyangbind.lib.xpathhelper as xpathhelper
from pyangbind.lib.yangtypes import RestrictedPrecisionDecimalType, RestrictedClassType, TypedListType
from pyangbind.lib.yangtypes import YANGBool, YANGListType, YANGDynClass, ReferenceType
from pyangbind.lib.base import PybindBase
from d... | 98 | 256 | 10,338 | 7 | 91 | extremenetworks/pybind | pybind/slxos/v17r_2_00/cfm_state/cfm_y1731/test_profile/__init__.py | Python | test_profile | test_profile | 10 | 599 | 10 | 10 | 05303fc68a25cc052dedeaaeb604be84c027eed7 | bigcode/the-stack | train |
65adecbd6a50e2e5d81fad8e | train | class | class usersmessagesattachmentsOperations:
"""usersmessagesattachmentsOperations async operations.
You should not instantiate this class directly. Instead, you should create a Client instance that
instantiates it for you and attaches it as an attribute.
:ivar models: Alias to model classes used in this... | class usersmessagesattachmentsOperations:
| """usersmessagesattachmentsOperations async operations.
You should not instantiate this class directly. Instead, you should create a Client instance that
instantiates it for you and attaches it as an attribute.
:ivar models: Alias to model classes used in this operation group.
:type models: ~users... | # coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may ... | 180 | 256 | 880 | 6 | 174 | microsoftgraph/msgraph-cli-archived | msgraph/cli/command_modules/usersactions/azext_usersactions/vendored_sdks/usersactions/aio/operations/_usersmessagesattachments_operations.py | Python | usersmessagesattachmentsOperations | usersmessagesattachmentsOperations | 20 | 106 | 20 | 20 | eb203c79b103953e74e7a79f576c37e5ef2c797c | bigcode/the-stack | train |
b37034e0fa9825123514a9fa | train | class | class RuleStatus:
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
sensitive_list = []
... | class RuleStatus:
| """
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
sensitive_list = []
openapi_types = {
... | # coding: utf-8
import re
import six
from huaweicloudsdkcore.utils.http_utils import sanitize_for_serialization
class RuleStatus:
| 32 | 186 | 623 | 4 | 27 | huaweicloud/huaweicloud-sdk-python-v3 | huaweicloud-sdk-iotda/huaweicloudsdkiotda/v5/model/rule_status.py | Python | RuleStatus | RuleStatus | 11 | 113 | 11 | 13 | bc3709f76c8c09cb455683e66ca2e6e7681a4b22 | bigcode/the-stack | train |
c2e34041f20d6f75ab725590 | train | class | class ReconstructionOpsTest(test.TestCase):
def __init__(self, *args, **kwargs):
super(ReconstructionOpsTest, self).__init__(*args, **kwargs)
self.batch_size = 3
self.frames = 3
self.samples = 5
self.bases = np.array(range(2, 5))
exponents = np.array(range(self.frames * self.samples))
po... | class ReconstructionOpsTest(test.TestCase):
| def __init__(self, *args, **kwargs):
super(ReconstructionOpsTest, self).__init__(*args, **kwargs)
self.batch_size = 3
self.frames = 3
self.samples = 5
self.bases = np.array(range(2, 5))
exponents = np.array(range(self.frames * self.samples))
powers = np.power(self.bases[:, np.newaxis], ex... | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 235 | 256 | 1,704 | 8 | 226 | wenming2014/tensorflow | tensorflow/python/kernel_tests/signal/reconstruction_ops_test.py | Python | ReconstructionOpsTest | ReconstructionOpsTest | 32 | 188 | 32 | 33 | 4823d9eb2e9bd241ef6f8c1f21747444fdc112bb | bigcode/the-stack | train |
7ef6a7cce08b6998da57e2bb | train | class | class AbbreviationSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Abbreviation
fields = "__all__"
| class AbbreviationSerializer(serializers.HyperlinkedModelSerializer):
| class Meta:
model = Abbreviation
fields = "__all__"
| from rest_framework import serializers
from .models import Abbreviation
class AbbreviationSerializer(serializers.HyperlinkedModelSerializer):
| 24 | 64 | 28 | 11 | 12 | acdh-oeaw/abbr | words/serializers.py | Python | AbbreviationSerializer | AbbreviationSerializer | 5 | 9 | 5 | 6 | c5351c1377d6d7a6e05d8a81a1a692fa164f2195 | bigcode/the-stack | train |
8eeed9d857de0d17c53bfab0 | train | class | class VisibleAppsOfUserInvitationEndpoint(IDEndpoint):
path = '/v1/userInvitations/{id}/visibleApps'
def fields(self, *, app: Union[AppField, list[AppField]]=None) -> VisibleAppsOfUserInvitationEndpoint:
'''Fields to return for included related types.
:param app: the fields to include for retu... | class VisibleAppsOfUserInvitationEndpoint(IDEndpoint):
| path = '/v1/userInvitations/{id}/visibleApps'
def fields(self, *, app: Union[AppField, list[AppField]]=None) -> VisibleAppsOfUserInvitationEndpoint:
'''Fields to return for included related types.
:param app: the fields to include for returned resources of type apps
:type app: Union[Ap... | .ErrorResponse`: if a error reponse returned.
:py:class:`requests.RequestException`: if a connection or a HTTP error occurred.
'''
json = super()._perform_get()
return UserInvitationResponse.parse_obj(json)
def delete(self):
'''Delete the resource.
:raises:... | 105 | 105 | 353 | 10 | 95 | codinn/applaud | applaud/endpoints/user_invitations.py | Python | VisibleAppsOfUserInvitationEndpoint | VisibleAppsOfUserInvitationEndpoint | 188 | 227 | 188 | 188 | c45858ea7ea1c43a7104bdc6b1458a426ba1dcd5 | bigcode/the-stack | train |
b225c33c2a9a4cf880d41336 | train | class | class UserInvitationEndpoint(IDEndpoint):
path = '/v1/userInvitations/{id}'
@endpoint('/v1/userInvitations/{id}/visibleApps')
def visible_apps(self) -> VisibleAppsOfUserInvitationEndpoint:
return VisibleAppsOfUserInvitationEndpoint(self.id, self.session)
def fields(self, *, user_invita... | class UserInvitationEndpoint(IDEndpoint):
| path = '/v1/userInvitations/{id}'
@endpoint('/v1/userInvitations/{id}/visibleApps')
def visible_apps(self) -> VisibleAppsOfUserInvitationEndpoint:
return VisibleAppsOfUserInvitationEndpoint(self.id, self.session)
def fields(self, *, user_invitation: Union[UserInvitationField, list[User... | UserInvitations
:rtype: UserInvitationsResponse
:raises: :py:class:`applaud.schemas.responses.ErrorResponse`: if a error reponse returned.
:py:class:`requests.RequestException`: if a connection or a HTTP error occurred.
'''
json = super()._perform_get()
return U... | 189 | 189 | 632 | 7 | 182 | codinn/applaud | applaud/endpoints/user_invitations.py | Python | UserInvitationEndpoint | UserInvitationEndpoint | 120 | 186 | 120 | 120 | c8683288018fd18b349ad25e6293e64f848191d2 | bigcode/the-stack | train |
3a1a76a2a9bdb7a06f45b9ba | train | class | class UserInvitationsEndpoint(Endpoint):
path = '/v1/userInvitations'
def fields(self, *, user_invitation: Union[UserInvitationField, list[UserInvitationField]]=None, app: Union[AppField, list[AppField]]=None) -> UserInvitationsEndpoint:
'''Fields to return for included related types.
:param u... | class UserInvitationsEndpoint(Endpoint):
| path = '/v1/userInvitations'
def fields(self, *, user_invitation: Union[UserInvitationField, list[UserInvitationField]]=None, app: Union[AppField, list[AppField]]=None) -> UserInvitationsEndpoint:
'''Fields to return for included related types.
:param user_invitation: the fields to include for... | from __future__ import annotations
from .base import Endpoint, IDEndpoint, SortOrder, endpoint
from ..fields import *
from typing import Union
from ..schemas.models import *
from ..schemas.responses import *
from ..schemas.requests import *
from ..schemas.enums import *
class UserInvitationsEndpoint(Endpoint):
| 64 | 256 | 1,077 | 8 | 56 | codinn/applaud | applaud/endpoints/user_invitations.py | Python | UserInvitationsEndpoint | UserInvitationsEndpoint | 10 | 118 | 10 | 10 | 9b86f03413ea584bcd913f90423904e5bde43bbb | bigcode/the-stack | train |
9948fe254ffe6d5f5647d0db | train | class | class PythonProtobufSubsystem(Subsystem):
options_scope = "python-protobuf"
help = f"Options related to the Protobuf Python backend.\n\nSee {docs_url('protobuf')}."
@classmethod
def register_options(cls, register):
super().register_options(register)
register(
"--runtime-depe... | class PythonProtobufSubsystem(Subsystem):
| options_scope = "python-protobuf"
help = f"Options related to the Protobuf Python backend.\n\nSee {docs_url('protobuf')}."
@classmethod
def register_options(cls, register):
super().register_options(register)
register(
"--runtime-dependencies",
type=list,
... | Apache License, Version 2.0 (see LICENSE).
from typing import cast
from pants.backend.codegen.protobuf.target_types import ProtobufDependencies
from pants.engine.addresses import Addresses, UnparsedAddressInputs
from pants.engine.rules import Get, collect_rules, rule
from pants.engine.target import InjectDependencie... | 111 | 111 | 373 | 8 | 102 | cosmicexplorer/pants | src/python/pants/backend/codegen/protobuf/python/python_protobuf_subsystem.py | Python | PythonProtobufSubsystem | PythonProtobufSubsystem | 16 | 64 | 16 | 16 | 5ebdde0192c7b46b428971611e56445eabe4590a | bigcode/the-stack | train |
72a225d5042c5767713b5cd9 | train | class | class InjectPythonProtobufDependencies(InjectDependenciesRequest):
inject_for = ProtobufDependencies
| class InjectPythonProtobufDependencies(InjectDependenciesRequest):
| inject_for = ProtobufDependencies
| )
@property
def mypy_plugin(self) -> bool:
return cast(bool, self.options.mypy_plugin)
@property
def mypy_plugin_version(self) -> str:
return cast(str, self.options.mypy_plugin_version)
class InjectPythonProtobufDependencies(InjectDependenciesRequest):
| 64 | 64 | 19 | 11 | 53 | cosmicexplorer/pants | src/python/pants/backend/codegen/protobuf/python/python_protobuf_subsystem.py | Python | InjectPythonProtobufDependencies | InjectPythonProtobufDependencies | 67 | 68 | 67 | 67 | c2009919a1e43fa79f84650a7ff9b1dca83cfcc0 | bigcode/the-stack | train |
6ff977b2f96825de39a694c5 | train | function | @rule
async def inject_dependencies(
_: InjectPythonProtobufDependencies, python_protobuf: PythonProtobufSubsystem
) -> InjectedDependencies:
addresses = await Get(Addresses, UnparsedAddressInputs, python_protobuf.runtime_dependencies)
return InjectedDependencies(addresses)
| @rule
async def inject_dependencies(
_: InjectPythonProtobufDependencies, python_protobuf: PythonProtobufSubsystem
) -> InjectedDependencies:
| addresses = await Get(Addresses, UnparsedAddressInputs, python_protobuf.runtime_dependencies)
return InjectedDependencies(addresses)
| str:
return cast(str, self.options.mypy_plugin_version)
class InjectPythonProtobufDependencies(InjectDependenciesRequest):
inject_for = ProtobufDependencies
@rule
async def inject_dependencies(
_: InjectPythonProtobufDependencies, python_protobuf: PythonProtobufSubsystem
) -> InjectedDependencies:
| 64 | 64 | 58 | 31 | 32 | cosmicexplorer/pants | src/python/pants/backend/codegen/protobuf/python/python_protobuf_subsystem.py | Python | inject_dependencies | inject_dependencies | 71 | 76 | 71 | 74 | 970eec6fcdae4212a5d51ada5f9448eea6d5e8a2 | bigcode/the-stack | train |
d54d7ac66a448f2eae792605 | train | function | def rules():
return [
*collect_rules(),
UnionRule(InjectDependenciesRequest, InjectPythonProtobufDependencies),
]
| def rules():
| return [
*collect_rules(),
UnionRule(InjectDependenciesRequest, InjectPythonProtobufDependencies),
]
| tobufDependencies
@rule
async def inject_dependencies(
_: InjectPythonProtobufDependencies, python_protobuf: PythonProtobufSubsystem
) -> InjectedDependencies:
addresses = await Get(Addresses, UnparsedAddressInputs, python_protobuf.runtime_dependencies)
return InjectedDependencies(addresses)
def rules():
| 64 | 64 | 27 | 3 | 61 | cosmicexplorer/pants | src/python/pants/backend/codegen/protobuf/python/python_protobuf_subsystem.py | Python | rules | rules | 79 | 83 | 79 | 79 | 0626c3cc92be61ab37b83723bf2797eea21d503e | bigcode/the-stack | train |
20686094f9eb7c7edc49ff34 | train | class | class ReutersParser(HTMLParser):
"""
ReutersParser subclasses HTMLParser and is used to open the SGML
files associated with the Reuters-21578 categorised test collection.
The parser is a generator and will yield a single document at a time.
Since the data will be chunked on parsing, it is necessary... | class ReutersParser(HTMLParser):
| """
ReutersParser subclasses HTMLParser and is used to open the SGML
files associated with the Reuters-21578 categorised test collection.
The parser is a generator and will yield a single document at a time.
Since the data will be chunked on parsing, it is necessary to keep
some internal state... | import html
from pprint import pprint
import re
from HTMLParser import HTMLParser
class ReutersParser(HTMLParser):
| 25 | 230 | 768 | 7 | 17 | marius92mc/Document_Classification | classification/reuters_parser.py | Python | ReutersParser | ReutersParser | 8 | 108 | 8 | 8 | d90ca2ede5397ee450794cabd257af35003b0e58 | bigcode/the-stack | train |
2725130d3c82fefdbc281c3f | train | class | class ActstreamConfig(AppConfig):
name = 'actstream'
def ready(self):
from actstream.actions import action_handler
action.connect(action_handler, dispatch_uid='actstream.models')
action_class = self.get_model('action')
if settings.USE_JSONFIELD and not hasattr(action_class, 'da... | class ActstreamConfig(AppConfig):
| name = 'actstream'
def ready(self):
from actstream.actions import action_handler
action.connect(action_handler, dispatch_uid='actstream.models')
action_class = self.get_model('action')
if settings.USE_JSONFIELD and not hasattr(action_class, 'data'):
from actstream.j... | from django.apps import AppConfig
from actstream import settings
from actstream.signals import action
class ActstreamConfig(AppConfig):
| 28 | 64 | 108 | 7 | 20 | Ganonmaster/django-activity-stream | actstream/apps.py | Python | ActstreamConfig | ActstreamConfig | 7 | 20 | 7 | 7 | b4b4ff5160d7324c46cd74a1aa70fe64777a6713 | bigcode/the-stack | train |
89b324d0949821cf205e1aad | train | class | class SocketInput(Input):
"""
Not complete, but it took an annoyingly long time to get working
so I'm leaving it in for future use.
"""
logger: logging.Logger
host: str
port: int
queue: Optional[InputQueue] = None
def __init__(self) -> None:
super().__init__()
se... | class SocketInput(Input):
| """
Not complete, but it took an annoyingly long time to get working
so I'm leaving it in for future use.
"""
logger: logging.Logger
host: str
port: int
queue: Optional[InputQueue] = None
def __init__(self) -> None:
super().__init__()
self.host = "localhost"
... | import asyncio
import dataclasses
import logging
import socket
from typing import Optional, Set, Type
from mewbot.core import InputEvent, InputQueue
from mewbot.api.v1 import Input
@dataclasses.dataclass # Needed for pycharm linting
class SocketInputEvent(InputEvent):
data: bytes
class SocketInput(Input):
| 75 | 105 | 350 | 5 | 69 | ajCameron/mewbot | src/mewbot/socket_io.py | Python | SocketInput | SocketInput | 17 | 77 | 17 | 17 | 520bd5fbc0aaec0529e5a5aad6c2a4495859d252 | bigcode/the-stack | train |
299f3b4b87e1eb0f5f3fb2b4 | train | class | @dataclasses.dataclass # Needed for pycharm linting
class SocketInputEvent(InputEvent):
data: bytes
| @dataclasses.dataclass # Needed for pycharm linting
class SocketInputEvent(InputEvent):
| data: bytes
| asyncio
import dataclasses
import logging
import socket
from typing import Optional, Set, Type
from mewbot.core import InputEvent, InputQueue
from mewbot.api.v1 import Input
@dataclasses.dataclass # Needed for pycharm linting
class SocketInputEvent(InputEvent):
| 64 | 64 | 26 | 21 | 42 | ajCameron/mewbot | src/mewbot/socket_io.py | Python | SocketInputEvent | SocketInputEvent | 12 | 14 | 12 | 13 | dda7454202261e78f891bdd926020a4569481f66 | bigcode/the-stack | train |
0d381ae9a4fe61e4b831f5cf | train | function | def get_service(group_name: Optional[str] = None,
service_name: Optional[str] = None,
opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetServiceResult:
"""
A Data Migration Service resource
:param str group_name: Name of the resource group
:param str service_na... | def get_service(group_name: Optional[str] = None,
service_name: Optional[str] = None,
opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetServiceResult:
| """
A Data Migration Service resource
:param str group_name: Name of the resource group
:param str service_name: Name of the service
"""
__args__ = dict()
__args__['groupName'] = group_name
__args__['serviceName'] = service_name
if opts is None:
opts = pulumi.InvokeOptions(... | ,
provisioning_state=self.provisioning_state,
public_key=self.public_key,
sku=self.sku,
tags=self.tags,
type=self.type,
virtual_subnet_id=self.virtual_subnet_id)
def get_service(group_name: Optional[str] = None,
service_name: Option... | 86 | 86 | 288 | 42 | 44 | pulumi/pulumi-azure-nextgen | sdk/python/pulumi_azure_nextgen/datamigration/v20180331preview/get_service.py | Python | get_service | get_service | 166 | 196 | 166 | 168 | 92c4671726972dec6536387bd383127774efd331 | bigcode/the-stack | train |
196a915a5a790cba9f82c77c | train | class | @pulumi.output_type
class GetServiceResult:
"""
A Data Migration Service resource
"""
def __init__(__self__, etag=None, id=None, kind=None, location=None, name=None, provisioning_state=None, public_key=None, sku=None, tags=None, type=None, virtual_subnet_id=None):
if etag and not isinstance(etag... | @pulumi.output_type
class GetServiceResult:
| """
A Data Migration Service resource
"""
def __init__(__self__, etag=None, id=None, kind=None, location=None, name=None, provisioning_state=None, public_key=None, sku=None, tags=None, type=None, virtual_subnet_id=None):
if etag and not isinstance(etag, str):
raise TypeError("Expecte... | # coding=utf-8
# *** WARNING: this file was generated by the Pulumi SDK Generator. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union
from ... import _utilities, _tables
from... | 116 | 256 | 1,013 | 11 | 105 | pulumi/pulumi-azure-nextgen | sdk/python/pulumi_azure_nextgen/datamigration/v20180331preview/get_service.py | Python | GetServiceResult | GetServiceResult | 18 | 144 | 18 | 19 | da13c02d3329631b42e9358adf978f7b41ff6dd2 | bigcode/the-stack | train |
81e8baaea2bfcafe3bf43b7f | train | class | class AwaitableGetServiceResult(GetServiceResult):
# pylint: disable=using-constant-test
def __await__(self):
if False:
yield self
return GetServiceResult(
etag=self.etag,
id=self.id,
kind=self.kind,
location=self.location,
... | class AwaitableGetServiceResult(GetServiceResult):
# pylint: disable=using-constant-test
| def __await__(self):
if False:
yield self
return GetServiceResult(
etag=self.etag,
id=self.id,
kind=self.kind,
location=self.location,
name=self.name,
provisioning_state=self.provisioning_state,
public_ke... | (self) -> str:
"""
The ID of the Microsoft.Network/virtualNetworks/subnets resource to which the service should be joined
"""
return pulumi.get(self, "virtual_subnet_id")
class AwaitableGetServiceResult(GetServiceResult):
# pylint: disable=using-constant-test
| 64 | 64 | 112 | 21 | 43 | pulumi/pulumi-azure-nextgen | sdk/python/pulumi_azure_nextgen/datamigration/v20180331preview/get_service.py | Python | AwaitableGetServiceResult | AwaitableGetServiceResult | 147 | 163 | 147 | 148 | b1726c3b1e0ca929127731c07a412495af58d9d8 | bigcode/the-stack | train |
be2897aa3ba53a9e9ba46ece | train | class | @pulumi.output_type
class GetMaintenanceConfigurationResult:
"""
Maintenance configuration record type
"""
def __init__(__self__, extension_properties=None, id=None, location=None, maintenance_scope=None, name=None, namespace=None, tags=None, type=None):
if extension_properties and not isinstanc... | @pulumi.output_type
class GetMaintenanceConfigurationResult:
| """
Maintenance configuration record type
"""
def __init__(__self__, extension_properties=None, id=None, location=None, maintenance_scope=None, name=None, namespace=None, tags=None, type=None):
if extension_properties and not isinstance(extension_properties, dict):
raise TypeError("E... | # coding=utf-8
# *** WARNING: this file was generated by the Pulumi SDK Generator. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union
from ... import _utilities, _tables
__a... | 116 | 216 | 720 | 12 | 104 | pulumi-bot/pulumi-azure-native | sdk/python/pulumi_azure_native/maintenance/v20180601preview/get_maintenance_configuration.py | Python | GetMaintenanceConfigurationResult | GetMaintenanceConfigurationResult | 17 | 110 | 17 | 18 | 7115b7dff7ec488e015ea3372387a1029f797976 | bigcode/the-stack | train |
0e8e94c761ce77c7268d0996 | train | class | class AwaitableGetMaintenanceConfigurationResult(GetMaintenanceConfigurationResult):
# pylint: disable=using-constant-test
def __await__(self):
if False:
yield self
return GetMaintenanceConfigurationResult(
extension_properties=self.extension_properties,
id=se... | class AwaitableGetMaintenanceConfigurationResult(GetMaintenanceConfigurationResult):
# pylint: disable=using-constant-test
| def __await__(self):
if False:
yield self
return GetMaintenanceConfigurationResult(
extension_properties=self.extension_properties,
id=self.id,
location=self.location,
maintenance_scope=self.maintenance_scope,
name=self.name,
... | tags")
@property
@pulumi.getter
def type(self) -> str:
"""
Type of the resource
"""
return pulumi.get(self, "type")
class AwaitableGetMaintenanceConfigurationResult(GetMaintenanceConfigurationResult):
# pylint: disable=using-constant-test
| 64 | 64 | 90 | 23 | 41 | pulumi-bot/pulumi-azure-native | sdk/python/pulumi_azure_native/maintenance/v20180601preview/get_maintenance_configuration.py | Python | AwaitableGetMaintenanceConfigurationResult | AwaitableGetMaintenanceConfigurationResult | 113 | 126 | 113 | 114 | 0efb70f15f2e210f353bc26c9d6c4847459aaa25 | bigcode/the-stack | train |
d01b3d13bbcc969d096e3119 | train | function | def get_maintenance_configuration(resource_group_name: Optional[str] = None,
resource_name: Optional[str] = None,
opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetMaintenanceConfigurationResult:
"""
Maintenance configuration record t... | def get_maintenance_configuration(resource_group_name: Optional[str] = None,
resource_name: Optional[str] = None,
opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetMaintenanceConfigurationResult:
| """
Maintenance configuration record type
:param str resource_group_name: Resource Group Name
:param str resource_name: Resource Identifier
"""
__args__ = dict()
__args__['resourceGroupName'] = resource_group_name
__args__['resourceName'] = resource_name
if opts is None:
op... | =self.location,
maintenance_scope=self.maintenance_scope,
name=self.name,
namespace=self.namespace,
tags=self.tags,
type=self.type)
def get_maintenance_configuration(resource_group_name: Optional[str] = None,
resource_name: Op... | 77 | 77 | 257 | 46 | 31 | pulumi-bot/pulumi-azure-native | sdk/python/pulumi_azure_native/maintenance/v20180601preview/get_maintenance_configuration.py | Python | get_maintenance_configuration | get_maintenance_configuration | 129 | 156 | 129 | 131 | 90f2c590d15d53775bb291dda7b24f90bcb228ad | bigcode/the-stack | train |
7db1ef7b9f59947f154a50e0 | train | class | class DocstatusTransitionError(ValidationError): pass
| class DocstatusTransitionError(ValidationError): | pass
| class CannotChangeConstantError(ValidationError): pass
class CharacterLengthExceededError(ValidationError): pass
class UpdateAfterSubmitError(ValidationError): pass
class LinkValidationError(ValidationError): pass
class CancelledLinkError(LinkValidationError): pass
class DocstatusTransitionError(ValidationError): | 64 | 64 | 11 | 10 | 53 | snehapatil1/frappe | frappe/exceptions.py | Python | DocstatusTransitionError | DocstatusTransitionError | 73 | 73 | 73 | 73 | 4f79557659075231203e3976bc94b9f8a7de5a7e | bigcode/the-stack | train |
256f094cb079be6ecab28172 | train | class | class NameError(Exception):
http_status_code = 409
| class NameError(Exception):
| http_status_code = 409
| http_status_code = 417
class AuthenticationError(Exception):
http_status_code = 401
class SessionExpired(Exception):
http_status_code = 401
class PermissionError(Exception):
http_status_code = 403
class DoesNotExistError(ValidationError):
http_status_code = 404
class NameError(Exception):
| 64 | 64 | 12 | 5 | 58 | snehapatil1/frappe | frappe/exceptions.py | Python | NameError | NameError | 28 | 29 | 28 | 28 | 536ed0f91adf2dff71afbe5256210fc8a9a4531a | bigcode/the-stack | train |
79b165cc16a7498fd6346023 | train | class | class OutgoingEmailError(Exception):
http_status_code = 501
| class OutgoingEmailError(Exception):
| http_status_code = 501
| _code = 401
class SessionExpired(Exception):
http_status_code = 401
class PermissionError(Exception):
http_status_code = 403
class DoesNotExistError(ValidationError):
http_status_code = 404
class NameError(Exception):
http_status_code = 409
class OutgoingEmailError(Exception):
| 64 | 64 | 14 | 7 | 56 | snehapatil1/frappe | frappe/exceptions.py | Python | OutgoingEmailError | OutgoingEmailError | 31 | 32 | 31 | 31 | 7b0608b0b674cc220523300219ab9eed0a49714f | bigcode/the-stack | train |
41e9ab43bbf47bf013fafcff | train | class | class DataError(ValidationError): pass
| class DataError(ValidationError): | pass
| __init__(self, reason, msg=None):
if not msg:
msg = "MariaDb is not properly configured"
super(ImproperDBConfigurationError, self).__init__(msg)
self.reason = reason
class DuplicateEntryError(NameError):pass
class DataError(ValidationError): | 64 | 64 | 9 | 8 | 55 | snehapatil1/frappe | frappe/exceptions.py | Python | DataError | DataError | 61 | 61 | 61 | 61 | 0cd94bc98838b6d614f6cfac7771be4252b996cf | bigcode/the-stack | train |
1eb18417686b0f366b2e3b07 | train | class | class MandatoryError(ValidationError): pass
| class MandatoryError(ValidationError): | pass
| init__(msg)
self.reason = reason
class DuplicateEntryError(NameError):pass
class DataError(ValidationError): pass
class UnknownDomainError(Exception): pass
class MappingMismatchError(ValidationError): pass
class InvalidStatusError(ValidationError): pass
class MandatoryError(ValidationError): | 64 | 64 | 9 | 8 | 55 | snehapatil1/frappe | frappe/exceptions.py | Python | MandatoryError | MandatoryError | 65 | 65 | 65 | 65 | bc6d20c8f1da7082eddc0fd70bd8b02306431110 | bigcode/the-stack | train |
b5bc648596aaee3c31f6cb58 | train | class | class AppNotInstalledError(ValidationError): pass
| class AppNotInstalledError(ValidationError): | pass
| pass
class EmptyTableError(ValidationError): pass
class LinkExistsError(ValidationError): pass
class InvalidEmailAddressError(ValidationError): pass
class TemplateNotFoundError(ValidationError): pass
class UniqueValidationError(ValidationError): pass
class AppNotInstalledError(ValidationError): | 64 | 64 | 11 | 10 | 53 | snehapatil1/frappe | frappe/exceptions.py | Python | AppNotInstalledError | AppNotInstalledError | 80 | 80 | 80 | 80 | 6b92c0b6d31fbbeb4752756745b3539be4d20377 | bigcode/the-stack | train |
2b66b4036dc71def964acc4f | train | class | class CancelledLinkError(LinkValidationError): pass
| class CancelledLinkError(LinkValidationError): | pass
| class RateLimitExceededError(ValidationError): pass
class CannotChangeConstantError(ValidationError): pass
class CharacterLengthExceededError(ValidationError): pass
class UpdateAfterSubmitError(ValidationError): pass
class LinkValidationError(ValidationError): pass
class CancelledLinkError(LinkValidationError): | 64 | 64 | 11 | 10 | 53 | snehapatil1/frappe | frappe/exceptions.py | Python | CancelledLinkError | CancelledLinkError | 72 | 72 | 72 | 72 | 01bdcdd4596802b27a6d5d9ea34dd06a3be5986a | bigcode/the-stack | train |
2a1916211f59194ca70c6fc6 | train | class | class CannotChangeConstantError(ValidationError): pass
| class CannotChangeConstantError(ValidationError): | pass
| (Exception): pass
class MappingMismatchError(ValidationError): pass
class InvalidStatusError(ValidationError): pass
class MandatoryError(ValidationError): pass
class InvalidSignatureError(ValidationError): pass
class RateLimitExceededError(ValidationError): pass
class CannotChangeConstantError(ValidationError): | 64 | 64 | 11 | 10 | 53 | snehapatil1/frappe | frappe/exceptions.py | Python | CannotChangeConstantError | CannotChangeConstantError | 68 | 68 | 68 | 68 | 743457406d1c26e6fbe6dbdf6d92f302e9a7abfa | bigcode/the-stack | train |
d03ce8d451e242d0675d927d | train | class | class CircularLinkingError(ValidationError): pass
| class CircularLinkingError(ValidationError): | pass
| Error): pass
class AppNotInstalledError(ValidationError): pass
class IncorrectSitePath(NotFound): pass
class ImplicitCommitError(ValidationError): pass
class RetryBackgroundJobError(Exception): pass
class DocumentLockedError(ValidationError): pass
class CircularLinkingError(ValidationError): | 64 | 64 | 11 | 10 | 53 | snehapatil1/frappe | frappe/exceptions.py | Python | CircularLinkingError | CircularLinkingError | 85 | 85 | 85 | 85 | 4041ca68601358beb6b6c5a0126c496ff7f5f0cd | bigcode/the-stack | train |
1dc84e121792957f76c82a22 | train | class | class MappingMismatchError(ValidationError): pass
| class MappingMismatchError(ValidationError): | pass
| "MariaDb is not properly configured"
super(ImproperDBConfigurationError, self).__init__(msg)
self.reason = reason
class DuplicateEntryError(NameError):pass
class DataError(ValidationError): pass
class UnknownDomainError(Exception): pass
class MappingMismatchError(ValidationError): | 64 | 64 | 10 | 9 | 54 | snehapatil1/frappe | frappe/exceptions.py | Python | MappingMismatchError | MappingMismatchError | 63 | 63 | 63 | 63 | db22e6df769c7edb4ae32d314a80c75890bfe024 | bigcode/the-stack | train |
3c8939790cdebb110e9c14d3 | train | class | class RetryBackgroundJobError(Exception): pass
| class RetryBackgroundJobError(Exception): | pass
| Error): pass
class TemplateNotFoundError(ValidationError): pass
class UniqueValidationError(ValidationError): pass
class AppNotInstalledError(ValidationError): pass
class IncorrectSitePath(NotFound): pass
class ImplicitCommitError(ValidationError): pass
class RetryBackgroundJobError(Exception): | 64 | 64 | 9 | 8 | 55 | snehapatil1/frappe | frappe/exceptions.py | Python | RetryBackgroundJobError | RetryBackgroundJobError | 83 | 83 | 83 | 83 | 2df57a94b8dac4d978e967f565c6944ec45da6d2 | bigcode/the-stack | train |
7d082e804213fe136f88ce03 | train | class | class DocumentLockedError(ValidationError): pass
| class DocumentLockedError(ValidationError): | pass
| ValidationError): pass
class UniqueValidationError(ValidationError): pass
class AppNotInstalledError(ValidationError): pass
class IncorrectSitePath(NotFound): pass
class ImplicitCommitError(ValidationError): pass
class RetryBackgroundJobError(Exception): pass
class DocumentLockedError(ValidationError): | 64 | 64 | 10 | 9 | 54 | snehapatil1/frappe | frappe/exceptions.py | Python | DocumentLockedError | DocumentLockedError | 84 | 84 | 84 | 84 | 15955cbb2cb813d718e6b13d1e6a01e8a7e892b0 | bigcode/the-stack | train |
251ab41cc7e8ef3a23143870 | train | class | class ValidationError(Exception):
http_status_code = 417
| class ValidationError(Exception):
| http_status_code = 417
| from __future__ import unicode_literals
# BEWARE don't put anything in this file except exceptions
from werkzeug.exceptions import NotFound
# imports - third-party imports
from pymysql import ProgrammingError as SQLError, Error
# from pymysql import OperationalError as DatabaseOperationalError
class ValidationError(E... | 64 | 64 | 12 | 5 | 58 | snehapatil1/frappe | frappe/exceptions.py | Python | ValidationError | ValidationError | 13 | 14 | 13 | 13 | 1e6067adc57115b7ec5dd93b9730f206d7294431 | bigcode/the-stack | train |
c24f1474c7bc27363f7c68f5 | train | class | class IncorrectSitePath(NotFound): pass
| class IncorrectSitePath(NotFound): | pass
| ): pass
class LinkExistsError(ValidationError): pass
class InvalidEmailAddressError(ValidationError): pass
class TemplateNotFoundError(ValidationError): pass
class UniqueValidationError(ValidationError): pass
class AppNotInstalledError(ValidationError): pass
class IncorrectSitePath(NotFound): | 64 | 64 | 9 | 8 | 55 | snehapatil1/frappe | frappe/exceptions.py | Python | IncorrectSitePath | IncorrectSitePath | 81 | 81 | 81 | 81 | eabc0d08db46253f7753f7f3794ab08fdb230cb6 | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.