project_name stringlengths 6 104 | file_name stringlengths 4 89 | full_name stringlengths 1 102 | func_name stringlengths 1 85 | docstring stringlengths 13 836 | docstring_tokens listlengths 4 122 | code stringlengths 23 39.7k | code_tokens stringlengths 29 44.6k | url int64 3 986k |
|---|---|---|---|---|---|---|---|---|
deepmind/xmanager | kubernetes.py | annotations_from_executor | annotations_from_executor | Get Pod annotations from the executor for TPUs. | [
"Get",
"Pod",
"annotations",
"from",
"the",
"executor",
"for",
"TPUs."
] | def annotations_from_executor(executor: local_executors.Kubernetes) -> Dict[str, str]:
if executor.cloud_provider != local_executors.GOOGLE_KUBERNETES_ENGINE_CLOUD_PROVIDER:
return {}
if executor.requirements.accelerator in xm.TpuType:
tpu_runtime_version = 'nightly'
if executor.tpu_capa... | ['def', 'annotations_from_executor(executor:', 'local_executors.Kubernetes)', '->', 'Dict[str,', 'str]:', 'if', 'executor.cloud_provider', '!=', 'local_executors.GOOGLE_KUBERNETES_ENGINE_CLOUD_PROVIDER:', 'return', '{}', 'if', 'executor.requirements.accelerator', 'in', 'xm.TpuType:', 'tpu_runtime_version', '=', "'night... | 968,710 |
deepmind/xmanager | utils.py | get_world_size_rank | get_world_size_rank | Get the world size and rank of the current replica from CLUSTER_SPEC. | [
"Get",
"the",
"world",
"size",
"and",
"rank",
"of",
"the",
"current",
"replica",
"from",
"CLUSTER_SPEC."
] | def get_world_size_rank() -> Tuple[int, int]:
cluster_spec = os.environ.get('CLUSTER_SPEC', None)
if not cluster_spec:
return (1, 0)
cluster_spec = json.loads(cluster_spec)
world_size = 0
for pool in cluster_spec['cluster']:
if pool == cluster_spec['task']['type']:
rank =... | ['def', 'get_world_size_rank()', '->', 'Tuple[int,', 'int]:', 'cluster_spec', '=', "os.environ.get('CLUSTER_SPEC',", 'None)', 'if', 'not', 'cluster_spec:', 'return', '(1,', '0)', 'cluster_spec', '=', 'json.loads(cluster_spec)', 'world_size', '=', '0', 'for', 'pool', 'in', "cluster_spec['cluster']:", 'if', 'pool', '==',... | 968,714 |
deepmind/xmanager | utils.py | create_cluster_specs | create_cluster_specs | Takes a list of domain names and constructs a CLUSTER_SPEC for each. | [
"Takes",
"a",
"list",
"of",
"domain",
"names",
"and",
"constructs",
"a",
"CLUSTER_SPEC",
"for",
"each."
] | def create_cluster_specs(workers: Sequence[str]) -> List[str]:
cluster = {}
for (i, domain) in enumerate(workers):
cluster[f'workerpool{i}'] = [domain]
specs = []
for i in range(len(workers)):
spec = {'cluster': cluster, 'task': {'type': f'workerpool{i}', 'index': i}}
specs.appen... | ['def', 'create_cluster_specs(workers:', 'Sequence[str])', '->', 'List[str]:', 'cluster', '=', '{}', 'for', '(i,', 'domain)', 'in', 'enumerate(workers):', "cluster[f'workerpool{i}']", '=', '[domain]', 'specs', '=', '[]', 'for', 'i', 'in', 'range(len(workers)):', 'spec', '=', "{'cluster':", 'cluster,', "'task':", "{'typ... | 968,715 |
deepmind/xmanager | utils.py | map_workerpool_address_args | map_workerpool_address_args | Maps late-binding to workerpool addresses at runtime. | [
"Maps",
"late-binding",
"to",
"workerpool",
"addresses",
"at",
"runtime."
] | def map_workerpool_address_args(args: List[str]) -> List[str]:
cluster_spec = os.environ.get('CLUSTER_SPEC')
if cluster_spec is None:
return args
late_bind_regex = re.compile('\\%objectname\\((.*)\\)\\%')
cluster_spec = json.loads(cluster_spec)['cluster']
result = []
for arg in args:
... | ['def', 'map_workerpool_address_args(args:', 'List[str])', '->', 'List[str]:', 'cluster_spec', '=', "os.environ.get('CLUSTER_SPEC')", 'if', 'cluster_spec', 'is', 'None:', 'return', 'args', 'late_bind_regex', '=', "re.compile('\\\\%objectname\\\\((.*)\\\\)\\\\%')", 'cluster_spec', '=', "json.loads(cluster_spec)['cluster... | 968,717 |
deepmind/xmanager | utils.py | create_workerpool_address_env_vars_script | create_workerpool_address_env_vars_script | Create a script to map late-binding env vars to their value at runtime. | [
"Create",
"a",
"script",
"to",
"map",
"late-binding",
"env",
"vars",
"to",
"their",
"value",
"at",
"runtime."
] | def create_workerpool_address_env_vars_script(path: str) -> None:
with open(path, 'w') as f:
f.write('#!/bin/bash\n\n')
cluster_spec = os.environ.get('CLUSTER_SPEC', None)
if cluster_spec is None:
return
content = []
late_bind_regex = re.compile('\\%objectname\\((.*)\\)\\%')
clus... | ['def', 'create_workerpool_address_env_vars_script(path:', 'str)', '->', 'None:', 'with', 'open(path,', "'w')", 'as', 'f:', "f.write('#!/bin/bash\\n\\n')", 'cluster_spec', '=', "os.environ.get('CLUSTER_SPEC',", 'None)', 'if', 'cluster_spec', 'is', 'None:', 'return', 'content', '=', '[]', 'late_bind_regex', '=', "re.com... | 968,718 |
deepmind/xmanager | vertex.py | get_machine_spec | get_machine_spec | Get the GCP machine type that best matches the Job's requirements. | [
"Get",
"the",
"GCP",
"machine",
"type",
"that",
"best",
"matches",
"the",
"Job's",
"requirements."
] | def get_machine_spec(job: xm.Job) -> Dict[str, Any]:
assert isinstance(job.executor, local_executors.Vertex)
requirements = job.executor.requirements
spec = {}
for (resource, value) in requirements.task_requirements.items():
accelerator_type = None
if resource in xm.GpuType:
... | ['def', 'get_machine_spec(job:', 'xm.Job)', '->', 'Dict[str,', 'Any]:', 'assert', 'isinstance(job.executor,', 'local_executors.Vertex)', 'requirements', '=', 'job.executor.requirements', 'spec', '=', '{}', 'for', '(resource,', 'value)', 'in', 'requirements.task_requirements.items():', 'accelerator_type', '=', 'None', '... | 968,721 |
deepmind/xmanager | vertex.py | launch | launch | Launch Vertex jobs in the job_group and return a handler. | [
"Launch",
"Vertex",
"jobs",
"in",
"the",
"job_group",
"and",
"return",
"a",
"handler."
] | def launch(experiment_title: str, work_unit_name: str, job_group: xm.JobGroup) -> List[VertexHandle]:
jobs = xm.job_operators.collect_jobs_by_filter(job_group, _vertex_job_predicate)
if not jobs:
return []
job_name = get_default_client().launch(name=f'{experiment_title}_{work_unit_name}', jobs=jobs)... | ['def', 'launch(experiment_title:', 'str,', 'work_unit_name:', 'str,', 'job_group:', 'xm.JobGroup)', '->', 'List[VertexHandle]:', 'jobs', '=', 'xm.job_operators.collect_jobs_by_filter(job_group,', '_vertex_job_predicate)', 'if', 'not', 'jobs:', 'return', '[]', 'job_name', '=', "get_default_client().launch(name=f'{exper... | 968,722 |
deepmind/xmanager | vertex.py | cpu_ram_to_machine_type | cpu_ram_to_machine_type | Convert a cpu and memory spec into a machine type. | [
"Convert",
"a",
"cpu",
"and",
"memory",
"spec",
"into",
"a",
"machine",
"type."
] | def cpu_ram_to_machine_type(cpu: Optional[int], ram: Optional[int]) -> str:
cpu = cpu or 0
ram = ram or 0
if cpu + ram == 0:
return 'n1-standard-4'
optimal_machine_type = ''
optimal_excess_resources = math.inf
for (machine_type, (machine_cpu, machine_ram)) in _MACHINE_TYPE_TO_CPU_RAM.ite... | ['def', 'cpu_ram_to_machine_type(cpu:', 'Optional[int],', 'ram:', 'Optional[int])', '->', 'str:', 'cpu', '=', 'cpu', 'or', '0', 'ram', '=', 'ram', 'or', '0', 'if', 'cpu', '+', 'ram', '==', '0:', 'return', "'n1-standard-4'", 'optimal_machine_type', '=', "''", 'optimal_excess_resources', '=', 'math.inf', 'for', '(machine... | 968,723 |
deepmind/xmanager | vertex.py | Client.launch | launch | Launch jobs on AI Platform (Unified). | [
"Launch",
"jobs",
"on",
"AI",
"Platform",
"(Unified)."
] | def launch(self, name: str, jobs: Sequence[xm.Job]) -> str:
pools = []
(tensorboard, output_dir) = self.get_tensorboard_settings(jobs)
for (i, job) in enumerate(jobs):
executable = job.executable
if not isinstance(executable, local_executables.GoogleContainerRegistryImage):
raise... | ['def', 'launch(self,', 'name:', 'str,', 'jobs:', 'Sequence[xm.Job])', '->', 'str:', 'pools', '=', '[]', '(tensorboard,', 'output_dir)', '=', 'self.get_tensorboard_settings(jobs)', 'for', '(i,', 'job)', 'in', 'enumerate(jobs):', 'executable', '=', 'job.executable', 'if', 'not', 'isinstance(executable,', 'local_executab... | 968,724 |
deepmind/xmanager | vertex.py | Client.get_tensorboard_settings | get_tensorboard_settings | Get the tensorboard settings for a sequence of Jobs. | [
"Get",
"the",
"tensorboard",
"settings",
"for",
"a",
"sequence",
"of",
"Jobs."
] | def get_tensorboard_settings(self, jobs: Sequence[xm.Job]) -> Tuple[str, str]:
executors = []
for job in jobs:
assert isinstance(job.executor, local_executors.Vertex)
executors.append(job.executor)
if all((not executor.tensorboard for executor in executors)):
return ('', '')
if n... | ['def', 'get_tensorboard_settings(self,', 'jobs:', 'Sequence[xm.Job])', '->', 'Tuple[str,', 'str]:', 'executors', '=', '[]', 'for', 'job', 'in', 'jobs:', 'assert', 'isinstance(job.executor,', 'local_executors.Vertex)', 'executors.append(job.executor)', 'if', 'all((not', 'executor.tensorboard', 'for', 'executor', 'in', ... | 968,725 |
deepmind/xmanager | addressing.py | k8s_pod_domain | k8s_pod_domain | Returns the Kubernetes pod address of a job. | [
"Returns",
"the",
"Kubernetes",
"pod",
"address",
"of",
"a",
"job."
] | def k8s_pod_domain(job_name: str, experiment_id: int, work_unit_id: int, service: str='experiments', namespace: str='default') -> str:
return f'{experiment_id}-{work_unit_id}-{job_name}.{service}.{namespace}.svc.cluster.local:2222' | ['def', 'k8s_pod_domain(job_name:', 'str,', 'experiment_id:', 'int,', 'work_unit_id:', 'int,', 'service:', "str='experiments',", 'namespace:', "str='default')", '->', 'str:', 'return', "f'{experiment_id}-{work_unit_id}-{job_name}.{service}.{namespace}.svc.cluster.local:2222'"] | 968,726 |
deepmind/xmanager | executor_selector.py | create_experiment | create_experiment | Creates an experiment depending on the launch mode. | [
"Creates",
"an",
"experiment",
"depending",
"on",
"the",
"launch",
"mode."
] | def create_experiment(experiment_title: Optional[str]=None, mode: Optional[XMLaunchMode]=None) -> xm.Experiment:
if mode is None:
mode = launch_mode()
if mode in (XMLaunchMode.LOCAL, XMLaunchMode.INTERACTIVE, XMLaunchMode.VERTEX):
return xm_local.create_experiment(experiment_title)
raise Val... | ['def', 'create_experiment(experiment_title:', 'Optional[str]=None,', 'mode:', 'Optional[XMLaunchMode]=None)', '->', 'xm.Experiment:', 'if', 'mode', 'is', 'None:', 'mode', '=', 'launch_mode()', 'if', 'mode', 'in', '(XMLaunchMode.LOCAL,', 'XMLaunchMode.INTERACTIVE,', 'XMLaunchMode.VERTEX):', 'return', 'xm_local.create_e... | 968,728 |
deepmind/xmanager | gcs.py | get_gcs_path_or_fail | get_gcs_path_or_fail | Returns value passed in the --xm_gcs_path flag; fails if nothing is passed. | [
"Returns",
"value",
"passed",
"in",
"the",
"--xm_gcs_path",
"flag;",
"fails",
"if",
"nothing",
"is",
"passed."
] | def get_gcs_path_or_fail(project_name: str) -> str:
if not _GCS_PATH.value:
raise app.UsageError('--xm_gcs_path is missing. Suggestion: ' + f'--xm_gcs_path={suggestion(project_name)}')
elif not is_gcs_path(_GCS_PATH.value):
raise app.UsageError('--xm_gcs_path not in gs://bucket/directory or /gcs... | ['def', 'get_gcs_path_or_fail(project_name:', 'str)', '->', 'str:', 'if', 'not', '_GCS_PATH.value:', 'raise', "app.UsageError('--xm_gcs_path", 'is', 'missing.', 'Suggestion:', "'", '+', "f'--xm_gcs_path={suggestion(project_name)}')", 'elif', 'not', 'is_gcs_path(_GCS_PATH.value):', 'raise', "app.UsageError('--xm_gcs_pat... | 968,733 |
deepmind/xmanager | gcs.py | is_gs_path | is_gs_path | Given the path, checks whether it is a valid Google Storage URL. | [
"Given",
"the",
"path,",
"checks",
"whether",
"it",
"is",
"a",
"valid",
"Google",
"Storage",
"URL."
] | def is_gs_path(path: str) -> bool:
return path.startswith(_GS_PREFIX) | ['def', 'is_gs_path(path:', 'str)', '->', 'bool:', 'return', 'path.startswith(_GS_PREFIX)'] | 968,734 |
deepmind/xmanager | gcs.py | is_gcs_fuse_path | is_gcs_fuse_path | Given the path, checks whether it is a valid gcs_fuse path. | [
"Given",
"the",
"path,",
"checks",
"whether",
"it",
"is",
"a",
"valid",
"gcs_fuse",
"path."
] | def is_gcs_fuse_path(path: str) -> bool:
return path.startswith(_GCS_PREFIX) | ['def', 'is_gcs_fuse_path(path:', 'str)', '->', 'bool:', 'return', 'path.startswith(_GCS_PREFIX)'] | 968,735 |
deepmind/xmanager | gcs.py | get_gcs_url | get_gcs_url | Given the GCS path, provides a GCS URL to access it. | [
"Given",
"the",
"GCS",
"path,",
"provides",
"a",
"GCS",
"URL",
"to",
"access",
"it."
] | def get_gcs_url(path: str) -> str:
no_prefix = _gcs_path_no_prefix(path)
return f'{gcp_website_url}/storage/browser/{no_prefix}' | ['def', 'get_gcs_url(path:', 'str)', '->', 'str:', 'no_prefix', '=', '_gcs_path_no_prefix(path)', 'return', "f'{gcp_website_url}/storage/browser/{no_prefix}'"] | 968,737 |
deepmind/xmanager | tensorboard.py | add_tensorboard | add_tensorboard | Self-contained function which adds a Tensorboard auxiliary job to @experiment. | [
"Self-contained",
"function",
"which",
"adds",
"a",
"Tensorboard",
"auxiliary",
"job",
"to",
"@experiment."
] | def add_tensorboard(experiment: xm.Experiment, logdir: str, executor: xm.Executor, timeout_secs: int=60 * 60 * 24, args: Optional[Mapping[str, Any]]=None) -> None:
provider = TensorboardProvider
[executable] = experiment.package([xm.Packageable(provider.get_tensorboard_packageable(timeout_secs=timeout_secs), ex... | ['def', 'add_tensorboard(experiment:', 'xm.Experiment,', 'logdir:', 'str,', 'executor:', 'xm.Executor,', 'timeout_secs:', 'int=60', '*', '60', '*', '24,', 'args:', 'Optional[Mapping[str,', 'Any]]=None)', '->', 'None:', 'provider', '=', 'TensorboardProvider', '[executable]', '=', 'experiment.package([xm.Packageable(prov... | 968,741 |
deepmind/xmanager | tensorboard.py | TensorboardProvider.get_tensorboard_packageable | get_tensorboard_packageable | Creates container spec running TensorBoard server. | [
"Creates",
"container",
"spec",
"running",
"TensorBoard",
"server."
] | def get_tensorboard_packageable(timeout_secs: int) -> xm.PythonContainer:
if timeout_secs < 0:
raise RuntimeError('`timeout_secs` must be a nonnegative number')
return xm.PythonContainer(base_image='tensorflow/tensorflow', entrypoint=xm.CommandList([f'timeout {timeout_secs}s tensorboard'])) | ['def', 'get_tensorboard_packageable(timeout_secs:', 'int)', '->', 'xm.PythonContainer:', 'if', 'timeout_secs', '<', '0:', 'raise', "RuntimeError('`timeout_secs`", 'must', 'be', 'a', 'nonnegative', "number')", 'return', "xm.PythonContainer(base_image='tensorflow/tensorflow',", "entrypoint=xm.CommandList([f'timeout", '{... | 968,742 |
deepmind/xmanager | xm_tensorflow.py | MultiWorkerMirroredStrategyBuilder.create_kubernetes_job_group | create_kubernetes_job_group | Builds a Kubernetes job group that can be added to an experiment. | [
"Builds",
"a",
"Kubernetes",
"job",
"group",
"that",
"can",
"be",
"added",
"to",
"an",
"experiment."
] | def create_kubernetes_job_group(self, work_unit: xm.WorkUnit, hparams: xm.UserArgs) -> xm.JobGroup:
assert isinstance(self.worker_executor, xm_local.Kubernetes)
worker_job_domains = {}
for i in range(self.num_workers):
job_name = f'{self.worker_name}-{i}'
worker_job_domains[job_name] = addre... | ['def', 'create_kubernetes_job_group(self,', 'work_unit:', 'xm.WorkUnit,', 'hparams:', 'xm.UserArgs)', '->', 'xm.JobGroup:', 'assert', 'isinstance(self.worker_executor,', 'xm_local.Kubernetes)', 'worker_job_domains', '=', '{}', 'for', 'i', 'in', 'range(self.num_workers):', 'job_name', '=', "f'{self.worker_name}-{i}'", ... | 968,745 |
deepmind/xmanager | docker_adapter.py | DockerAdapter.run_container_client | run_container_client | Runs a given container image using Python Docker client. | [
"Runs",
"a",
"given",
"container",
"image",
"using",
"Python",
"Docker",
"client."
] | def run_container_client(self, name: str, image_id: str, args: Sequence[str], env_vars: Mapping[str, str], network: str, ports: Ports, volumes: Dict[str, str], gpu_count: int) -> containers.Container:
make_mount = lambda guest: {'bind': guest, 'mode': 'rw'}
device_requests = [types.DeviceRequest(count=gpu_count... | ['def', 'run_container_client(self,', 'name:', 'str,', 'image_id:', 'str,', 'args:', 'Sequence[str],', 'env_vars:', 'Mapping[str,', 'str],', 'network:', 'str,', 'ports:', 'Ports,', 'volumes:', 'Dict[str,', 'str],', 'gpu_count:', 'int)', '->', 'containers.Container:', 'make_mount', '=', 'lambda', 'guest:', "{'bind':", '... | 968,750 |
deepmind/xmanager | vizier_controller.py | VizierController.run | run | Peridically check and sync status between vizier and work units and create new work units when needed. | [
"Peridically",
"check",
"and",
"sync",
"status",
"between",
"vizier",
"and",
"work",
"units",
"and",
"create",
"new",
"work",
"units",
"when",
"needed."
] | def run(self, poll_frequency_in_sec: float=60) -> None:
while True:
for work_unit_updater in self._work_unit_updaters:
if not work_unit_updater.completed:
work_unit_updater.check_for_completion()
num_exisiting_work_units = len(self._work_unit_updaters)
num_complet... | ['def', 'run(self,', 'poll_frequency_in_sec:', 'float=60)', '->', 'None:', 'while', 'True:', 'for', 'work_unit_updater', 'in', 'self._work_unit_updaters:', 'if', 'not', 'work_unit_updater.completed:', 'work_unit_updater.check_for_completion()', 'num_exisiting_work_units', '=', 'len(self._work_unit_updaters)', 'num_comp... | 968,752 |
deepmind/xmanager | vizier_controller.py | WorkUnitVizierUpdater.check_for_completion | check_for_completion | Sync the completion status between WorkUnit and Vizier Trial if needed. | [
"Sync",
"the",
"completion",
"status",
"between",
"WorkUnit",
"and",
"Vizier",
"Trial",
"if",
"needed."
] | def check_for_completion(self) -> None:
if self.completed:
return
print(f'Start completion check for work unit {self._work_unit.work_unit_id}.\n')
if not self.work_unit_status().is_active:
self._complete_trial(self._trial)
self.completed = True
elif self._vz_client.check_trial_ea... | ['def', 'check_for_completion(self)', '->', 'None:', 'if', 'self.completed:', 'return', "print(f'Start", 'completion', 'check', 'for', 'work', 'unit', "{self._work_unit.work_unit_id}.\\n')", 'if', 'not', 'self.work_unit_status().is_active:', 'self._complete_trial(self._trial)', 'self.completed', '=', 'True', 'elif', 's... | 968,753 |
deepmind/xmanager | vizier_worker.py | VizierWorker.add_trial_measurement | add_trial_measurement | Add trial measurements to Vizier. | [
"Add",
"trial",
"measurements",
"to",
"Vizier."
] | def add_trial_measurement(self, step: int, metrics: Dict[str, float]) -> None:
self._vz_client.add_trial_measurement(request=aip.AddTrialMeasurementRequest(trial_name=self._trial_name, measurement=aip.Measurement(step_count=step, metrics=[aip.Measurement.Metric(metric_id=k, value=v) for (k, v) in metrics.items()]))... | ['def', 'add_trial_measurement(self,', 'step:', 'int,', 'metrics:', 'Dict[str,', 'float])', '->', 'None:', 'self._vz_client.add_trial_measurement(request=aip.AddTrialMeasurementRequest(trial_name=self._trial_name,', 'measurement=aip.Measurement(step_count=step,', 'metrics=[aip.Measurement.Metric(metric_id=k,', 'value=v... | 968,754 |
deepmind/xmanager | async_packager.py | AsyncPackager.add | add | Adds new packageable to the batch. | [
"Adds",
"new",
"packageable",
"to",
"the",
"batch."
] | def add(self, packageable: job_blocks.Packageable) -> Awaitable[job_blocks.Executable]:
with self._lock:
future = concurrent_futures.Future()
self._packageables.append(packageable)
self._futures.append(future)
def check_is_packaged() -> None:
with self._lock:
if pack... | ['def', 'add(self,', 'packageable:', 'job_blocks.Packageable)', '->', 'Awaitable[job_blocks.Executable]:', 'with', 'self._lock:', 'future', '=', 'concurrent_futures.Future()', 'self._packageables.append(packageable)', 'self._futures.append(future)', 'def', 'check_is_packaged()', '->', 'None:', 'with', 'self._lock:', 'i... | 968,755 |
deepmind/xmanager | id_predictor.py | Predictor.reserve_id | reserve_id | Returns the next ID. | [
"Returns",
"the",
"next",
"ID."
] | def reserve_id(self) -> int:
with self._next_id_lock:
next_id = self._next_id
self._next_id += 1
return next_id | ['def', 'reserve_id(self)', '->', 'int:', 'with', 'self._next_id_lock:', 'next_id', '=', 'self._next_id', 'self._next_id', '+=', '1', 'return', 'next_id'] | 968,758 |
deepmind/xmanager | packagables.py | python_container | python_container | PythonContainer describes a directory containing Python code. | [
"PythonContainer",
"describes",
"a",
"directory",
"containing",
"Python",
"code."
] | def python_container(executor_spec: job_blocks.ExecutorSpec, entrypoint: Union[executables.ModuleName, executables.CommandList], path: str='.', base_image: Optional[str]=None, docker_instructions: Optional[List[str]]=None, use_deep_module: bool=False, *, args: Optional[job_blocks.UserArgs]=None, env_vars: Mapping[str, ... | ['def', 'python_container(executor_spec:', 'job_blocks.ExecutorSpec,', 'entrypoint:', 'Union[executables.ModuleName,', 'executables.CommandList],', 'path:', "str='.',", 'base_image:', 'Optional[str]=None,', 'docker_instructions:', 'Optional[List[str]]=None,', 'use_deep_module:', 'bool=False,', '*,', 'args:', 'Optional[... | 968,764 |
deepmind/xmanager | packagables_generator.py | generate_docstring | generate_docstring | Returns a docstring for a ExecutableSpec factory method. | [
"Returns",
"a",
"docstring",
"for",
"a",
"ExecutableSpec",
"factory",
"method."
] | def generate_docstring(executable: Type[job_blocks.ExecutableSpec]) -> str:
docstring = executable.__doc__
if _ATTRIBUTES_SECTION_HEADER not in docstring:
raise Exception(f'Please add Attributes: section to {executable.__name__} docstring.')
docstring = re.sub(_ATTRIBUTES_SECTION_HEADER, _ARGS_DOCST... | ['def', 'generate_docstring(executable:', 'Type[job_blocks.ExecutableSpec])', '->', 'str:', 'docstring', '=', 'executable.__doc__', 'if', '_ATTRIBUTES_SECTION_HEADER', 'not', 'in', 'docstring:', 'raise', "Exception(f'Please", 'add', 'Attributes:', 'section', 'to', '{executable.__name__}', "docstring.')", 'docstring', '... | 968,766 |
deepmind/xmanager | packagables_generator.py | generate_factory_parameters | generate_factory_parameters | Returns ExecutableSpec factory method parameters definition. | [
"Returns",
"ExecutableSpec",
"factory",
"method",
"parameters",
"definition."
] | def generate_factory_parameters(parameters: List[inspect.Parameter]) -> str:
source = ' executor_spec: job_blocks.ExecutorSpec,\n'
keyword_args_started = False
for parameter in parameters:
if parameter.kind == inspect.Parameter.KEYWORD_ONLY and (not keyword_args_started):
keyword_args... | ['def', 'generate_factory_parameters(parameters:', 'List[inspect.Parameter])', '->', 'str:', 'source', '=', "'", 'executor_spec:', "job_blocks.ExecutorSpec,\\n'", 'keyword_args_started', '=', 'False', 'for', 'parameter', 'in', 'parameters:', 'if', 'parameter.kind', '==', 'inspect.Parameter.KEYWORD_ONLY', 'and', '(not',... | 968,767 |
deepmind/xmanager | database.py | db_settings | db_settings | Returns connection settings created based on DB configuration. | [
"Returns",
"connection",
"settings",
"created",
"based",
"on",
"DB",
"configuration."
] | def db_settings() -> SqlConnectionSettings:
if _db_config():
return SqlConnectionSettings(**_db_config()['sql_connection_settings'])
return sqlite_settings() | ['def', 'db_settings()', '->', 'SqlConnectionSettings:', 'if', '_db_config():', 'return', "SqlConnectionSettings(**_db_config()['sql_connection_settings'])", 'return', 'sqlite_settings()'] | 968,770 |
deepmind/xmanager | database.py | database | database | Returns database based on DB configuration. | [
"Returns",
"database",
"based",
"on",
"DB",
"configuration."
] | def database() -> Database:
return Database(db_connector(), db_settings()) | ['def', 'database()', '->', 'Database:', 'return', 'Database(db_connector(),', 'db_settings())'] | 968,771 |
deepmind/xmanager | database.py | Database.maybe_migrate_database_version | maybe_migrate_database_version | Enforces the latest version of the database to be used. | [
"Enforces",
"the",
"latest",
"version",
"of",
"the",
"database",
"to",
"be",
"used."
] | def maybe_migrate_database_version(self):
db_version = self.database_version()
with self.engine.connect() as connection:
legacy_sqlite_db = self.engine.dialect.has_table(connection, 'VersionHistory')
need_to_update = db_version != self.latest_version_available() and db_version or legacy_sqlite_db
... | ['def', 'maybe_migrate_database_version(self):', 'db_version', '=', 'self.database_version()', 'with', 'self.engine.connect()', 'as', 'connection:', 'legacy_sqlite_db', '=', 'self.engine.dialect.has_table(connection,', "'VersionHistory')", 'need_to_update', '=', 'db_version', '!=', 'self.latest_version_available()', 'a... | 968,773 |
deepmind/xmanager | database.py | Database.get_work_unit | get_work_unit | Gets a work unit from local database. | [
"Gets",
"a",
"work",
"unit",
"from",
"local",
"database."
] | def get_work_unit(self, experiment_id: int, work_unit_id: int) -> WorkUnitResult:
query = text('SELECT job_name, job_data FROM job WHERE experiment_id=:experiment_id AND work_unit_id=:work_unit_id')
rows = self.engine.execute(query, experiment_id=experiment_id, work_unit_id=work_unit_id)
jobs = {}
for r... | ['def', 'get_work_unit(self,', 'experiment_id:', 'int,', 'work_unit_id:', 'int)', '->', 'WorkUnitResult:', 'query', '=', "text('SELECT", 'job_name,', 'job_data', 'FROM', 'job', 'WHERE', 'experiment_id=:experiment_id', 'AND', "work_unit_id=:work_unit_id')", 'rows', '=', 'self.engine.execute(query,', 'experiment_id=exper... | 968,778 |
deepmind/xmanager | __init__.py | MockExperiment.context | context | Returns metadata context for the experiment. | [
"Returns",
"metadata",
"context",
"for",
"the",
"experiment."
] | def context(self) -> MockMetadataContext:
return self._context | ['def', 'context(self)', '->', 'MockMetadataContext:', 'return', 'self._context'] | 968,783 |
MatanBN/XRTransfer | tree.py | Tree.height | height | Get function of the height of this node :return: The height of this node. | [
"Get",
"function",
"of",
"the",
"height",
"of",
"this",
"node",
":return:",
"The",
"height",
"of",
"this",
"node."
] | def height(self):
return self._height | ['def', 'height(self):', 'return', 'self._height'] | 968,865 |
MatanBN/XRTransfer | tree.py | Tree.has_op | has_op | Get function that returns true if this node governs an opinion, else false :return: A boolean to indicate if this node governs an opinion. | [
"Get",
"function",
"that",
"returns",
"true",
"if",
"this",
"node",
"governs",
"an",
"opinion,",
"else",
"false",
":return:",
"A",
"boolean",
"to",
"indicate",
"if",
"this",
"node",
"governs",
"an",
"opinion."
] | def has_op(self):
return self._has_op | ['def', 'has_op(self):', 'return', 'self._has_op'] | 968,868 |
MatanBN/XRTransfer | tree.py | Tree.add_asp | add_asp | Add one to the number of aspects governed by this node. | [
"Add",
"one",
"to",
"the",
"number",
"of",
"aspects",
"governed",
"by",
"this",
"node."
] | def add_asp(self):
self._asp_num += 1 | ['def', 'add_asp(self):', 'self._asp_num', '+=', '1'] | 968,871 |
ultralytics/xview-yolov3 | rectangle.py | Rectangle.is_empty | is_empty | Determines if the Rectangle instance is valid or not. | [
"Determines",
"if",
"the",
"Rectangle",
"instance",
"is",
"valid",
"or",
"not."
] | def is_empty(self):
return self.xmin_ is None or self.ymin_ is None or self.xmax_ is None or (self.ymax_ is None) or (self.xmin_ >= self.xmax_) or (self.ymin_ >= self.ymax_) | ['def', 'is_empty(self):', 'return', 'self.xmin_', 'is', 'None', 'or', 'self.ymin_', 'is', 'None', 'or', 'self.xmax_', 'is', 'None', 'or', '(self.ymax_', 'is', 'None)', 'or', '(self.xmin_', '>=', 'self.xmax_)', 'or', '(self.ymin_', '>=', 'self.ymax_)'] | 968,911 |
ultralytics/xview-yolov3 | rectangle.py | Rectangle.intersect_over_union | intersect_over_union | Returns the intersection over union ratio of this and other rectangle. | [
"Returns",
"the",
"intersection",
"over",
"union",
"ratio",
"of",
"this",
"and",
"other",
"rectangle."
] | def intersect_over_union(self, other):
if not self.intersects(other):
return 0.0
intersect_rect = self.intersect(other)
if intersect_rect.is_empty():
return 0.0
if self.area() == 0 or other.area() == 0:
return 0.0
return intersect_rect.area() / (self.area() + other.area() - i... | ['def', 'intersect_over_union(self,', 'other):', 'if', 'not', 'self.intersects(other):', 'return', '0.0', 'intersect_rect', '=', 'self.intersect(other)', 'if', 'intersect_rect.is_empty():', 'return', '0.0', 'if', 'self.area()', '==', '0', 'or', 'other.area()', '==', '0:', 'return', '0.0', 'return', 'intersect_rect.area... | 968,918 |
stepjam/YARR | prioritized_replay_buffer.py | PrioritizedReplayBuffer.add_final | add_final | Adds a transition to the replay memory. | [
"Adds",
"a",
"transition",
"to",
"the",
"replay",
"memory."
] | def add_final(self, **kwargs):
if self.is_empty() or self._store['terminal'][self.cursor() - 1] != 1:
raise ValueError('The previous transition was not terminal.')
self._check_add_types(kwargs, self._obs_signature)
transition = self._final_transition(kwargs)
for element_type in self._storage_sig... | ['def', 'add_final(self,', '**kwargs):', 'if', 'self.is_empty()', 'or', "self._store['terminal'][self.cursor()", '-', '1]', '!=', '1:', 'raise', "ValueError('The", 'previous', 'transition', 'was', 'not', "terminal.')", 'self._check_add_types(kwargs,', 'self._obs_signature)', 'transition', '=', 'self._final_transition(k... | 968,966 |
stepjam/YARR | prioritized_replay_buffer.py | PrioritizedReplayBuffer.get_transition_elements | get_transition_elements | Returns a 'type signature' for sample_transition_batch. | [
"Returns",
"a",
"'type",
"signature'",
"for",
"sample_transition_batch."
] | def get_transition_elements(self, batch_size=None):
parent_transition_type = super(PrioritizedReplayBuffer, self).get_transition_elements(batch_size)
probablilities_type = [ReplayElement('sampling_probabilities', (batch_size,), np.float32)]
return parent_transition_type + probablilities_type | ['def', 'get_transition_elements(self,', 'batch_size=None):', 'parent_transition_type', '=', 'super(PrioritizedReplayBuffer,', 'self).get_transition_elements(batch_size)', 'probablilities_type', '=', "[ReplayElement('sampling_probabilities',", '(batch_size,),', 'np.float32)]', 'return', 'parent_transition_type', '+', '... | 968,971 |
stepjam/YARR | uniform_replay_buffer.py | UniformReplayBuffer.cursor | cursor | Index to the location where the next transition will be written. | [
"Index",
"to",
"the",
"location",
"where",
"the",
"next",
"transition",
"will",
"be",
"written."
] | def cursor(self):
return self._add_count % self._replay_capacity | ['def', 'cursor(self):', 'return', 'self._add_count', '%', 'self._replay_capacity'] | 968,982 |
stepjam/YARR | uniform_replay_buffer.py | UniformReplayBuffer.get_range | get_range | Returns the range of array at the index handling wraparound if necessary. | [
"Returns",
"the",
"range",
"of",
"array",
"at",
"the",
"index",
"handling",
"wraparound",
"if",
"necessary."
] | def get_range(self, array, start_index, end_index):
assert end_index > start_index, 'end_index must be larger than start_index'
assert end_index >= 0
assert start_index < self._replay_capacity
if not self.is_full():
assert end_index <= self.cursor(), 'Index {} has not been added.'.format(start_i... | ['def', 'get_range(self,', 'array,', 'start_index,', 'end_index):', 'assert', 'end_index', '>', 'start_index,', "'end_index", 'must', 'be', 'larger', 'than', "start_index'", 'assert', 'end_index', '>=', '0', 'assert', 'start_index', '<', 'self._replay_capacity', 'if', 'not', 'self.is_full():', 'assert', 'end_index', '<... | 968,983 |
stepjam/YARR | uniform_replay_buffer.py | UniformReplayBuffer.unpack_transition | unpack_transition | Unpacks the given transition into member variables. | [
"Unpacks",
"the",
"given",
"transition",
"into",
"member",
"variables."
] | def unpack_transition(self, transition_tensors, transition_type):
self.transition = collections.OrderedDict()
for (element, element_type) in zip(transition_tensors, transition_type):
self.transition[element_type.name] = element
return self.transition | ['def', 'unpack_transition(self,', 'transition_tensors,', 'transition_type):', 'self.transition', '=', 'collections.OrderedDict()', 'for', '(element,', 'element_type)', 'in', 'zip(transition_tensors,', 'transition_type):', 'self.transition[element_type.name]', '=', 'element', 'return', 'self.transition'] | 968,987 |
jeffbass/yin-yang-ranch | nodewatcher.py | SystemctlMonitor.imagenode_OK | imagenode_OK | check the imagenode is OK using systemctl status command. | [
"check",
"the",
"imagenode",
"is",
"OK",
"using",
"systemctl",
"status",
"command."
] | def imagenode_OK(self, imagenode):
status = subprocess.run(['ssh', imagenode, self.status_cmd], capture_output=True, text=True)
lines = status.stdout.splitlines()
if lines:
if 'started imagenode service' in lines[-1].lower():
return True
self.log.error('**imagenode error ' + imag... | ['def', 'imagenode_OK(self,', 'imagenode):', 'status', '=', "subprocess.run(['ssh',", 'imagenode,', 'self.status_cmd],', 'capture_output=True,', 'text=True)', 'lines', '=', 'status.stdout.splitlines()', 'if', 'lines:', 'if', "'started", 'imagenode', "service'", 'in', 'lines[-1].lower():', 'return', 'True', "self.log.er... | 968,999 |
heartkilla/yolo-v3 | utils.py | load_images | load_images | Loads images in a 4D array. | [
"Loads",
"images",
"in",
"a",
"4D",
"array."
] | def load_images(img_names, model_size):
imgs = []
for img_name in img_names:
img = Image.open(img_name)
img = img.resize(size=model_size)
img = np.array(img, dtype=np.float32)
img = np.expand_dims(img[:, :, :3], axis=0)
imgs.append(img)
imgs = np.concatenate(imgs)
... | ['def', 'load_images(img_names,', 'model_size):', 'imgs', '=', '[]', 'for', 'img_name', 'in', 'img_names:', 'img', '=', 'Image.open(img_name)', 'img', '=', 'img.resize(size=model_size)', 'img', '=', 'np.array(img,', 'dtype=np.float32)', 'img', '=', 'np.expand_dims(img[:,', ':,', ':3],', 'axis=0)', 'imgs.append(img)', '... | 969,153 |
heartkilla/yolo-v3 | utils.py | load_class_names | load_class_names | Returns a list of class names read from `file_name`. | [
"Returns",
"a",
"list",
"of",
"class",
"names",
"read",
"from",
"`file_name`."
] | def load_class_names(file_name):
with open(file_name, 'r') as f:
class_names = f.read().splitlines()
return class_names | ['def', 'load_class_names(file_name):', 'with', 'open(file_name,', "'r')", 'as', 'f:', 'class_names', '=', 'f.read().splitlines()', 'return', 'class_names'] | 969,154 |
heartkilla/yolo-v3 | yolo_v3.py | darknet53 | darknet53 | Creates Darknet53 model for feature extraction. | [
"Creates",
"Darknet53",
"model",
"for",
"feature",
"extraction."
] | def darknet53(inputs, training, data_format):
inputs = conv2d_fixed_padding(inputs, filters=32, kernel_size=3, data_format=data_format)
inputs = batch_norm(inputs, training=training, data_format=data_format)
inputs = tf.nn.leaky_relu(inputs, alpha=_LEAKY_RELU)
inputs = conv2d_fixed_padding(inputs, filte... | ['def', 'darknet53(inputs,', 'training,', 'data_format):', 'inputs', '=', 'conv2d_fixed_padding(inputs,', 'filters=32,', 'kernel_size=3,', 'data_format=data_format)', 'inputs', '=', 'batch_norm(inputs,', 'training=training,', 'data_format=data_format)', 'inputs', '=', 'tf.nn.leaky_relu(inputs,', 'alpha=_LEAKY_RELU)', '... | 969,160 |
heartkilla/yolo-v3 | yolo_v3.py | yolo_convolution_block | yolo_convolution_block | Creates convolution operations layer used after Darknet. | [
"Creates",
"convolution",
"operations",
"layer",
"used",
"after",
"Darknet."
] | def yolo_convolution_block(inputs, filters, training, data_format):
inputs = conv2d_fixed_padding(inputs, filters=filters, kernel_size=1, data_format=data_format)
inputs = batch_norm(inputs, training=training, data_format=data_format)
inputs = tf.nn.leaky_relu(inputs, alpha=_LEAKY_RELU)
inputs = conv2d_... | ['def', 'yolo_convolution_block(inputs,', 'filters,', 'training,', 'data_format):', 'inputs', '=', 'conv2d_fixed_padding(inputs,', 'filters=filters,', 'kernel_size=1,', 'data_format=data_format)', 'inputs', '=', 'batch_norm(inputs,', 'training=training,', 'data_format=data_format)', 'inputs', '=', 'tf.nn.leaky_relu(inp... | 969,161 |
heartkilla/yolo-v3 | yolo_v3.py | upsample | upsample | Upsamples to `out_shape` using nearest neighbor interpolation. | [
"Upsamples",
"to",
"`out_shape`",
"using",
"nearest",
"neighbor",
"interpolation."
] | def upsample(inputs, out_shape, data_format):
if data_format == 'channels_first':
inputs = tf.transpose(inputs, [0, 2, 3, 1])
new_height = out_shape[3]
new_width = out_shape[2]
else:
new_height = out_shape[2]
new_width = out_shape[1]
inputs = tf.image.resize_nearest_n... | ['def', 'upsample(inputs,', 'out_shape,', 'data_format):', 'if', 'data_format', '==', "'channels_first':", 'inputs', '=', 'tf.transpose(inputs,', '[0,', '2,', '3,', '1])', 'new_height', '=', 'out_shape[3]', 'new_width', '=', 'out_shape[2]', 'else:', 'new_height', '=', 'out_shape[2]', 'new_width', '=', 'out_shape[1]', '... | 969,163 |
heartkilla/yolo-v3 | yolo_v3.py | build_boxes | build_boxes | Computes top left and bottom right points of the boxes. | [
"Computes",
"top",
"left",
"and",
"bottom",
"right",
"points",
"of",
"the",
"boxes."
] | def build_boxes(inputs):
(center_x, center_y, width, height, confidence, classes) = tf.split(inputs, [1, 1, 1, 1, 1, -1], axis=-1)
top_left_x = center_x - width / 2
top_left_y = center_y - height / 2
bottom_right_x = center_x + width / 2
bottom_right_y = center_y + height / 2
boxes = tf.concat([... | ['def', 'build_boxes(inputs):', '(center_x,', 'center_y,', 'width,', 'height,', 'confidence,', 'classes)', '=', 'tf.split(inputs,', '[1,', '1,', '1,', '1,', '1,', '-1],', 'axis=-1)', 'top_left_x', '=', 'center_x', '-', 'width', '/', '2', 'top_left_y', '=', 'center_y', '-', 'height', '/', '2', 'bottom_right_x', '=', 'ce... | 969,164 |
heartkilla/yolo-v3 | yolo_v3.py | non_max_suppression | non_max_suppression | Performs non-max suppression separately for each class. | [
"Performs",
"non-max",
"suppression",
"separately",
"for",
"each",
"class."
] | def non_max_suppression(inputs, n_classes, max_output_size, iou_threshold, confidence_threshold):
batch = tf.unstack(inputs)
boxes_dicts = []
for boxes in batch:
boxes = tf.boolean_mask(boxes, boxes[:, 4] > confidence_threshold)
classes = tf.argmax(boxes[:, 5:], axis=-1)
classes = tf... | ['def', 'non_max_suppression(inputs,', 'n_classes,', 'max_output_size,', 'iou_threshold,', 'confidence_threshold):', 'batch', '=', 'tf.unstack(inputs)', 'boxes_dicts', '=', '[]', 'for', 'boxes', 'in', 'batch:', 'boxes', '=', 'tf.boolean_mask(boxes,', 'boxes[:,', '4]', '>', 'confidence_threshold)', 'classes', '=', 'tf.a... | 969,165 |
ruhyadi/yolo3d-lightning | kitti_dataset.py | KITTIDataset.get_objects | get_objects | Get objects parameter from labels, like dimension and class name. | [
"Get",
"objects",
"parameter",
"from",
"labels,",
"like",
"dimension",
"and",
"class",
"name."
] | def get_objects(self, ids):
objects = []
for id in ids:
with open(self.label_path / f'{id}.txt') as file:
for (line_num, line) in enumerate(file):
line = line[:-1].split(' ')
obj_class = line[0]
if obj_class not in self.class_list:
... | ['def', 'get_objects(self,', 'ids):', 'objects', '=', '[]', 'for', 'id', 'in', 'ids:', 'with', 'open(self.label_path', '/', "f'{id}.txt')", 'as', 'file:', 'for', '(line_num,', 'line)', 'in', 'enumerate(file):', 'line', '=', "line[:-1].split('", "')", 'obj_class', '=', 'line[0]', 'if', 'obj_class', 'not', 'in', 'self.cl... | 969,183 |
ruhyadi/yolo3d-lightning | pylogger.py | get_pylogger | get_pylogger | Initializes multi-GPU-friendly python command line logger. | [
"Initializes",
"multi-GPU-friendly",
"python",
"command",
"line",
"logger."
] | def get_pylogger(name=__name__) -> logging.Logger:
logger = logging.getLogger(name)
logging_levels = ('debug', 'info', 'warning', 'error', 'exception', 'fatal', 'critical')
for level in logging_levels:
setattr(logger, level, rank_zero_only(getattr(logger, level)))
return logger | ['def', 'get_pylogger(name=__name__)', '->', 'logging.Logger:', 'logger', '=', 'logging.getLogger(name)', 'logging_levels', '=', "('debug',", "'info',", "'warning',", "'error',", "'exception',", "'fatal',", "'critical')", 'for', 'level', 'in', 'logging_levels:', 'setattr(logger,', 'level,', 'rank_zero_only(getattr(logg... | 969,205 |
ruhyadi/yolo3d-lightning | utils.py | instantiate_loggers | instantiate_loggers | Instantiates loggers from config. | [
"Instantiates",
"loggers",
"from",
"config."
] | def instantiate_loggers(logger_cfg: DictConfig) -> List[LightningLoggerBase]:
logger: List[LightningLoggerBase] = []
if not logger_cfg:
log.warning('Logger config is empty.')
return logger
if not isinstance(logger_cfg, DictConfig):
raise TypeError('Logger config must be a DictConfig!... | ['def', 'instantiate_loggers(logger_cfg:', 'DictConfig)', '->', 'List[LightningLoggerBase]:', 'logger:', 'List[LightningLoggerBase]', '=', '[]', 'if', 'not', 'logger_cfg:', "log.warning('Logger", 'config', 'is', "empty.')", 'return', 'logger', 'if', 'not', 'isinstance(logger_cfg,', 'DictConfig):', 'raise', "TypeError('... | 969,213 |
hukaixuan19970627/yolov5_obb | rboxs_utils.py | poly2rbox | poly2rbox | Trans poly format to rbox format. | [
"Trans",
"poly",
"format",
"to",
"rbox",
"format."
] | def poly2rbox(polys, num_cls_thata=180, radius=6.0, use_pi=False, use_gaussian=False):
assert polys.shape[-1] == 8
if use_gaussian:
csl_labels = []
rboxes = []
for poly in polys:
poly = np.float32(poly.reshape(4, 2))
((x, y), (w, h), angle) = cv2.minAreaRect(poly)
angle =... | ['def', 'poly2rbox(polys,', 'num_cls_thata=180,', 'radius=6.0,', 'use_pi=False,', 'use_gaussian=False):', 'assert', 'polys.shape[-1]', '==', '8', 'if', 'use_gaussian:', 'csl_labels', '=', '[]', 'rboxes', '=', '[]', 'for', 'poly', 'in', 'polys:', 'poly', '=', 'np.float32(poly.reshape(4,', '2))', '((x,', 'y),', '(w,', 'h... | 969,724 |
hukaixuan19970627/yolov5_obb | rboxs_utils.py | rbox2poly | rbox2poly | Trans rbox format to poly format. | [
"Trans",
"rbox",
"format",
"to",
"poly",
"format."
] | def rbox2poly(obboxes):
if isinstance(obboxes, torch.Tensor):
(center, w, h, theta) = (obboxes[:, :2], obboxes[:, 2:3], obboxes[:, 3:4], obboxes[:, 4:5])
(Cos, Sin) = (torch.cos(theta), torch.sin(theta))
vector1 = torch.cat((w / 2 * Cos, -w / 2 * Sin), dim=-1)
vector2 = torch.cat((-h... | ['def', 'rbox2poly(obboxes):', 'if', 'isinstance(obboxes,', 'torch.Tensor):', '(center,', 'w,', 'h,', 'theta)', '=', '(obboxes[:,', ':2],', 'obboxes[:,', '2:3],', 'obboxes[:,', '3:4],', 'obboxes[:,', '4:5])', '(Cos,', 'Sin)', '=', '(torch.cos(theta),', 'torch.sin(theta))', 'vector1', '=', 'torch.cat((w', '/', '2', '*',... | 969,725 |
hukaixuan19970627/yolov5_obb | rboxs_utils.py | poly_filter | poly_filter | Filter the poly labels which is out of the image. | [
"Filter",
"the",
"poly",
"labels",
"which",
"is",
"out",
"of",
"the",
"image."
] | def poly_filter(polys, h, w):
x = polys[:, 0::2]
y = polys[:, 1::2]
x_max = np.amax(x, axis=1)
x_min = np.amin(x, axis=1)
y_max = np.amax(y, axis=1)
y_min = np.amin(y, axis=1)
(x_ctr, y_ctr) = ((x_max + x_min) / 2.0, (y_max + y_min) / 2.0)
keep_masks = (x_ctr > 0) & (x_ctr < w) & (y_ctr ... | ['def', 'poly_filter(polys,', 'h,', 'w):', 'x', '=', 'polys[:,', '0::2]', 'y', '=', 'polys[:,', '1::2]', 'x_max', '=', 'np.amax(x,', 'axis=1)', 'x_min', '=', 'np.amin(x,', 'axis=1)', 'y_max', '=', 'np.amax(y,', 'axis=1)', 'y_min', '=', 'np.amin(y,', 'axis=1)', '(x_ctr,', 'y_ctr)', '=', '((x_max', '+', 'x_min)', '/', '2... | 969,727 |
vidhyadharan-k/YOLOv7-Semantic-Segmentation | dataloaders.py | polygons2masks_overlap | polygons2masks_overlap | Return a (640, 640) overlap mask. | [
"Return",
"a",
"(640,",
"640)",
"overlap",
"mask."
] | def polygons2masks_overlap(img_size, segments, downsample_ratio=1):
masks = np.zeros((img_size[0] // downsample_ratio, img_size[1] // downsample_ratio), dtype=np.uint8)
areas = []
ms = []
for si in range(len(segments)):
mask = polygon2mask(img_size, [segments[si].reshape(-1)], downsample_ratio=d... | ['def', 'polygons2masks_overlap(img_size,', 'segments,', 'downsample_ratio=1):', 'masks', '=', 'np.zeros((img_size[0]', '//', 'downsample_ratio,', 'img_size[1]', '//', 'downsample_ratio),', 'dtype=np.uint8)', 'areas', '=', '[]', 'ms', '=', '[]', 'for', 'si', 'in', 'range(len(segments)):', 'mask', '=', 'polygon2mask(img... | 969,838 |
vidhyadharan-k/YOLOv7-Semantic-Segmentation | metrics.py | Metric.mp | mp | mean precision of all classes. | [
"mean",
"precision",
"of",
"all",
"classes."
] | def mp(self):
return self.p.mean() if len(self.p) else 0.0 | ['def', 'mp(self):', 'return', 'self.p.mean()', 'if', 'len(self.p)', 'else', '0.0'] | 969,846 |
vidhyadharan-k/YOLOv7-Semantic-Segmentation | metrics.py | Metric.mr | mr | mean recall of all classes. | [
"mean",
"recall",
"of",
"all",
"classes."
] | def mr(self):
return self.r.mean() if len(self.r) else 0.0 | ['def', 'mr(self):', 'return', 'self.r.mean()', 'if', 'len(self.r)', 'else', '0.0'] | 969,847 |
gliese581gg/YOLO_tensorflow | voc_utils.py | imgs_from_category_as_list | imgs_from_category_as_list | Get a list of filenames for images in a particular category as a list rather than a pandas dataframe. | [
"Get",
"a",
"list",
"of",
"filenames",
"for",
"images",
"in",
"a",
"particular",
"category",
"as",
"a",
"list",
"rather",
"than",
"a",
"pandas",
"dataframe."
] | def imgs_from_category_as_list(cat_name, dataset):
df = imgs_from_category(cat_name, dataset)
df = df[df['true'] == 1]
return df['filename'].values | ['def', 'imgs_from_category_as_list(cat_name,', 'dataset):', 'df', '=', 'imgs_from_category(cat_name,', 'dataset)', 'df', '=', "df[df['true']", '==', '1]', 'return', "df['filename'].values"] | 969,889 |
gliese581gg/YOLO_tensorflow | voc_utils.py | load_annotation | load_annotation | Load annotation file for a given image. | [
"Load",
"annotation",
"file",
"for",
"a",
"given",
"image."
] | def load_annotation(img_filename):
xml = ''
with open(annotation_file_from_img(img_filename)) as f:
xml = f.readlines()
xml = ''.join([line.strip('\t') for line in xml])
return BeautifulSoup(xml) | ['def', 'load_annotation(img_filename):', 'xml', '=', "''", 'with', 'open(annotation_file_from_img(img_filename))', 'as', 'f:', 'xml', '=', 'f.readlines()', 'xml', '=', "''.join([line.strip('\\t')", 'for', 'line', 'in', 'xml])', 'return', 'BeautifulSoup(xml)'] | 969,891 |
gliese581gg/YOLO_tensorflow | voc_utils.py | load_imgs | load_imgs | Load a bunch of images from disk as np array. | [
"Load",
"a",
"bunch",
"of",
"images",
"from",
"disk",
"as",
"np",
"array."
] | def load_imgs(img_filenames):
return np.array([load_img(fname) for fname in img_filenames]) | ['def', 'load_imgs(img_filenames):', 'return', 'np.array([load_img(fname)', 'for', 'fname', 'in', 'img_filenames])'] | 969,893 |
gliese581gg/YOLO_tensorflow | voc_utils.py | get_image_url_list | get_image_url_list | For a given data type, returns a list of filenames. | [
"For",
"a",
"given",
"data",
"type,",
"returns",
"a",
"list",
"of",
"filenames."
] | def get_image_url_list(category, data_type=None):
df = _load_data(category, data_type=data_type)
image_url_list = list(unique_everseen(list(img_dir + df['fname'])))
return image_url_list | ['def', 'get_image_url_list(category,', 'data_type=None):', 'df', '=', '_load_data(category,', 'data_type=data_type)', 'image_url_list', '=', 'list(unique_everseen(list(img_dir', '+', "df['fname'])))", 'return', 'image_url_list'] | 969,894 |
gliese581gg/YOLO_tensorflow | voc_utils.py | get_imgs | get_imgs | Load and return all the images for a particular category. | [
"Load",
"and",
"return",
"all",
"the",
"images",
"for",
"a",
"particular",
"category."
] | def get_imgs(cat_name, data_type=None):
image_url_list = get_image_url_list(cat_name, data_type=data_type)
imgs = []
for url in image_url_list:
imgs.append(load_img(url))
return np.array(imgs) | ['def', 'get_imgs(cat_name,', 'data_type=None):', 'image_url_list', '=', 'get_image_url_list(cat_name,', 'data_type=data_type)', 'imgs', '=', '[]', 'for', 'url', 'in', 'image_url_list:', 'imgs.append(load_img(url))', 'return', 'np.array(imgs)'] | 969,896 |
gliese581gg/YOLO_tensorflow | voc_utils.py | cat_name_to_cat_id | cat_name_to_cat_id | Transform a category name to an id number alphabetically. | [
"Transform",
"a",
"category",
"name",
"to",
"an",
"id",
"number",
"alphabetically."
] | def cat_name_to_cat_id(cat_name):
cat_list = list_image_sets()
cat_id_dict = dict(zip(cat_list, range(len(cat_list))))
return cat_id_dict[cat_name] | ['def', 'cat_name_to_cat_id(cat_name):', 'cat_list', '=', 'list_image_sets()', 'cat_id_dict', '=', 'dict(zip(cat_list,', 'range(len(cat_list))))', 'return', 'cat_id_dict[cat_name]'] | 969,898 |
dshahrokhian/YOLO_tensorflow | voc_utils.py | display_img_and_masks | display_img_and_masks | Display an image and it's two masks side by side. | [
"Display",
"an",
"image",
"and",
"it's",
"two",
"masks",
"side",
"by",
"side."
] | def display_img_and_masks(img, true_mask, predicted_mask, block=False):
m_predicted_color = predicted_mask.reshape(predicted_mask.shape[0], predicted_mask.shape[1])
m_true_color = true_mask.reshape(true_mask.shape[0], true_mask.shape[1])
plt.figure(1)
plt.clf()
plt.axis('off')
(f, (ax1, ax2, ax3... | ['def', 'display_img_and_masks(img,', 'true_mask,', 'predicted_mask,', 'block=False):', 'm_predicted_color', '=', 'predicted_mask.reshape(predicted_mask.shape[0],', 'predicted_mask.shape[1])', 'm_true_color', '=', 'true_mask.reshape(true_mask.shape[0],', 'true_mask.shape[1])', 'plt.figure(1)', 'plt.clf()', "plt.axis('o... | 969,912 |
onozeam/YoutubeDNN | main.py | Ranking.forward | forward | input is (batch_size, n_item, watch_time_feature_size), and output is (batch_size, n_item). | [
"input",
"is",
"(batch_size,",
"n_item,",
"watch_time_feature_size),",
"and",
"output",
"is",
"(batch_size,",
"n_item)."
] | def forward(self, src):
h = F.relu(self.fc1(src))
h = F.relu(self.fc2(h))
out = F.relu(self.fc3(h))
return out.squeeze(-1) | ['def', 'forward(self,', 'src):', 'h', '=', 'F.relu(self.fc1(src))', 'h', '=', 'F.relu(self.fc2(h))', 'out', '=', 'F.relu(self.fc3(h))', 'return', 'out.squeeze(-1)'] | 969,914 |
Alexander-Parker/youtube_nlp | code.py | Code.scope | scope | Scope dictionary for this instance or ``None``. | [
"Scope",
"dictionary",
"for",
"this",
"instance",
"or",
"``None``."
] | def scope(self):
return self.__scope | ['def', 'scope(self):', 'return', 'self.__scope'] | 969,933 |
Alexander-Parker/youtube_nlp | ttl.py | TTLCache.expire | expire | Remove expired items from the cache. | [
"Remove",
"expired",
"items",
"from",
"the",
"cache."
] | def expire(self, time=None):
if time is None:
time = self.__timer()
root = self.__root
curr = root.next
links = self.__links
cache_delitem = Cache.__delitem__
while curr is not root and curr.expire < time:
cache_delitem(self, curr.key)
del links[curr.key]
next = c... | ['def', 'expire(self,', 'time=None):', 'if', 'time', 'is', 'None:', 'time', '=', 'self.__timer()', 'root', '=', 'self.__root', 'curr', '=', 'root.next', 'links', '=', 'self.__links', 'cache_delitem', '=', 'Cache.__delitem__', 'while', 'curr', 'is', 'not', 'root', 'and', 'curr.expire', '<', 'time:', 'cache_delitem(self,... | 969,978 |
Alexander-Parker/youtube_nlp | _cloud_sdk.py | load_authorized_user_credentials | load_authorized_user_credentials | Loads an authorized user credential. | [
"Loads",
"an",
"authorized",
"user",
"credential."
] | def load_authorized_user_credentials(info):
return google.oauth2.credentials.Credentials.from_authorized_user_info(info) | ['def', 'load_authorized_user_credentials(info):', 'return', 'google.oauth2.credentials.Credentials.from_authorized_user_info(info)'] | 970,025 |
Alexander-Parker/youtube_nlp | http.py | set_user_agent | set_user_agent | Set the user-agent on every request. | [
"Set",
"the",
"user-agent",
"on",
"every",
"request."
] | def set_user_agent(http, user_agent):
request_orig = http.request
def new_request(uri, method='GET', body=None, headers=None, redirections=httplib2.DEFAULT_MAX_REDIRECTS, connection_type=None):
if headers is None:
headers = {}
if 'user-agent' in headers:
headers['user-ag... | ['def', 'set_user_agent(http,', 'user_agent):', 'request_orig', '=', 'http.request', 'def', 'new_request(uri,', "method='GET',", 'body=None,', 'headers=None,', 'redirections=httplib2.DEFAULT_MAX_REDIRECTS,', 'connection_type=None):', 'if', 'headers', 'is', 'None:', 'headers', '=', '{}', 'if', "'user-agent'", 'in', 'hea... | 970,102 |
Alexander-Parker/youtube_nlp | schema.py | _SchemaToStruct.emitBegin | emitBegin | Add text to the output, but with no line terminator. | [
"Add",
"text",
"to",
"the",
"output,",
"but",
"with",
"no",
"line",
"terminator."
] | def emitBegin(self, text):
self.value.extend([' ' * self.dent, text]) | ['def', 'emitBegin(self,', 'text):', "self.value.extend(['", "'", '*', 'self.dent,', 'text])'] | 970,150 |
Alexander-Parker/youtube_nlp | base.py | Cache.get | get | Gets the content from the memcache with a given key. | [
"Gets",
"the",
"content",
"from",
"the",
"memcache",
"with",
"a",
"given",
"key."
] | def get(self, url):
raise NotImplementedError() | ['def', 'get(self,', 'url):', 'raise', 'NotImplementedError()'] | 970,158 |
Alexander-Parker/youtube_nlp | auth.py | logout | logout | Log out from a database. | [
"Log",
"out",
"from",
"a",
"database."
] | def logout(source, sock_info):
sock_info.command(source, {'logout': 1}) | ['def', 'logout(source,', 'sock_info):', 'sock_info.command(source,', "{'logout':", '1})'] | 970,264 |
Alexander-Parker/youtube_nlp | bulk.py | _Bulk.execute_no_results | execute_no_results | Execute all operations, returning no results (w=0). | [
"Execute",
"all",
"operations,",
"returning",
"no",
"results",
"(w=0)."
] | def execute_no_results(self, sock_info, generator):
if self.uses_collation:
raise ConfigurationError('Collation is unsupported for unacknowledged writes.')
if self.uses_array_filters:
raise ConfigurationError('arrayFilters is unsupported for unacknowledged writes.')
if self.bypass_doc_val an... | ['def', 'execute_no_results(self,', 'sock_info,', 'generator):', 'if', 'self.uses_collation:', 'raise', "ConfigurationError('Collation", 'is', 'unsupported', 'for', 'unacknowledged', "writes.')", 'if', 'self.uses_array_filters:', 'raise', "ConfigurationError('arrayFilters", 'is', 'unsupported', 'for', 'unacknowledged',... | 970,277 |
Alexander-Parker/youtube_nlp | client_options.py | ClientOptions.local_threshold_ms | local_threshold_ms | The local threshold for this instance. | [
"The",
"local",
"threshold",
"for",
"this",
"instance."
] | def local_threshold_ms(self):
return self.__local_threshold_ms | ['def', 'local_threshold_ms(self):', 'return', 'self.__local_threshold_ms'] | 970,294 |
Alexander-Parker/youtube_nlp | client_options.py | ClientOptions.retry_writes | retry_writes | If this instance should retry supported write operations. | [
"If",
"this",
"instance",
"should",
"retry",
"supported",
"write",
"operations."
] | def retry_writes(self):
return self.__retry_writes | ['def', 'retry_writes(self):', 'return', 'self.__retry_writes'] | 970,299 |
Alexander-Parker/youtube_nlp | client_session.py | SessionOptions.causal_consistency | causal_consistency | Whether causal consistency is configured. | [
"Whether",
"causal",
"consistency",
"is",
"configured."
] | def causal_consistency(self):
return self._causal_consistency | ['def', 'causal_consistency(self):', 'return', 'self._causal_consistency'] | 970,300 |
Alexander-Parker/youtube_nlp | client_session.py | ClientSession.session_id | session_id | A BSON document, the opaque server session identifier. | [
"A",
"BSON",
"document,",
"the",
"opaque",
"server",
"session",
"identifier."
] | def session_id(self):
self._check_ended()
return self._server_session.session_id | ['def', 'session_id(self):', 'self._check_ended()', 'return', 'self._server_session.session_id'] | 970,305 |
Alexander-Parker/youtube_nlp | client_session.py | ClientSession.cluster_time | cluster_time | The cluster time returned by the last operation executed in this session. | [
"The",
"cluster",
"time",
"returned",
"by",
"the",
"last",
"operation",
"executed",
"in",
"this",
"session."
] | def cluster_time(self):
return self._cluster_time | ['def', 'cluster_time(self):', 'return', 'self._cluster_time'] | 970,306 |
Alexander-Parker/youtube_nlp | client_session.py | ClientSession.has_ended | has_ended | True if this session is finished. | [
"True",
"if",
"this",
"session",
"is",
"finished."
] | def has_ended(self):
return self._server_session is None | ['def', 'has_ended(self):', 'return', 'self._server_session', 'is', 'None'] | 970,313 |
Alexander-Parker/youtube_nlp | common.py | validate_list_or_none | validate_list_or_none | Validates that 'value' is a list or None. | [
"Validates",
"that",
"'value'",
"is",
"a",
"list",
"or",
"None."
] | def validate_list_or_none(option, value):
if value is None:
return value
return validate_list(option, value) | ['def', 'validate_list_or_none(option,', 'value):', 'if', 'value', 'is', 'None:', 'return', 'value', 'return', 'validate_list(option,', 'value)'] | 970,376 |
Alexander-Parker/youtube_nlp | common.py | validate_driver_or_none | validate_driver_or_none | Validate the driver keyword arg. | [
"Validate",
"the",
"driver",
"keyword",
"arg."
] | def validate_driver_or_none(option, value):
if value is None:
return value
if not isinstance(value, DriverInfo):
raise TypeError('%s must be an instance of DriverInfo' % (option,))
return value | ['def', 'validate_driver_or_none(option,', 'value):', 'if', 'value', 'is', 'None:', 'return', 'value', 'if', 'not', 'isinstance(value,', 'DriverInfo):', 'raise', "TypeError('%s", 'must', 'be', 'an', 'instance', 'of', "DriverInfo'", '%', '(option,))', 'return', 'value'] | 970,380 |
Alexander-Parker/youtube_nlp | database.py | Database.client | client | The client instance for this :class:`Database`. | [
"The",
"client",
"instance",
"for",
"this",
":class:`Database`."
] | def client(self):
return self.__client | ['def', 'client(self):', 'return', 'self.__client'] | 970,421 |
Alexander-Parker/youtube_nlp | max_staleness_selectors.py | select | select | Apply max_staleness, in seconds, to a Selection. | [
"Apply",
"max_staleness,",
"in",
"seconds,",
"to",
"a",
"Selection."
] | def select(max_staleness, selection):
if max_staleness == -1:
return selection
_validate_max_staleness(max_staleness, selection.heartbeat_frequency)
if selection.primary:
return _with_primary(max_staleness, selection)
else:
return _no_primary(max_staleness, selection) | ['def', 'select(max_staleness,', 'selection):', 'if', 'max_staleness', '==', '-1:', 'return', 'selection', '_validate_max_staleness(max_staleness,', 'selection.heartbeat_frequency)', 'if', 'selection.primary:', 'return', '_with_primary(max_staleness,', 'selection)', 'else:', 'return', '_no_primary(max_staleness,', 'sel... | 970,453 |
Alexander-Parker/youtube_nlp | message.py | _OpReply.command_response | command_response | Unpack a command response. | [
"Unpack",
"a",
"command",
"response."
] | def command_response(self):
docs = self.unpack_response()
assert self.number_returned == 1
return docs[0] | ['def', 'command_response(self):', 'docs', '=', 'self.unpack_response()', 'assert', 'self.number_returned', '==', '1', 'return', 'docs[0]'] | 970,472 |
Alexander-Parker/youtube_nlp | message.py | _OpReply.unpack | unpack | Construct an _OpReply from raw bytes. | [
"Construct",
"an",
"_OpReply",
"from",
"raw",
"bytes."
] | def unpack(cls, msg):
(flags, cursor_id, _, number_returned) = cls.UNPACK_FROM(msg)
documents = bytes(msg[20:])
return cls(flags, cursor_id, number_returned, documents) | ['def', 'unpack(cls,', 'msg):', '(flags,', 'cursor_id,', '_,', 'number_returned)', '=', 'cls.UNPACK_FROM(msg)', 'documents', '=', 'bytes(msg[20:])', 'return', 'cls(flags,', 'cursor_id,', 'number_returned,', 'documents)'] | 970,473 |
Alexander-Parker/youtube_nlp | monitoring.py | CommandStartedEvent.database_name | database_name | The name of the database this command was run against. | [
"The",
"name",
"of",
"the",
"database",
"this",
"command",
"was",
"run",
"against."
] | def database_name(self):
return self.__db | ['def', 'database_name(self):', 'return', 'self.__db'] | 970,526 |
Alexander-Parker/youtube_nlp | periodic_executor.py | PeriodicExecutor.wake | wake | Execute the target function soon. | [
"Execute",
"the",
"target",
"function",
"soon."
] | def wake(self):
self._event = True | ['def', 'wake(self):', 'self._event', '=', 'True'] | 970,561 |
Alexander-Parker/youtube_nlp | pool.py | SocketInfo.idle_time_seconds | idle_time_seconds | Seconds since this socket was last checked into its pool. | [
"Seconds",
"since",
"this",
"socket",
"was",
"last",
"checked",
"into",
"its",
"pool."
] | def idle_time_seconds(self):
return _time() - self.last_checkin_time | ['def', 'idle_time_seconds(self):', 'return', '_time()', '-', 'self.last_checkin_time'] | 970,584 |
Alexander-Parker/youtube_nlp | pool.py | Pool.remove_stale_sockets | remove_stale_sockets | Removes stale sockets then adds new ones if pool is too small. | [
"Removes",
"stale",
"sockets",
"then",
"adds",
"new",
"ones",
"if",
"pool",
"is",
"too",
"small."
] | def remove_stale_sockets(self):
if self.opts.max_idle_time_seconds is not None:
with self.lock:
while self.sockets and self.sockets[-1].idle_time_seconds() > self.opts.max_idle_time_seconds:
sock_info = self.sockets.pop()
sock_info.close()
while True:
... | ['def', 'remove_stale_sockets(self):', 'if', 'self.opts.max_idle_time_seconds', 'is', 'not', 'None:', 'with', 'self.lock:', 'while', 'self.sockets', 'and', 'self.sockets[-1].idle_time_seconds()', '>', 'self.opts.max_idle_time_seconds:', 'sock_info', '=', 'self.sockets.pop()', 'sock_info.close()', 'while', 'True:', 'wit... | 970,585 |
Alexander-Parker/youtube_nlp | response.py | Response.request_id | request_id | The request id of this operation. | [
"The",
"request",
"id",
"of",
"this",
"operation."
] | def request_id(self):
return self._request_id | ['def', 'request_id(self):', 'return', 'self._request_id'] | 970,603 |
Alexander-Parker/youtube_nlp | server_description.py | ServerDescription.retryable_writes_supported | retryable_writes_supported | Checks if this server supports retryable writes. | [
"Checks",
"if",
"this",
"server",
"supports",
"retryable",
"writes."
] | def retryable_writes_supported(self):
return self._ls_timeout_minutes is not None and self._server_type in (SERVER_TYPE.Mongos, SERVER_TYPE.RSPrimary) | ['def', 'retryable_writes_supported(self):', 'return', 'self._ls_timeout_minutes', 'is', 'not', 'None', 'and', 'self._server_type', 'in', '(SERVER_TYPE.Mongos,', 'SERVER_TYPE.RSPrimary)'] | 970,638 |
Alexander-Parker/youtube_nlp | settings.py | TopologySettings.get_server_descriptions | get_server_descriptions | Initial dict of (address, ServerDescription) for all seeds. | [
"Initial",
"dict",
"of",
"(address,",
"ServerDescription)",
"for",
"all",
"seeds."
] | def get_server_descriptions(self):
return dict([(address, ServerDescription(address)) for address in self.seeds]) | ['def', 'get_server_descriptions(self):', 'return', 'dict([(address,', 'ServerDescription(address))', 'for', 'address', 'in', 'self.seeds])'] | 970,646 |
Alexander-Parker/youtube_nlp | topology.py | Topology.get_primary | get_primary | Return primary's address or None. | [
"Return",
"primary's",
"address",
"or",
"None."
] | def get_primary(self):
with self._lock:
topology_type = self._description.topology_type
if topology_type != TOPOLOGY_TYPE.ReplicaSetWithPrimary:
return None
return writable_server_selector(self._new_selection())[0].address | ['def', 'get_primary(self):', 'with', 'self._lock:', 'topology_type', '=', 'self._description.topology_type', 'if', 'topology_type', '!=', 'TOPOLOGY_TYPE.ReplicaSetWithPrimary:', 'return', 'None', 'return', 'writable_server_selector(self._new_selection())[0].address'] | 970,672 |
Alexander-Parker/youtube_nlp | topology.py | Topology.max_cluster_time | max_cluster_time | Return a document, the highest seen $clusterTime. | [
"Return",
"a",
"document,",
"the",
"highest",
"seen",
"$clusterTime."
] | def max_cluster_time(self):
return self._max_cluster_time | ['def', 'max_cluster_time(self):', 'return', 'self._max_cluster_time'] | 970,675 |
Alexander-Parker/youtube_nlp | topology.py | Topology.get_server_session | get_server_session | Start or resume a server session, or raise ConfigurationError. | [
"Start",
"or",
"resume",
"a",
"server",
"session,",
"or",
"raise",
"ConfigurationError."
] | def get_server_session(self):
with self._lock:
session_timeout = self._description.logical_session_timeout_minutes
if session_timeout is None:
if self._description.topology_type == TOPOLOGY_TYPE.Single:
if not self._description.has_known_servers:
self.... | ['def', 'get_server_session(self):', 'with', 'self._lock:', 'session_timeout', '=', 'self._description.logical_session_timeout_minutes', 'if', 'session_timeout', 'is', 'None:', 'if', 'self._description.topology_type', '==', 'TOPOLOGY_TYPE.Single:', 'if', 'not', 'self._description.has_known_servers:', 'self._select_serv... | 970,681 |
Alexander-Parker/youtube_nlp | topology_description.py | TopologyDescription.logical_session_timeout_minutes | logical_session_timeout_minutes | Minimum logical session timeout, or None. | [
"Minimum",
"logical",
"session",
"timeout,",
"or",
"None."
] | def logical_session_timeout_minutes(self):
return self._ls_timeout_minutes | ['def', 'logical_session_timeout_minutes(self):', 'return', 'self._ls_timeout_minutes'] | 970,693 |
Alexander-Parker/youtube_nlp | write_concern.py | WriteConcern.is_server_default | is_server_default | Does this WriteConcern match the server default. | [
"Does",
"this",
"WriteConcern",
"match",
"the",
"server",
"default."
] | def is_server_default(self):
return self.__server_default | ['def', 'is_server_default(self):', 'return', 'self.__server_default'] | 970,706 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.