repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
thieman/dagobah | dagobah/core/core.py | Dagobah.from_backend | def from_backend(self, dagobah_id):
""" Reconstruct this Dagobah instance from the backend. """
logger.debug('Reconstructing Dagobah instance from backend with ID {0}'.format(dagobah_id))
rec = self.backend.get_dagobah_json(dagobah_id)
if not rec:
raise DagobahError('dagobah ... | python | def from_backend(self, dagobah_id):
""" Reconstruct this Dagobah instance from the backend. """
logger.debug('Reconstructing Dagobah instance from backend with ID {0}'.format(dagobah_id))
rec = self.backend.get_dagobah_json(dagobah_id)
if not rec:
raise DagobahError('dagobah ... | [
"def",
"from_backend",
"(",
"self",
",",
"dagobah_id",
")",
":",
"logger",
".",
"debug",
"(",
"'Reconstructing Dagobah instance from backend with ID {0}'",
".",
"format",
"(",
"dagobah_id",
")",
")",
"rec",
"=",
"self",
".",
"backend",
".",
"get_dagobah_json",
"("... | Reconstruct this Dagobah instance from the backend. | [
"Reconstruct",
"this",
"Dagobah",
"instance",
"from",
"the",
"backend",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L70-L77 | train |
thieman/dagobah | dagobah/core/core.py | Dagobah._construct_from_json | def _construct_from_json(self, rec):
""" Construct this Dagobah instance from a JSON document. """
self.delete()
for required_key in ['dagobah_id', 'created_jobs']:
setattr(self, required_key, rec[required_key])
for job_json in rec.get('jobs', []):
self._add_jo... | python | def _construct_from_json(self, rec):
""" Construct this Dagobah instance from a JSON document. """
self.delete()
for required_key in ['dagobah_id', 'created_jobs']:
setattr(self, required_key, rec[required_key])
for job_json in rec.get('jobs', []):
self._add_jo... | [
"def",
"_construct_from_json",
"(",
"self",
",",
"rec",
")",
":",
"self",
".",
"delete",
"(",
")",
"for",
"required_key",
"in",
"[",
"'dagobah_id'",
",",
"'created_jobs'",
"]",
":",
"setattr",
"(",
"self",
",",
"required_key",
",",
"rec",
"[",
"required_ke... | Construct this Dagobah instance from a JSON document. | [
"Construct",
"this",
"Dagobah",
"instance",
"from",
"a",
"JSON",
"document",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L80-L91 | train |
thieman/dagobah | dagobah/core/core.py | Dagobah.add_job_from_json | def add_job_from_json(self, job_json, destructive=False):
""" Construct a new Job from an imported JSON spec. """
logger.debug('Importing job from JSON document: {0}'.format(job_json))
rec = self.backend.decode_import_json(job_json)
if destructive:
try:
self.d... | python | def add_job_from_json(self, job_json, destructive=False):
""" Construct a new Job from an imported JSON spec. """
logger.debug('Importing job from JSON document: {0}'.format(job_json))
rec = self.backend.decode_import_json(job_json)
if destructive:
try:
self.d... | [
"def",
"add_job_from_json",
"(",
"self",
",",
"job_json",
",",
"destructive",
"=",
"False",
")",
":",
"logger",
".",
"debug",
"(",
"'Importing job from JSON document: {0}'",
".",
"format",
"(",
"job_json",
")",
")",
"rec",
"=",
"self",
".",
"backend",
".",
"... | Construct a new Job from an imported JSON spec. | [
"Construct",
"a",
"new",
"Job",
"from",
"an",
"imported",
"JSON",
"spec",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L94-L105 | train |
thieman/dagobah | dagobah/core/core.py | Dagobah._add_job_from_spec | def _add_job_from_spec(self, job_json, use_job_id=True):
""" Add a single job to the Dagobah from a spec. """
job_id = (job_json['job_id']
if use_job_id
else self.backend.get_new_job_id())
self.add_job(str(job_json['name']), job_id)
job = self.get_job... | python | def _add_job_from_spec(self, job_json, use_job_id=True):
""" Add a single job to the Dagobah from a spec. """
job_id = (job_json['job_id']
if use_job_id
else self.backend.get_new_job_id())
self.add_job(str(job_json['name']), job_id)
job = self.get_job... | [
"def",
"_add_job_from_spec",
"(",
"self",
",",
"job_json",
",",
"use_job_id",
"=",
"True",
")",
":",
"job_id",
"=",
"(",
"job_json",
"[",
"'job_id'",
"]",
"if",
"use_job_id",
"else",
"self",
".",
"backend",
".",
"get_new_job_id",
"(",
")",
")",
"self",
"... | Add a single job to the Dagobah from a spec. | [
"Add",
"a",
"single",
"job",
"to",
"the",
"Dagobah",
"from",
"a",
"spec",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L108-L133 | train |
thieman/dagobah | dagobah/core/core.py | Dagobah.commit | def commit(self, cascade=False):
""" Commit this Dagobah instance to the backend.
If cascade is True, all child Jobs are commited as well.
"""
logger.debug('Committing Dagobah instance with cascade={0}'.format(cascade))
self.backend.commit_dagobah(self._serialize())
if c... | python | def commit(self, cascade=False):
""" Commit this Dagobah instance to the backend.
If cascade is True, all child Jobs are commited as well.
"""
logger.debug('Committing Dagobah instance with cascade={0}'.format(cascade))
self.backend.commit_dagobah(self._serialize())
if c... | [
"def",
"commit",
"(",
"self",
",",
"cascade",
"=",
"False",
")",
":",
"logger",
".",
"debug",
"(",
"'Committing Dagobah instance with cascade={0}'",
".",
"format",
"(",
"cascade",
")",
")",
"self",
".",
"backend",
".",
"commit_dagobah",
"(",
"self",
".",
"_s... | Commit this Dagobah instance to the backend.
If cascade is True, all child Jobs are commited as well. | [
"Commit",
"this",
"Dagobah",
"instance",
"to",
"the",
"backend",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L137-L145 | train |
thieman/dagobah | dagobah/core/core.py | Dagobah.delete | def delete(self):
""" Delete this Dagobah instance from the Backend. """
logger.debug('Deleting Dagobah instance with ID {0}'.format(self.dagobah_id))
self.jobs = []
self.created_jobs = 0
self.backend.delete_dagobah(self.dagobah_id) | python | def delete(self):
""" Delete this Dagobah instance from the Backend. """
logger.debug('Deleting Dagobah instance with ID {0}'.format(self.dagobah_id))
self.jobs = []
self.created_jobs = 0
self.backend.delete_dagobah(self.dagobah_id) | [
"def",
"delete",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'Deleting Dagobah instance with ID {0}'",
".",
"format",
"(",
"self",
".",
"dagobah_id",
")",
")",
"self",
".",
"jobs",
"=",
"[",
"]",
"self",
".",
"created_jobs",
"=",
"0",
"self",
".... | Delete this Dagobah instance from the Backend. | [
"Delete",
"this",
"Dagobah",
"instance",
"from",
"the",
"Backend",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L148-L153 | train |
thieman/dagobah | dagobah/core/core.py | Dagobah.add_job | def add_job(self, job_name, job_id=None):
""" Create a new, empty Job. """
logger.debug('Creating a new job named {0}'.format(job_name))
if not self._name_is_available(job_name):
raise DagobahError('name %s is not available' % job_name)
if not job_id:
job_id = se... | python | def add_job(self, job_name, job_id=None):
""" Create a new, empty Job. """
logger.debug('Creating a new job named {0}'.format(job_name))
if not self._name_is_available(job_name):
raise DagobahError('name %s is not available' % job_name)
if not job_id:
job_id = se... | [
"def",
"add_job",
"(",
"self",
",",
"job_name",
",",
"job_id",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"'Creating a new job named {0}'",
".",
"format",
"(",
"job_name",
")",
")",
"if",
"not",
"self",
".",
"_name_is_available",
"(",
"job_name",
... | Create a new, empty Job. | [
"Create",
"a",
"new",
"empty",
"Job",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L156-L172 | train |
thieman/dagobah | dagobah/core/core.py | Dagobah.get_host | def get_host(self, hostname):
""" Returns a Host dict with config options, or None if none exists"""
if hostname in self.get_hosts():
return self.load_ssh_conf().lookup(hostname)
logger.warn('Tried to find host with name {0}, but host not found'.format(hostname))
return None | python | def get_host(self, hostname):
""" Returns a Host dict with config options, or None if none exists"""
if hostname in self.get_hosts():
return self.load_ssh_conf().lookup(hostname)
logger.warn('Tried to find host with name {0}, but host not found'.format(hostname))
return None | [
"def",
"get_host",
"(",
"self",
",",
"hostname",
")",
":",
"if",
"hostname",
"in",
"self",
".",
"get_hosts",
"(",
")",
":",
"return",
"self",
".",
"load_ssh_conf",
"(",
")",
".",
"lookup",
"(",
"hostname",
")",
"logger",
".",
"warn",
"(",
"'Tried to fi... | Returns a Host dict with config options, or None if none exists | [
"Returns",
"a",
"Host",
"dict",
"with",
"config",
"options",
"or",
"None",
"if",
"none",
"exists"
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L205-L210 | train |
thieman/dagobah | dagobah/core/core.py | Dagobah.get_job | def get_job(self, job_name):
""" Returns a Job by name, or None if none exists. """
for job in self.jobs:
if job.name == job_name:
return job
logger.warn('Tried to find job with name {0}, but job not found'.format(job_name))
return None | python | def get_job(self, job_name):
""" Returns a Job by name, or None if none exists. """
for job in self.jobs:
if job.name == job_name:
return job
logger.warn('Tried to find job with name {0}, but job not found'.format(job_name))
return None | [
"def",
"get_job",
"(",
"self",
",",
"job_name",
")",
":",
"for",
"job",
"in",
"self",
".",
"jobs",
":",
"if",
"job",
".",
"name",
"==",
"job_name",
":",
"return",
"job",
"logger",
".",
"warn",
"(",
"'Tried to find job with name {0}, but job not found'",
".",... | Returns a Job by name, or None if none exists. | [
"Returns",
"a",
"Job",
"by",
"name",
"or",
"None",
"if",
"none",
"exists",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L212-L218 | train |
thieman/dagobah | dagobah/core/core.py | Dagobah.delete_job | def delete_job(self, job_name):
""" Delete a job by name, or error out if no such job exists. """
logger.debug('Deleting job {0}'.format(job_name))
for idx, job in enumerate(self.jobs):
if job.name == job_name:
self.backend.delete_job(job.job_id)
del s... | python | def delete_job(self, job_name):
""" Delete a job by name, or error out if no such job exists. """
logger.debug('Deleting job {0}'.format(job_name))
for idx, job in enumerate(self.jobs):
if job.name == job_name:
self.backend.delete_job(job.job_id)
del s... | [
"def",
"delete_job",
"(",
"self",
",",
"job_name",
")",
":",
"logger",
".",
"debug",
"(",
"'Deleting job {0}'",
".",
"format",
"(",
"job_name",
")",
")",
"for",
"idx",
",",
"job",
"in",
"enumerate",
"(",
"self",
".",
"jobs",
")",
":",
"if",
"job",
".... | Delete a job by name, or error out if no such job exists. | [
"Delete",
"a",
"job",
"by",
"name",
"or",
"error",
"out",
"if",
"no",
"such",
"job",
"exists",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L221-L230 | train |
thieman/dagobah | dagobah/core/core.py | Dagobah.add_task_to_job | def add_task_to_job(self, job_or_job_name, task_command, task_name=None,
**kwargs):
""" Add a task to a job owned by the Dagobah instance. """
if isinstance(job_or_job_name, Job):
job = job_or_job_name
else:
job = self.get_job(job_or_job_name)
... | python | def add_task_to_job(self, job_or_job_name, task_command, task_name=None,
**kwargs):
""" Add a task to a job owned by the Dagobah instance. """
if isinstance(job_or_job_name, Job):
job = job_or_job_name
else:
job = self.get_job(job_or_job_name)
... | [
"def",
"add_task_to_job",
"(",
"self",
",",
"job_or_job_name",
",",
"task_command",
",",
"task_name",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"job_or_job_name",
",",
"Job",
")",
":",
"job",
"=",
"job_or_job_name",
"else",
":",
... | Add a task to a job owned by the Dagobah instance. | [
"Add",
"a",
"task",
"to",
"a",
"job",
"owned",
"by",
"the",
"Dagobah",
"instance",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L233-L253 | train |
thieman/dagobah | dagobah/core/core.py | Dagobah._name_is_available | def _name_is_available(self, job_name):
""" Returns Boolean of whether the specified name is already in use. """
return (False
if [job for job in self.jobs if job.name == job_name]
else True) | python | def _name_is_available(self, job_name):
""" Returns Boolean of whether the specified name is already in use. """
return (False
if [job for job in self.jobs if job.name == job_name]
else True) | [
"def",
"_name_is_available",
"(",
"self",
",",
"job_name",
")",
":",
"return",
"(",
"False",
"if",
"[",
"job",
"for",
"job",
"in",
"self",
".",
"jobs",
"if",
"job",
".",
"name",
"==",
"job_name",
"]",
"else",
"True",
")"
] | Returns Boolean of whether the specified name is already in use. | [
"Returns",
"Boolean",
"of",
"whether",
"the",
"specified",
"name",
"is",
"already",
"in",
"use",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L255-L259 | train |
thieman/dagobah | dagobah/core/core.py | Dagobah._serialize | def _serialize(self, include_run_logs=False, strict_json=False):
""" Serialize a representation of this Dagobah object to JSON. """
result = {'dagobah_id': self.dagobah_id,
'created_jobs': self.created_jobs,
'jobs': [job._serialize(include_run_logs=include_run_logs,
... | python | def _serialize(self, include_run_logs=False, strict_json=False):
""" Serialize a representation of this Dagobah object to JSON. """
result = {'dagobah_id': self.dagobah_id,
'created_jobs': self.created_jobs,
'jobs': [job._serialize(include_run_logs=include_run_logs,
... | [
"def",
"_serialize",
"(",
"self",
",",
"include_run_logs",
"=",
"False",
",",
"strict_json",
"=",
"False",
")",
":",
"result",
"=",
"{",
"'dagobah_id'",
":",
"self",
".",
"dagobah_id",
",",
"'created_jobs'",
":",
"self",
".",
"created_jobs",
",",
"'jobs'",
... | Serialize a representation of this Dagobah object to JSON. | [
"Serialize",
"a",
"representation",
"of",
"this",
"Dagobah",
"object",
"to",
"JSON",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L262-L271 | train |
thieman/dagobah | dagobah/core/core.py | Job.commit | def commit(self):
""" Store metadata on this Job to the backend. """
logger.debug('Committing job {0}'.format(self.name))
self.backend.commit_job(self._serialize())
self.parent.commit() | python | def commit(self):
""" Store metadata on this Job to the backend. """
logger.debug('Committing job {0}'.format(self.name))
self.backend.commit_job(self._serialize())
self.parent.commit() | [
"def",
"commit",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'Committing job {0}'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"self",
".",
"backend",
".",
"commit_job",
"(",
"self",
".",
"_serialize",
"(",
")",
")",
"self",
".",
"pa... | Store metadata on this Job to the backend. | [
"Store",
"metadata",
"on",
"this",
"Job",
"to",
"the",
"backend",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L313-L317 | train |
thieman/dagobah | dagobah/core/core.py | Job.add_task | def add_task(self, command, name=None, **kwargs):
""" Adds a new Task to the graph with no edges. """
logger.debug('Adding task with command {0} to job {1}'.format(command, self.name))
if not self.state.allow_change_graph:
raise DagobahError("job's graph is immutable in its current ... | python | def add_task(self, command, name=None, **kwargs):
""" Adds a new Task to the graph with no edges. """
logger.debug('Adding task with command {0} to job {1}'.format(command, self.name))
if not self.state.allow_change_graph:
raise DagobahError("job's graph is immutable in its current ... | [
"def",
"add_task",
"(",
"self",
",",
"command",
",",
"name",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"'Adding task with command {0} to job {1}'",
".",
"format",
"(",
"command",
",",
"self",
".",
"name",
")",
")",
"if",
"n... | Adds a new Task to the graph with no edges. | [
"Adds",
"a",
"new",
"Task",
"to",
"the",
"graph",
"with",
"no",
"edges",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L320-L333 | train |
thieman/dagobah | dagobah/core/core.py | Job.add_dependency | def add_dependency(self, from_task_name, to_task_name):
""" Add a dependency between two tasks. """
logger.debug('Adding dependency from {0} to {1}'.format(from_task_name, to_task_name))
if not self.state.allow_change_graph:
raise DagobahError("job's graph is immutable in its curren... | python | def add_dependency(self, from_task_name, to_task_name):
""" Add a dependency between two tasks. """
logger.debug('Adding dependency from {0} to {1}'.format(from_task_name, to_task_name))
if not self.state.allow_change_graph:
raise DagobahError("job's graph is immutable in its curren... | [
"def",
"add_dependency",
"(",
"self",
",",
"from_task_name",
",",
"to_task_name",
")",
":",
"logger",
".",
"debug",
"(",
"'Adding dependency from {0} to {1}'",
".",
"format",
"(",
"from_task_name",
",",
"to_task_name",
")",
")",
"if",
"not",
"self",
".",
"state"... | Add a dependency between two tasks. | [
"Add",
"a",
"dependency",
"between",
"two",
"tasks",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L336-L345 | train |
thieman/dagobah | dagobah/core/core.py | Job.delete_task | def delete_task(self, task_name):
""" Deletes the named Task in this Job. """
logger.debug('Deleting task {0}'.format(task_name))
if not self.state.allow_change_graph:
raise DagobahError("job's graph is immutable in its current state: %s"
% self.state.... | python | def delete_task(self, task_name):
""" Deletes the named Task in this Job. """
logger.debug('Deleting task {0}'.format(task_name))
if not self.state.allow_change_graph:
raise DagobahError("job's graph is immutable in its current state: %s"
% self.state.... | [
"def",
"delete_task",
"(",
"self",
",",
"task_name",
")",
":",
"logger",
".",
"debug",
"(",
"'Deleting task {0}'",
".",
"format",
"(",
"task_name",
")",
")",
"if",
"not",
"self",
".",
"state",
".",
"allow_change_graph",
":",
"raise",
"DagobahError",
"(",
"... | Deletes the named Task in this Job. | [
"Deletes",
"the",
"named",
"Task",
"in",
"this",
"Job",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L348-L361 | train |
thieman/dagobah | dagobah/core/core.py | Job.delete_dependency | def delete_dependency(self, from_task_name, to_task_name):
""" Delete a dependency between two tasks. """
logger.debug('Deleting dependency from {0} to {1}'.format(from_task_name, to_task_name))
if not self.state.allow_change_graph:
raise DagobahError("job's graph is immutable in it... | python | def delete_dependency(self, from_task_name, to_task_name):
""" Delete a dependency between two tasks. """
logger.debug('Deleting dependency from {0} to {1}'.format(from_task_name, to_task_name))
if not self.state.allow_change_graph:
raise DagobahError("job's graph is immutable in it... | [
"def",
"delete_dependency",
"(",
"self",
",",
"from_task_name",
",",
"to_task_name",
")",
":",
"logger",
".",
"debug",
"(",
"'Deleting dependency from {0} to {1}'",
".",
"format",
"(",
"from_task_name",
",",
"to_task_name",
")",
")",
"if",
"not",
"self",
".",
"s... | Delete a dependency between two tasks. | [
"Delete",
"a",
"dependency",
"between",
"two",
"tasks",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L364-L373 | train |
thieman/dagobah | dagobah/core/core.py | Job.schedule | def schedule(self, cron_schedule, base_datetime=None):
""" Schedules the job to run periodically using Cron syntax. """
logger.debug('Scheduling job {0} with cron schedule {1}'.format(self.name, cron_schedule))
if not self.state.allow_change_schedule:
raise DagobahError("job's sched... | python | def schedule(self, cron_schedule, base_datetime=None):
""" Schedules the job to run periodically using Cron syntax. """
logger.debug('Scheduling job {0} with cron schedule {1}'.format(self.name, cron_schedule))
if not self.state.allow_change_schedule:
raise DagobahError("job's sched... | [
"def",
"schedule",
"(",
"self",
",",
"cron_schedule",
",",
"base_datetime",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"'Scheduling job {0} with cron schedule {1}'",
".",
"format",
"(",
"self",
".",
"name",
",",
"cron_schedule",
")",
")",
"if",
"not",... | Schedules the job to run periodically using Cron syntax. | [
"Schedules",
"the",
"job",
"to",
"run",
"periodically",
"using",
"Cron",
"syntax",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L376-L397 | train |
thieman/dagobah | dagobah/core/core.py | Job.start | def start(self):
""" Begins the job by kicking off all tasks with no dependencies. """
logger.info('Job {0} starting job run'.format(self.name))
if not self.state.allow_start:
raise DagobahError('job cannot be started in its current state; ' +
'it is p... | python | def start(self):
""" Begins the job by kicking off all tasks with no dependencies. """
logger.info('Job {0} starting job run'.format(self.name))
if not self.state.allow_start:
raise DagobahError('job cannot be started in its current state; ' +
'it is p... | [
"def",
"start",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Job {0} starting job run'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"if",
"not",
"self",
".",
"state",
".",
"allow_start",
":",
"raise",
"DagobahError",
"(",
"'job cannot be st... | Begins the job by kicking off all tasks with no dependencies. | [
"Begins",
"the",
"job",
"by",
"kicking",
"off",
"all",
"tasks",
"with",
"no",
"dependencies",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L400-L431 | train |
thieman/dagobah | dagobah/core/core.py | Job.retry | def retry(self):
""" Restarts failed tasks of a job. """
logger.info('Job {0} retrying all failed tasks'.format(self.name))
self.initialize_snapshot()
failed_task_names = []
for task_name, log in self.run_log['tasks'].items():
if log.get('success', True) == False:
... | python | def retry(self):
""" Restarts failed tasks of a job. """
logger.info('Job {0} retrying all failed tasks'.format(self.name))
self.initialize_snapshot()
failed_task_names = []
for task_name, log in self.run_log['tasks'].items():
if log.get('success', True) == False:
... | [
"def",
"retry",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Job {0} retrying all failed tasks'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"self",
".",
"initialize_snapshot",
"(",
")",
"failed_task_names",
"=",
"[",
"]",
"for",
"task_name",... | Restarts failed tasks of a job. | [
"Restarts",
"failed",
"tasks",
"of",
"a",
"job",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L434-L456 | train |
thieman/dagobah | dagobah/core/core.py | Job.terminate_all | def terminate_all(self):
""" Terminate all currently running tasks. """
logger.info('Job {0} terminating all currently running tasks'.format(self.name))
for task in self.tasks.itervalues():
if task.started_at and not task.completed_at:
task.terminate() | python | def terminate_all(self):
""" Terminate all currently running tasks. """
logger.info('Job {0} terminating all currently running tasks'.format(self.name))
for task in self.tasks.itervalues():
if task.started_at and not task.completed_at:
task.terminate() | [
"def",
"terminate_all",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Job {0} terminating all currently running tasks'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"for",
"task",
"in",
"self",
".",
"tasks",
".",
"itervalues",
"(",
")",
":",
... | Terminate all currently running tasks. | [
"Terminate",
"all",
"currently",
"running",
"tasks",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L459-L464 | train |
thieman/dagobah | dagobah/core/core.py | Job.kill_all | def kill_all(self):
""" Kill all currently running jobs. """
logger.info('Job {0} killing all currently running tasks'.format(self.name))
for task in self.tasks.itervalues():
if task.started_at and not task.completed_at:
task.kill() | python | def kill_all(self):
""" Kill all currently running jobs. """
logger.info('Job {0} killing all currently running tasks'.format(self.name))
for task in self.tasks.itervalues():
if task.started_at and not task.completed_at:
task.kill() | [
"def",
"kill_all",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Job {0} killing all currently running tasks'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"for",
"task",
"in",
"self",
".",
"tasks",
".",
"itervalues",
"(",
")",
":",
"if",
"... | Kill all currently running jobs. | [
"Kill",
"all",
"currently",
"running",
"jobs",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L467-L472 | train |
thieman/dagobah | dagobah/core/core.py | Job.edit | def edit(self, **kwargs):
""" Change this Job's name.
This will affect the historical data available for this
Job, e.g. past run logs will no longer be accessible.
"""
logger.debug('Job {0} changing name to {1}'.format(self.name, kwargs.get('name')))
if not self.state.a... | python | def edit(self, **kwargs):
""" Change this Job's name.
This will affect the historical data available for this
Job, e.g. past run logs will no longer be accessible.
"""
logger.debug('Job {0} changing name to {1}'.format(self.name, kwargs.get('name')))
if not self.state.a... | [
"def",
"edit",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"'Job {0} changing name to {1}'",
".",
"format",
"(",
"self",
".",
"name",
",",
"kwargs",
".",
"get",
"(",
"'name'",
")",
")",
")",
"if",
"not",
"self",
".",
"sta... | Change this Job's name.
This will affect the historical data available for this
Job, e.g. past run logs will no longer be accessible. | [
"Change",
"this",
"Job",
"s",
"name",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L475-L495 | train |
thieman/dagobah | dagobah/core/core.py | Job.edit_task | def edit_task(self, task_name, **kwargs):
""" Change the name of a Task owned by this Job.
This will affect the historical data available for this
Task, e.g. past run logs will no longer be accessible.
"""
logger.debug('Job {0} editing task {1}'.format(self.name, task_name))
... | python | def edit_task(self, task_name, **kwargs):
""" Change the name of a Task owned by this Job.
This will affect the historical data available for this
Task, e.g. past run logs will no longer be accessible.
"""
logger.debug('Job {0} editing task {1}'.format(self.name, task_name))
... | [
"def",
"edit_task",
"(",
"self",
",",
"task_name",
",",
"**",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"'Job {0} editing task {1}'",
".",
"format",
"(",
"self",
".",
"name",
",",
"task_name",
")",
")",
"if",
"not",
"self",
".",
"state",
".",
"a... | Change the name of a Task owned by this Job.
This will affect the historical data available for this
Task, e.g. past run logs will no longer be accessible. | [
"Change",
"the",
"name",
"of",
"a",
"Task",
"owned",
"by",
"this",
"Job",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L508-L547 | train |
thieman/dagobah | dagobah/core/core.py | Job._complete_task | def _complete_task(self, task_name, **kwargs):
""" Marks this task as completed. Kwargs are stored in the run log. """
logger.debug('Job {0} marking task {1} as completed'.format(self.name, task_name))
self.run_log['tasks'][task_name] = kwargs
for node in self.downstream(task_name, sel... | python | def _complete_task(self, task_name, **kwargs):
""" Marks this task as completed. Kwargs are stored in the run log. """
logger.debug('Job {0} marking task {1} as completed'.format(self.name, task_name))
self.run_log['tasks'][task_name] = kwargs
for node in self.downstream(task_name, sel... | [
"def",
"_complete_task",
"(",
"self",
",",
"task_name",
",",
"**",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"'Job {0} marking task {1} as completed'",
".",
"format",
"(",
"self",
".",
"name",
",",
"task_name",
")",
")",
"self",
".",
"run_log",
"[",
... | Marks this task as completed. Kwargs are stored in the run log. | [
"Marks",
"this",
"task",
"as",
"completed",
".",
"Kwargs",
"are",
"stored",
"in",
"the",
"run",
"log",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L550-L579 | train |
thieman/dagobah | dagobah/core/core.py | Job._put_task_in_run_log | def _put_task_in_run_log(self, task_name):
""" Initializes the run log task entry for this task. """
logger.debug('Job {0} initializing run log entry for task {1}'.format(self.name, task_name))
data = {'start_time': datetime.utcnow(),
'command': self.tasks[task_name].command}
... | python | def _put_task_in_run_log(self, task_name):
""" Initializes the run log task entry for this task. """
logger.debug('Job {0} initializing run log entry for task {1}'.format(self.name, task_name))
data = {'start_time': datetime.utcnow(),
'command': self.tasks[task_name].command}
... | [
"def",
"_put_task_in_run_log",
"(",
"self",
",",
"task_name",
")",
":",
"logger",
".",
"debug",
"(",
"'Job {0} initializing run log entry for task {1}'",
".",
"format",
"(",
"self",
".",
"name",
",",
"task_name",
")",
")",
"data",
"=",
"{",
"'start_time'",
":",
... | Initializes the run log task entry for this task. | [
"Initializes",
"the",
"run",
"log",
"task",
"entry",
"for",
"this",
"task",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L582-L587 | train |
thieman/dagobah | dagobah/core/core.py | Job._on_completion | def _on_completion(self):
""" Checks to see if the Job has completed, and cleans up if it has. """
logger.debug('Job {0} running _on_completion check'.format(self.name))
if self.state.status != 'running' or (not self._is_complete()):
return
for job, results in self.run_log[... | python | def _on_completion(self):
""" Checks to see if the Job has completed, and cleans up if it has. """
logger.debug('Job {0} running _on_completion check'.format(self.name))
if self.state.status != 'running' or (not self._is_complete()):
return
for job, results in self.run_log[... | [
"def",
"_on_completion",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'Job {0} running _on_completion check'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"if",
"self",
".",
"state",
".",
"status",
"!=",
"'running'",
"or",
"(",
"not",
"self"... | Checks to see if the Job has completed, and cleans up if it has. | [
"Checks",
"to",
"see",
"if",
"the",
"Job",
"has",
"completed",
"and",
"cleans",
"up",
"if",
"it",
"has",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L597-L631 | train |
thieman/dagobah | dagobah/core/core.py | Job._start_if_ready | def _start_if_ready(self, task_name):
""" Start this task if all its dependencies finished successfully. """
logger.debug('Job {0} running _start_if_ready for task {1}'.format(self.name, task_name))
task = self.tasks[task_name]
dependencies = self._dependencies(task_name, self.snapshot)
... | python | def _start_if_ready(self, task_name):
""" Start this task if all its dependencies finished successfully. """
logger.debug('Job {0} running _start_if_ready for task {1}'.format(self.name, task_name))
task = self.tasks[task_name]
dependencies = self._dependencies(task_name, self.snapshot)
... | [
"def",
"_start_if_ready",
"(",
"self",
",",
"task_name",
")",
":",
"logger",
".",
"debug",
"(",
"'Job {0} running _start_if_ready for task {1}'",
".",
"format",
"(",
"self",
".",
"name",
",",
"task_name",
")",
")",
"task",
"=",
"self",
".",
"tasks",
"[",
"ta... | Start this task if all its dependencies finished successfully. | [
"Start",
"this",
"task",
"if",
"all",
"its",
"dependencies",
"finished",
"successfully",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L634-L644 | train |
thieman/dagobah | dagobah/core/core.py | Job._commit_run_log | def _commit_run_log(self):
"""" Commit the current run log to the backend. """
logger.debug('Committing run log for job {0}'.format(self.name))
self.backend.commit_log(self.run_log) | python | def _commit_run_log(self):
"""" Commit the current run log to the backend. """
logger.debug('Committing run log for job {0}'.format(self.name))
self.backend.commit_log(self.run_log) | [
"def",
"_commit_run_log",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'Committing run log for job {0}'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"self",
".",
"backend",
".",
"commit_log",
"(",
"self",
".",
"run_log",
")"
] | Commit the current run log to the backend. | [
"Commit",
"the",
"current",
"run",
"log",
"to",
"the",
"backend",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L655-L658 | train |
thieman/dagobah | dagobah/core/core.py | Job._serialize | def _serialize(self, include_run_logs=False, strict_json=False):
""" Serialize a representation of this Job to a Python dict object. """
# return tasks in sorted order if graph is in a valid state
try:
topo_sorted = self.topological_sort()
t = [self.tasks[task]._serializ... | python | def _serialize(self, include_run_logs=False, strict_json=False):
""" Serialize a representation of this Job to a Python dict object. """
# return tasks in sorted order if graph is in a valid state
try:
topo_sorted = self.topological_sort()
t = [self.tasks[task]._serializ... | [
"def",
"_serialize",
"(",
"self",
",",
"include_run_logs",
"=",
"False",
",",
"strict_json",
"=",
"False",
")",
":",
"try",
":",
"topo_sorted",
"=",
"self",
".",
"topological_sort",
"(",
")",
"t",
"=",
"[",
"self",
".",
"tasks",
"[",
"task",
"]",
".",
... | Serialize a representation of this Job to a Python dict object. | [
"Serialize",
"a",
"representation",
"of",
"this",
"Job",
"to",
"a",
"Python",
"dict",
"object",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L661-L691 | train |
thieman/dagobah | dagobah/core/core.py | Job.initialize_snapshot | def initialize_snapshot(self):
""" Copy the DAG and validate """
logger.debug('Initializing DAG snapshot for job {0}'.format(self.name))
if self.snapshot is not None:
logging.warn("Attempting to initialize DAG snapshot without " +
"first destroying old snapsh... | python | def initialize_snapshot(self):
""" Copy the DAG and validate """
logger.debug('Initializing DAG snapshot for job {0}'.format(self.name))
if self.snapshot is not None:
logging.warn("Attempting to initialize DAG snapshot without " +
"first destroying old snapsh... | [
"def",
"initialize_snapshot",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'Initializing DAG snapshot for job {0}'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"if",
"self",
".",
"snapshot",
"is",
"not",
"None",
":",
"logging",
".",
"warn",
... | Copy the DAG and validate | [
"Copy",
"the",
"DAG",
"and",
"validate"
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L693-L706 | train |
thieman/dagobah | dagobah/core/core.py | Task.reset | def reset(self):
""" Reset this Task to a clean state prior to execution. """
logger.debug('Resetting task {0}'.format(self.name))
self.stdout_file = os.tmpfile()
self.stderr_file = os.tmpfile()
self.stdout = ""
self.stderr = ""
self.started_at = None
... | python | def reset(self):
""" Reset this Task to a clean state prior to execution. """
logger.debug('Resetting task {0}'.format(self.name))
self.stdout_file = os.tmpfile()
self.stderr_file = os.tmpfile()
self.stdout = ""
self.stderr = ""
self.started_at = None
... | [
"def",
"reset",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'Resetting task {0}'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"self",
".",
"stdout_file",
"=",
"os",
".",
"tmpfile",
"(",
")",
"self",
".",
"stderr_file",
"=",
"os",
"."... | Reset this Task to a clean state prior to execution. | [
"Reset",
"this",
"Task",
"to",
"a",
"clean",
"state",
"prior",
"to",
"execution",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L774-L791 | train |
thieman/dagobah | dagobah/core/core.py | Task.start | def start(self):
""" Begin execution of this task. """
logger.info('Starting task {0}'.format(self.name))
self.reset()
if self.hostname:
host = self.parent_job.parent.get_host(self.hostname)
if host:
self.remote_ssh(host)
else:
... | python | def start(self):
""" Begin execution of this task. """
logger.info('Starting task {0}'.format(self.name))
self.reset()
if self.hostname:
host = self.parent_job.parent.get_host(self.hostname)
if host:
self.remote_ssh(host)
else:
... | [
"def",
"start",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Starting task {0}'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"self",
".",
"reset",
"(",
")",
"if",
"self",
".",
"hostname",
":",
"host",
"=",
"self",
".",
"parent_job",
... | Begin execution of this task. | [
"Begin",
"execution",
"of",
"this",
"task",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L793-L811 | train |
thieman/dagobah | dagobah/core/core.py | Task.remote_ssh | def remote_ssh(self, host):
""" Execute a command on SSH. Takes a paramiko host dict """
logger.info('Starting remote execution of task {0} on host {1}'.format(self.name, host['hostname']))
try:
self.remote_client = paramiko.SSHClient()
self.remote_client.load_system_host... | python | def remote_ssh(self, host):
""" Execute a command on SSH. Takes a paramiko host dict """
logger.info('Starting remote execution of task {0} on host {1}'.format(self.name, host['hostname']))
try:
self.remote_client = paramiko.SSHClient()
self.remote_client.load_system_host... | [
"def",
"remote_ssh",
"(",
"self",
",",
"host",
")",
":",
"logger",
".",
"info",
"(",
"'Starting remote execution of task {0} on host {1}'",
".",
"format",
"(",
"self",
".",
"name",
",",
"host",
"[",
"'hostname'",
"]",
")",
")",
"try",
":",
"self",
".",
"re... | Execute a command on SSH. Takes a paramiko host dict | [
"Execute",
"a",
"command",
"on",
"SSH",
".",
"Takes",
"a",
"paramiko",
"host",
"dict"
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L813-L841 | train |
thieman/dagobah | dagobah/core/core.py | Task.check_complete | def check_complete(self):
""" Runs completion flow for this task if it's finished. """
logger.debug('Running check_complete for task {0}'.format(self.name))
# Tasks not completed
if self.remote_not_complete() or self.local_not_complete():
self._start_check_timer()
... | python | def check_complete(self):
""" Runs completion flow for this task if it's finished. """
logger.debug('Running check_complete for task {0}'.format(self.name))
# Tasks not completed
if self.remote_not_complete() or self.local_not_complete():
self._start_check_timer()
... | [
"def",
"check_complete",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'Running check_complete for task {0}'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"if",
"self",
".",
"remote_not_complete",
"(",
")",
"or",
"self",
".",
"local_not_complete"... | Runs completion flow for this task if it's finished. | [
"Runs",
"completion",
"flow",
"for",
"this",
"task",
"if",
"it",
"s",
"finished",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L843-L871 | train |
thieman/dagobah | dagobah/core/core.py | Task.remote_not_complete | def remote_not_complete(self):
"""
Returns True if this task is on a remote channel, and on a remote
machine, False if it is either not remote or not completed
"""
if self.remote_channel and not self.remote_channel.exit_status_ready():
self._timeout_check()
... | python | def remote_not_complete(self):
"""
Returns True if this task is on a remote channel, and on a remote
machine, False if it is either not remote or not completed
"""
if self.remote_channel and not self.remote_channel.exit_status_ready():
self._timeout_check()
... | [
"def",
"remote_not_complete",
"(",
"self",
")",
":",
"if",
"self",
".",
"remote_channel",
"and",
"not",
"self",
".",
"remote_channel",
".",
"exit_status_ready",
"(",
")",
":",
"self",
".",
"_timeout_check",
"(",
")",
"if",
"self",
".",
"remote_channel",
".",... | Returns True if this task is on a remote channel, and on a remote
machine, False if it is either not remote or not completed | [
"Returns",
"True",
"if",
"this",
"task",
"is",
"on",
"a",
"remote",
"channel",
"and",
"on",
"a",
"remote",
"machine",
"False",
"if",
"it",
"is",
"either",
"not",
"remote",
"or",
"not",
"completed"
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L873-L886 | train |
thieman/dagobah | dagobah/core/core.py | Task.local_not_complete | def local_not_complete(self):
""" Returns True if task is local and not completed"""
if self.process and self.process.poll() is None:
self._timeout_check()
return True
return False | python | def local_not_complete(self):
""" Returns True if task is local and not completed"""
if self.process and self.process.poll() is None:
self._timeout_check()
return True
return False | [
"def",
"local_not_complete",
"(",
"self",
")",
":",
"if",
"self",
".",
"process",
"and",
"self",
".",
"process",
".",
"poll",
"(",
")",
"is",
"None",
":",
"self",
".",
"_timeout_check",
"(",
")",
"return",
"True",
"return",
"False"
] | Returns True if task is local and not completed | [
"Returns",
"True",
"if",
"task",
"is",
"local",
"and",
"not",
"completed"
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L888-L893 | train |
thieman/dagobah | dagobah/core/core.py | Task.completed_task | def completed_task(self):
""" Handle wrapping up a completed task, local or remote"""
# If its remote and finished running
if self.remote_channel and self.remote_channel.exit_status_ready():
# Collect all remaining stdout/stderr
while self.remote_channel.recv_ready():
... | python | def completed_task(self):
""" Handle wrapping up a completed task, local or remote"""
# If its remote and finished running
if self.remote_channel and self.remote_channel.exit_status_ready():
# Collect all remaining stdout/stderr
while self.remote_channel.recv_ready():
... | [
"def",
"completed_task",
"(",
"self",
")",
":",
"if",
"self",
".",
"remote_channel",
"and",
"self",
".",
"remote_channel",
".",
"exit_status_ready",
"(",
")",
":",
"while",
"self",
".",
"remote_channel",
".",
"recv_ready",
"(",
")",
":",
"self",
".",
"stdo... | Handle wrapping up a completed task, local or remote | [
"Handle",
"wrapping",
"up",
"a",
"completed",
"task",
"local",
"or",
"remote"
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L895-L911 | train |
thieman/dagobah | dagobah/core/core.py | Task.terminate | def terminate(self):
""" Send SIGTERM to the task's process. """
logger.info('Sending SIGTERM to task {0}'.format(self.name))
if hasattr(self, 'remote_client') and self.remote_client is not None:
self.terminate_sent = True
self.remote_client.close()
return
... | python | def terminate(self):
""" Send SIGTERM to the task's process. """
logger.info('Sending SIGTERM to task {0}'.format(self.name))
if hasattr(self, 'remote_client') and self.remote_client is not None:
self.terminate_sent = True
self.remote_client.close()
return
... | [
"def",
"terminate",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Sending SIGTERM to task {0}'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"if",
"hasattr",
"(",
"self",
",",
"'remote_client'",
")",
"and",
"self",
".",
"remote_client",
"is",... | Send SIGTERM to the task's process. | [
"Send",
"SIGTERM",
"to",
"the",
"task",
"s",
"process",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L913-L923 | train |
thieman/dagobah | dagobah/core/core.py | Task.kill | def kill(self):
""" Send SIGKILL to the task's process. """
logger.info('Sending SIGKILL to task {0}'.format(self.name))
if hasattr(self, 'remote_client') and self.remote_client is not None:
self.kill_sent = True
self.remote_client.close()
return
if no... | python | def kill(self):
""" Send SIGKILL to the task's process. """
logger.info('Sending SIGKILL to task {0}'.format(self.name))
if hasattr(self, 'remote_client') and self.remote_client is not None:
self.kill_sent = True
self.remote_client.close()
return
if no... | [
"def",
"kill",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Sending SIGKILL to task {0}'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"if",
"hasattr",
"(",
"self",
",",
"'remote_client'",
")",
"and",
"self",
".",
"remote_client",
"is",
"n... | Send SIGKILL to the task's process. | [
"Send",
"SIGKILL",
"to",
"the",
"task",
"s",
"process",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L926-L936 | train |
thieman/dagobah | dagobah/core/core.py | Task._start_check_timer | def _start_check_timer(self):
""" Periodically checks to see if the task has completed. """
if self.timer:
self.timer.cancel()
self.timer = threading.Timer(2.5, self.check_complete)
self.timer.daemon = True
self.timer.start() | python | def _start_check_timer(self):
""" Periodically checks to see if the task has completed. """
if self.timer:
self.timer.cancel()
self.timer = threading.Timer(2.5, self.check_complete)
self.timer.daemon = True
self.timer.start() | [
"def",
"_start_check_timer",
"(",
"self",
")",
":",
"if",
"self",
".",
"timer",
":",
"self",
".",
"timer",
".",
"cancel",
"(",
")",
"self",
".",
"timer",
"=",
"threading",
".",
"Timer",
"(",
"2.5",
",",
"self",
".",
"check_complete",
")",
"self",
"."... | Periodically checks to see if the task has completed. | [
"Periodically",
"checks",
"to",
"see",
"if",
"the",
"task",
"has",
"completed",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L1004-L1010 | train |
thieman/dagobah | dagobah/core/core.py | Task._head_temp_file | def _head_temp_file(self, temp_file, num_lines):
""" Returns a list of the first num_lines lines from a temp file. """
if not isinstance(num_lines, int):
raise DagobahError('num_lines must be an integer')
temp_file.seek(0)
result, curr_line = [], 0
for line in temp_fi... | python | def _head_temp_file(self, temp_file, num_lines):
""" Returns a list of the first num_lines lines from a temp file. """
if not isinstance(num_lines, int):
raise DagobahError('num_lines must be an integer')
temp_file.seek(0)
result, curr_line = [], 0
for line in temp_fi... | [
"def",
"_head_temp_file",
"(",
"self",
",",
"temp_file",
",",
"num_lines",
")",
":",
"if",
"not",
"isinstance",
"(",
"num_lines",
",",
"int",
")",
":",
"raise",
"DagobahError",
"(",
"'num_lines must be an integer'",
")",
"temp_file",
".",
"seek",
"(",
"0",
"... | Returns a list of the first num_lines lines from a temp file. | [
"Returns",
"a",
"list",
"of",
"the",
"first",
"num_lines",
"lines",
"from",
"a",
"temp",
"file",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L1030-L1041 | train |
thieman/dagobah | dagobah/core/core.py | Task._tail_temp_file | def _tail_temp_file(self, temp_file, num_lines, seek_offset=10000):
""" Returns a list of the last num_lines lines from a temp file.
This works by first moving seek_offset chars back from the end of
the file, then attempting to tail the file from there. It is
possible that fewer than nu... | python | def _tail_temp_file(self, temp_file, num_lines, seek_offset=10000):
""" Returns a list of the last num_lines lines from a temp file.
This works by first moving seek_offset chars back from the end of
the file, then attempting to tail the file from there. It is
possible that fewer than nu... | [
"def",
"_tail_temp_file",
"(",
"self",
",",
"temp_file",
",",
"num_lines",
",",
"seek_offset",
"=",
"10000",
")",
":",
"if",
"not",
"isinstance",
"(",
"num_lines",
",",
"int",
")",
":",
"raise",
"DagobahError",
"(",
"'num_lines must be an integer'",
")",
"temp... | Returns a list of the last num_lines lines from a temp file.
This works by first moving seek_offset chars back from the end of
the file, then attempting to tail the file from there. It is
possible that fewer than num_lines will be returned, even if the
file has more total lines than num... | [
"Returns",
"a",
"list",
"of",
"the",
"last",
"num_lines",
"lines",
"from",
"a",
"temp",
"file",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L1044-L1068 | train |
thieman/dagobah | dagobah/core/core.py | Task._task_complete | def _task_complete(self, **kwargs):
""" Performs cleanup tasks and notifies Job that the Task finished. """
logger.debug('Running _task_complete for task {0}'.format(self.name))
with self.parent_job.completion_lock:
self.completed_at = datetime.utcnow()
self.successful = ... | python | def _task_complete(self, **kwargs):
""" Performs cleanup tasks and notifies Job that the Task finished. """
logger.debug('Running _task_complete for task {0}'.format(self.name))
with self.parent_job.completion_lock:
self.completed_at = datetime.utcnow()
self.successful = ... | [
"def",
"_task_complete",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"'Running _task_complete for task {0}'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"with",
"self",
".",
"parent_job",
".",
"completion_lock",
":",
"sel... | Performs cleanup tasks and notifies Job that the Task finished. | [
"Performs",
"cleanup",
"tasks",
"and",
"notifies",
"Job",
"that",
"the",
"Task",
"finished",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L1071-L1077 | train |
thieman/dagobah | dagobah/core/core.py | Task._serialize | def _serialize(self, include_run_logs=False, strict_json=False):
""" Serialize a representation of this Task to a Python dict. """
result = {'command': self.command,
'name': self.name,
'started_at': self.started_at,
'completed_at': self.completed_at... | python | def _serialize(self, include_run_logs=False, strict_json=False):
""" Serialize a representation of this Task to a Python dict. """
result = {'command': self.command,
'name': self.name,
'started_at': self.started_at,
'completed_at': self.completed_at... | [
"def",
"_serialize",
"(",
"self",
",",
"include_run_logs",
"=",
"False",
",",
"strict_json",
"=",
"False",
")",
":",
"result",
"=",
"{",
"'command'",
":",
"self",
".",
"command",
",",
"'name'",
":",
"self",
".",
"name",
",",
"'started_at'",
":",
"self",
... | Serialize a representation of this Task to a Python dict. | [
"Serialize",
"a",
"representation",
"of",
"this",
"Task",
"to",
"a",
"Python",
"dict",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L1080-L1102 | train |
thieman/dagobah | dagobah/daemon/auth.py | do_login | def do_login():
""" Attempt to auth using single login. Rate limited at the site level. """
dt_filter = lambda x: x >= datetime.utcnow() - timedelta(seconds=60)
app.config['AUTH_ATTEMPTS'] = filter(dt_filter, app.config['AUTH_ATTEMPTS'])
if len(app.config['AUTH_ATTEMPTS']) > app.config['AUTH_RATE_LIMI... | python | def do_login():
""" Attempt to auth using single login. Rate limited at the site level. """
dt_filter = lambda x: x >= datetime.utcnow() - timedelta(seconds=60)
app.config['AUTH_ATTEMPTS'] = filter(dt_filter, app.config['AUTH_ATTEMPTS'])
if len(app.config['AUTH_ATTEMPTS']) > app.config['AUTH_RATE_LIMI... | [
"def",
"do_login",
"(",
")",
":",
"dt_filter",
"=",
"lambda",
"x",
":",
"x",
">=",
"datetime",
".",
"utcnow",
"(",
")",
"-",
"timedelta",
"(",
"seconds",
"=",
"60",
")",
"app",
".",
"config",
"[",
"'AUTH_ATTEMPTS'",
"]",
"=",
"filter",
"(",
"dt_filte... | Attempt to auth using single login. Rate limited at the site level. | [
"Attempt",
"to",
"auth",
"using",
"single",
"login",
".",
"Rate",
"limited",
"at",
"the",
"site",
"level",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/daemon/auth.py#L28-L43 | train |
thieman/dagobah | dagobah/__init__.py | return_standard_conf | def return_standard_conf():
""" Return the sample config file. """
result = resource_string(__name__, 'daemon/dagobahd.yml')
result = result % {'app_secret': os.urandom(24).encode('hex')}
return result | python | def return_standard_conf():
""" Return the sample config file. """
result = resource_string(__name__, 'daemon/dagobahd.yml')
result = result % {'app_secret': os.urandom(24).encode('hex')}
return result | [
"def",
"return_standard_conf",
"(",
")",
":",
"result",
"=",
"resource_string",
"(",
"__name__",
",",
"'daemon/dagobahd.yml'",
")",
"result",
"=",
"result",
"%",
"{",
"'app_secret'",
":",
"os",
".",
"urandom",
"(",
"24",
")",
".",
"encode",
"(",
"'hex'",
"... | Return the sample config file. | [
"Return",
"the",
"sample",
"config",
"file",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/__init__.py#L10-L14 | train |
thieman/dagobah | dagobah/daemon/views.py | job_detail | def job_detail(job_id=None):
""" Show a detailed description of a Job's status. """
jobs = [job for job in get_jobs() if str(job['job_id']) == job_id]
if not jobs:
abort(404)
return render_template('job_detail.html', job=jobs[0], hosts=dagobah.get_hosts()) | python | def job_detail(job_id=None):
""" Show a detailed description of a Job's status. """
jobs = [job for job in get_jobs() if str(job['job_id']) == job_id]
if not jobs:
abort(404)
return render_template('job_detail.html', job=jobs[0], hosts=dagobah.get_hosts()) | [
"def",
"job_detail",
"(",
"job_id",
"=",
"None",
")",
":",
"jobs",
"=",
"[",
"job",
"for",
"job",
"in",
"get_jobs",
"(",
")",
"if",
"str",
"(",
"job",
"[",
"'job_id'",
"]",
")",
"==",
"job_id",
"]",
"if",
"not",
"jobs",
":",
"abort",
"(",
"404",
... | Show a detailed description of a Job's status. | [
"Show",
"a",
"detailed",
"description",
"of",
"a",
"Job",
"s",
"status",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/daemon/views.py#L33-L38 | train |
thieman/dagobah | dagobah/daemon/views.py | task_detail | def task_detail(job_id=None, task_name=None):
""" Show a detailed description of a specific task. """
jobs = get_jobs()
job = [job for job in jobs if str(job['job_id']) == job_id][0]
return render_template('task_detail.html',
job=job,
task_name=task_... | python | def task_detail(job_id=None, task_name=None):
""" Show a detailed description of a specific task. """
jobs = get_jobs()
job = [job for job in jobs if str(job['job_id']) == job_id][0]
return render_template('task_detail.html',
job=job,
task_name=task_... | [
"def",
"task_detail",
"(",
"job_id",
"=",
"None",
",",
"task_name",
"=",
"None",
")",
":",
"jobs",
"=",
"get_jobs",
"(",
")",
"job",
"=",
"[",
"job",
"for",
"job",
"in",
"jobs",
"if",
"str",
"(",
"job",
"[",
"'job_id'",
"]",
")",
"==",
"job_id",
... | Show a detailed description of a specific task. | [
"Show",
"a",
"detailed",
"description",
"of",
"a",
"specific",
"task",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/daemon/views.py#L42-L50 | train |
thieman/dagobah | dagobah/daemon/views.py | log_detail | def log_detail(job_id=None, task_name=None, log_id=None):
""" Show a detailed description of a specific log. """
jobs = get_jobs()
job = [job for job in jobs if str(job['job_id']) == job_id][0]
return render_template('log_detail.html',
job=job,
... | python | def log_detail(job_id=None, task_name=None, log_id=None):
""" Show a detailed description of a specific log. """
jobs = get_jobs()
job = [job for job in jobs if str(job['job_id']) == job_id][0]
return render_template('log_detail.html',
job=job,
... | [
"def",
"log_detail",
"(",
"job_id",
"=",
"None",
",",
"task_name",
"=",
"None",
",",
"log_id",
"=",
"None",
")",
":",
"jobs",
"=",
"get_jobs",
"(",
")",
"job",
"=",
"[",
"job",
"for",
"job",
"in",
"jobs",
"if",
"str",
"(",
"job",
"[",
"'job_id'",
... | Show a detailed description of a specific log. | [
"Show",
"a",
"detailed",
"description",
"of",
"a",
"specific",
"log",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/daemon/views.py#L54-L63 | train |
thieman/dagobah | dagobah/email/text.py | TextEmail._task_to_text | def _task_to_text(self, task):
""" Return a standard formatting of a Task serialization. """
started = self._format_date(task.get('started_at', None))
completed = self._format_date(task.get('completed_at', None))
success = task.get('success', None)
success_lu = {None: 'Not exec... | python | def _task_to_text(self, task):
""" Return a standard formatting of a Task serialization. """
started = self._format_date(task.get('started_at', None))
completed = self._format_date(task.get('completed_at', None))
success = task.get('success', None)
success_lu = {None: 'Not exec... | [
"def",
"_task_to_text",
"(",
"self",
",",
"task",
")",
":",
"started",
"=",
"self",
".",
"_format_date",
"(",
"task",
".",
"get",
"(",
"'started_at'",
",",
"None",
")",
")",
"completed",
"=",
"self",
".",
"_format_date",
"(",
"task",
".",
"get",
"(",
... | Return a standard formatting of a Task serialization. | [
"Return",
"a",
"standard",
"formatting",
"of",
"a",
"Task",
"serialization",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/email/text.py#L25-L43 | train |
thieman/dagobah | dagobah/email/text.py | TextEmail._job_to_text | def _job_to_text(self, job):
""" Return a standard formatting of a Job serialization. """
next_run = self._format_date(job.get('next_run', None))
tasks = ''
for task in job.get('tasks', []):
tasks += self._task_to_text(task)
tasks += '\n\n'
return '\n'.... | python | def _job_to_text(self, job):
""" Return a standard formatting of a Job serialization. """
next_run = self._format_date(job.get('next_run', None))
tasks = ''
for task in job.get('tasks', []):
tasks += self._task_to_text(task)
tasks += '\n\n'
return '\n'.... | [
"def",
"_job_to_text",
"(",
"self",
",",
"job",
")",
":",
"next_run",
"=",
"self",
".",
"_format_date",
"(",
"job",
".",
"get",
"(",
"'next_run'",
",",
"None",
")",
")",
"tasks",
"=",
"''",
"for",
"task",
"in",
"job",
".",
"get",
"(",
"'tasks'",
",... | Return a standard formatting of a Job serialization. | [
"Return",
"a",
"standard",
"formatting",
"of",
"a",
"Job",
"serialization",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/email/text.py#L46-L65 | train |
thieman/dagobah | dagobah/email/common.py | EmailTemplate._get_template | def _get_template(self, template_name, template_file):
""" Returns a Jinja2 template of the specified file. """
template = os.path.join(self.location, 'templates',
template_name, template_file)
return jinja2.Template(open(template).read()) | python | def _get_template(self, template_name, template_file):
""" Returns a Jinja2 template of the specified file. """
template = os.path.join(self.location, 'templates',
template_name, template_file)
return jinja2.Template(open(template).read()) | [
"def",
"_get_template",
"(",
"self",
",",
"template_name",
",",
"template_file",
")",
":",
"template",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"location",
",",
"'templates'",
",",
"template_name",
",",
"template_file",
")",
"return",
"jinja2",... | Returns a Jinja2 template of the specified file. | [
"Returns",
"a",
"Jinja2",
"template",
"of",
"the",
"specified",
"file",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/email/common.py#L75-L79 | train |
thieman/dagobah | dagobah/daemon/daemon.py | replace_nones | def replace_nones(dict_or_list):
"""Update a dict or list in place to replace
'none' string values with Python None."""
def replace_none_in_value(value):
if isinstance(value, basestring) and value.lower() == "none":
return None
return value
items = dict_or_list.iteritems() ... | python | def replace_nones(dict_or_list):
"""Update a dict or list in place to replace
'none' string values with Python None."""
def replace_none_in_value(value):
if isinstance(value, basestring) and value.lower() == "none":
return None
return value
items = dict_or_list.iteritems() ... | [
"def",
"replace_nones",
"(",
"dict_or_list",
")",
":",
"def",
"replace_none_in_value",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"basestring",
")",
"and",
"value",
".",
"lower",
"(",
")",
"==",
"\"none\"",
":",
"return",
"None",
"retur... | Update a dict or list in place to replace
'none' string values with Python None. | [
"Update",
"a",
"dict",
"or",
"list",
"in",
"place",
"to",
"replace",
"none",
"string",
"values",
"with",
"Python",
"None",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/daemon/daemon.py#L27-L42 | train |
thieman/dagobah | dagobah/daemon/daemon.py | get_config_file | def get_config_file():
""" Return the loaded config file if one exists. """
# config will be created here if we can't find one
new_config_path = os.path.expanduser('~/.dagobahd.yml')
config_dirs = ['/etc',
os.path.expanduser('~')]
config_filenames = ['dagobahd.yml',
... | python | def get_config_file():
""" Return the loaded config file if one exists. """
# config will be created here if we can't find one
new_config_path = os.path.expanduser('~/.dagobahd.yml')
config_dirs = ['/etc',
os.path.expanduser('~')]
config_filenames = ['dagobahd.yml',
... | [
"def",
"get_config_file",
"(",
")",
":",
"new_config_path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/.dagobahd.yml'",
")",
"config_dirs",
"=",
"[",
"'/etc'",
",",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
"]",
"config_filenames",
"=... | Return the loaded config file if one exists. | [
"Return",
"the",
"loaded",
"config",
"file",
"if",
"one",
"exists",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/daemon/daemon.py#L44-L81 | train |
thieman/dagobah | dagobah/daemon/daemon.py | configure_event_hooks | def configure_event_hooks(config):
""" Returns an EventHandler instance with registered hooks. """
def print_event_info(**kwargs):
print kwargs.get('event_params', {})
def job_complete_email(email_handler, **kwargs):
email_handler.send_job_completed(kwargs['event_params'])
def job_fai... | python | def configure_event_hooks(config):
""" Returns an EventHandler instance with registered hooks. """
def print_event_info(**kwargs):
print kwargs.get('event_params', {})
def job_complete_email(email_handler, **kwargs):
email_handler.send_job_completed(kwargs['event_params'])
def job_fai... | [
"def",
"configure_event_hooks",
"(",
"config",
")",
":",
"def",
"print_event_info",
"(",
"**",
"kwargs",
")",
":",
"print",
"kwargs",
".",
"get",
"(",
"'event_params'",
",",
"{",
"}",
")",
"def",
"job_complete_email",
"(",
"email_handler",
",",
"**",
"kwargs... | Returns an EventHandler instance with registered hooks. | [
"Returns",
"an",
"EventHandler",
"instance",
"with",
"registered",
"hooks",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/daemon/daemon.py#L167-L196 | train |
thieman/dagobah | dagobah/daemon/daemon.py | init_core_logger | def init_core_logger(location, config):
""" Initialize the logger with settings from config. """
logger = logging.getLogger('dagobah')
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
if get_conf(config, 'Logging.Core.enabled', False) == False:
logger.addHa... | python | def init_core_logger(location, config):
""" Initialize the logger with settings from config. """
logger = logging.getLogger('dagobah')
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
if get_conf(config, 'Logging.Core.enabled', False) == False:
logger.addHa... | [
"def",
"init_core_logger",
"(",
"location",
",",
"config",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"'dagobah'",
")",
"formatter",
"=",
"logging",
".",
"Formatter",
"(",
"'%(asctime)s - %(name)s - %(levelname)s - %(message)s'",
")",
"if",
"get_conf... | Initialize the logger with settings from config. | [
"Initialize",
"the",
"logger",
"with",
"settings",
"from",
"config",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/daemon/daemon.py#L199-L234 | train |
thieman/dagobah | dagobah/daemon/daemon.py | get_backend | def get_backend(config):
""" Returns a backend instance based on the Daemon config file. """
backend_string = get_conf(config, 'Dagobahd.backend', None)
if backend_string is None:
from ..backend.base import BaseBackend
return BaseBackend()
elif backend_string.lower() == 'mongo':
... | python | def get_backend(config):
""" Returns a backend instance based on the Daemon config file. """
backend_string = get_conf(config, 'Dagobahd.backend', None)
if backend_string is None:
from ..backend.base import BaseBackend
return BaseBackend()
elif backend_string.lower() == 'mongo':
... | [
"def",
"get_backend",
"(",
"config",
")",
":",
"backend_string",
"=",
"get_conf",
"(",
"config",
",",
"'Dagobahd.backend'",
",",
"None",
")",
"if",
"backend_string",
"is",
"None",
":",
"from",
".",
".",
"backend",
".",
"base",
"import",
"BaseBackend",
"retur... | Returns a backend instance based on the Daemon config file. | [
"Returns",
"a",
"backend",
"instance",
"based",
"on",
"the",
"Daemon",
"config",
"file",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/daemon/daemon.py#L238-L264 | train |
thieman/dagobah | dagobah/daemon/util.py | api_call | def api_call(fn):
""" Returns function result in API format if requested from an API
endpoint """
@wraps(fn)
def wrapper(*args, **kwargs):
try:
result = fn(*args, **kwargs)
except (DagobahError, DAGValidationError) as e:
if request and request.endpoint == fn.__na... | python | def api_call(fn):
""" Returns function result in API format if requested from an API
endpoint """
@wraps(fn)
def wrapper(*args, **kwargs):
try:
result = fn(*args, **kwargs)
except (DagobahError, DAGValidationError) as e:
if request and request.endpoint == fn.__na... | [
"def",
"api_call",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"result",
"=",
"fn",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"except",
"(",
"DagobahError",
... | Returns function result in API format if requested from an API
endpoint | [
"Returns",
"function",
"result",
"in",
"API",
"format",
"if",
"requested",
"from",
"an",
"API",
"endpoint"
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/daemon/util.py#L40-L79 | train |
thieman/dagobah | dagobah/daemon/util.py | validate_dict | def validate_dict(in_dict, **kwargs):
""" Returns Boolean of whether given dict conforms to type specifications
given in kwargs. """
if not isinstance(in_dict, dict):
raise ValueError('requires a dictionary')
for key, value in kwargs.iteritems():
if key == 'required':
for ... | python | def validate_dict(in_dict, **kwargs):
""" Returns Boolean of whether given dict conforms to type specifications
given in kwargs. """
if not isinstance(in_dict, dict):
raise ValueError('requires a dictionary')
for key, value in kwargs.iteritems():
if key == 'required':
for ... | [
"def",
"validate_dict",
"(",
"in_dict",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"in_dict",
",",
"dict",
")",
":",
"raise",
"ValueError",
"(",
"'requires a dictionary'",
")",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"iteritems... | Returns Boolean of whether given dict conforms to type specifications
given in kwargs. | [
"Returns",
"Boolean",
"of",
"whether",
"given",
"dict",
"conforms",
"to",
"type",
"specifications",
"given",
"in",
"kwargs",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/daemon/util.py#L82-L118 | train |
thieman/dagobah | dagobah/backend/mongo.py | MongoBackend.delete_dagobah | def delete_dagobah(self, dagobah_id):
""" Deletes the Dagobah and all child Jobs from the database.
Related run logs are deleted as well.
"""
rec = self.dagobah_coll.find_one({'_id': dagobah_id})
for job in rec.get('jobs', []):
if 'job_id' in job:
se... | python | def delete_dagobah(self, dagobah_id):
""" Deletes the Dagobah and all child Jobs from the database.
Related run logs are deleted as well.
"""
rec = self.dagobah_coll.find_one({'_id': dagobah_id})
for job in rec.get('jobs', []):
if 'job_id' in job:
se... | [
"def",
"delete_dagobah",
"(",
"self",
",",
"dagobah_id",
")",
":",
"rec",
"=",
"self",
".",
"dagobah_coll",
".",
"find_one",
"(",
"{",
"'_id'",
":",
"dagobah_id",
"}",
")",
"for",
"job",
"in",
"rec",
".",
"get",
"(",
"'jobs'",
",",
"[",
"]",
")",
"... | Deletes the Dagobah and all child Jobs from the database.
Related run logs are deleted as well. | [
"Deletes",
"the",
"Dagobah",
"and",
"all",
"child",
"Jobs",
"from",
"the",
"database",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/backend/mongo.py#L96-L107 | train |
thieman/dagobah | dagobah/backend/mongo.py | MongoBackend.commit_log | def commit_log(self, log_json):
""" Commits a run log to the Mongo backend.
Due to limitations of maximum document size in Mongo,
stdout and stderr logs are truncated to a maximum size for
each task.
"""
log_json['_id'] = log_json['log_id']
append = {'save_date'... | python | def commit_log(self, log_json):
""" Commits a run log to the Mongo backend.
Due to limitations of maximum document size in Mongo,
stdout and stderr logs are truncated to a maximum size for
each task.
"""
log_json['_id'] = log_json['log_id']
append = {'save_date'... | [
"def",
"commit_log",
"(",
"self",
",",
"log_json",
")",
":",
"log_json",
"[",
"'_id'",
"]",
"=",
"log_json",
"[",
"'log_id'",
"]",
"append",
"=",
"{",
"'save_date'",
":",
"datetime",
".",
"utcnow",
"(",
")",
"}",
"for",
"task_name",
",",
"values",
"in"... | Commits a run log to the Mongo backend.
Due to limitations of maximum document size in Mongo,
stdout and stderr logs are truncated to a maximum size for
each task. | [
"Commits",
"a",
"run",
"log",
"to",
"the",
"Mongo",
"backend",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/backend/mongo.py#L117-L135 | train |
thieman/dagobah | dagobah/backend/base.py | BaseBackend.decode_import_json | def decode_import_json(self, json_doc, transformers=None):
""" Decode a JSON string based on a list of transformers.
Each transformer is a pair of ([conditional], transformer). If
all conditionals are met on each non-list, non-dict object,
the transformer tries to apply itself.
... | python | def decode_import_json(self, json_doc, transformers=None):
""" Decode a JSON string based on a list of transformers.
Each transformer is a pair of ([conditional], transformer). If
all conditionals are met on each non-list, non-dict object,
the transformer tries to apply itself.
... | [
"def",
"decode_import_json",
"(",
"self",
",",
"json_doc",
",",
"transformers",
"=",
"None",
")",
":",
"def",
"custom_decoder",
"(",
"dct",
")",
":",
"def",
"transform",
"(",
"o",
")",
":",
"if",
"not",
"transformers",
":",
"return",
"o",
"for",
"conditi... | Decode a JSON string based on a list of transformers.
Each transformer is a pair of ([conditional], transformer). If
all conditionals are met on each non-list, non-dict object,
the transformer tries to apply itself.
conditional: Callable that returns a Bool.
transformer: Callab... | [
"Decode",
"a",
"JSON",
"string",
"based",
"on",
"a",
"list",
"of",
"transformers",
"."
] | e624180c2291034960302c9e0b818b65b5a7ee11 | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/backend/base.py#L82-L132 | train |
singingwolfboy/flask-sse | flask_sse.py | ServerSentEventsBlueprint.publish | def publish(self, data, type=None, id=None, retry=None, channel='sse'):
"""
Publish data as a server-sent event.
:param data: The event data. If it is not a string, it will be
serialized to JSON using the Flask application's
:class:`~flask.json.JSONEncoder`.
:par... | python | def publish(self, data, type=None, id=None, retry=None, channel='sse'):
"""
Publish data as a server-sent event.
:param data: The event data. If it is not a string, it will be
serialized to JSON using the Flask application's
:class:`~flask.json.JSONEncoder`.
:par... | [
"def",
"publish",
"(",
"self",
",",
"data",
",",
"type",
"=",
"None",
",",
"id",
"=",
"None",
",",
"retry",
"=",
"None",
",",
"channel",
"=",
"'sse'",
")",
":",
"message",
"=",
"Message",
"(",
"data",
",",
"type",
"=",
"type",
",",
"id",
"=",
"... | Publish data as a server-sent event.
:param data: The event data. If it is not a string, it will be
serialized to JSON using the Flask application's
:class:`~flask.json.JSONEncoder`.
:param type: An optional event type.
:param id: An optional event ID.
:param ret... | [
"Publish",
"data",
"as",
"a",
"server",
"-",
"sent",
"event",
"."
] | a5c6afe12cd3c29c90588ad8a2c698c829af6572 | https://github.com/singingwolfboy/flask-sse/blob/a5c6afe12cd3c29c90588ad8a2c698c829af6572/flask_sse.py#L112-L130 | train |
rconradharris/envparse | envparse.py | Env.cast | def cast(cls, value, cast=str, subcast=None):
"""
Parse and cast provided value.
:param value: Stringed value.
:param cast: Type or callable to cast return value as.
:param subcast: Subtype or callable to cast return values as (used for
nested structures)... | python | def cast(cls, value, cast=str, subcast=None):
"""
Parse and cast provided value.
:param value: Stringed value.
:param cast: Type or callable to cast return value as.
:param subcast: Subtype or callable to cast return values as (used for
nested structures)... | [
"def",
"cast",
"(",
"cls",
",",
"value",
",",
"cast",
"=",
"str",
",",
"subcast",
"=",
"None",
")",
":",
"if",
"cast",
"is",
"bool",
":",
"value",
"=",
"value",
".",
"lower",
"(",
")",
"in",
"cls",
".",
"BOOLEAN_TRUE_STRINGS",
"elif",
"cast",
"is",... | Parse and cast provided value.
:param value: Stringed value.
:param cast: Type or callable to cast return value as.
:param subcast: Subtype or callable to cast return values as (used for
nested structures).
:returns: Value of type `cast`. | [
"Parse",
"and",
"cast",
"provided",
"value",
"."
] | e67e70307af19d925e194b2a163e0608dae7eb55 | https://github.com/rconradharris/envparse/blob/e67e70307af19d925e194b2a163e0608dae7eb55/envparse.py#L117-L152 | train |
chishui/terminal-leetcode | leetcode/terminal.py | Terminal.reload_list | def reload_list(self):
'''Press R in home view to retrieve quiz list'''
self.leetcode.load()
if self.leetcode.quizzes and len(self.leetcode.quizzes) > 0:
self.home_view = self.make_listview(self.leetcode.quizzes)
self.view_stack = []
self.goto_view(self.home_v... | python | def reload_list(self):
'''Press R in home view to retrieve quiz list'''
self.leetcode.load()
if self.leetcode.quizzes and len(self.leetcode.quizzes) > 0:
self.home_view = self.make_listview(self.leetcode.quizzes)
self.view_stack = []
self.goto_view(self.home_v... | [
"def",
"reload_list",
"(",
"self",
")",
":",
"self",
".",
"leetcode",
".",
"load",
"(",
")",
"if",
"self",
".",
"leetcode",
".",
"quizzes",
"and",
"len",
"(",
"self",
".",
"leetcode",
".",
"quizzes",
")",
">",
"0",
":",
"self",
".",
"home_view",
"=... | Press R in home view to retrieve quiz list | [
"Press",
"R",
"in",
"home",
"view",
"to",
"retrieve",
"quiz",
"list"
] | ad81924dbcac13da736f89a3b693ba13f2361906 | https://github.com/chishui/terminal-leetcode/blob/ad81924dbcac13da736f89a3b693ba13f2361906/leetcode/terminal.py#L116-L122 | train |
materialsvirtuallab/pyhull | pyhull/delaunay.py | DelaunayTri.simplices | def simplices(self):
"""
Returns the simplices of the triangulation.
"""
return [Simplex([self.points[i] for i in v]) for v in self.vertices] | python | def simplices(self):
"""
Returns the simplices of the triangulation.
"""
return [Simplex([self.points[i] for i in v]) for v in self.vertices] | [
"def",
"simplices",
"(",
"self",
")",
":",
"return",
"[",
"Simplex",
"(",
"[",
"self",
".",
"points",
"[",
"i",
"]",
"for",
"i",
"in",
"v",
"]",
")",
"for",
"v",
"in",
"self",
".",
"vertices",
"]"
] | Returns the simplices of the triangulation. | [
"Returns",
"the",
"simplices",
"of",
"the",
"triangulation",
"."
] | 01d4ee2c108ab3d8faa9b9ff476290ffee90073f | https://github.com/materialsvirtuallab/pyhull/blob/01d4ee2c108ab3d8faa9b9ff476290ffee90073f/pyhull/delaunay.py#L62-L66 | train |
materialsvirtuallab/pyhull | pyhull/__init__.py | qhull_cmd | def qhull_cmd(cmd, options, points):
"""
Generalized helper method to perform a qhull based command.
Args:
cmd:
Command to perform. Supported commands are qconvex,
qdelaunay and qvoronoi.
options:
Options to be provided for qhull command. See specific met... | python | def qhull_cmd(cmd, options, points):
"""
Generalized helper method to perform a qhull based command.
Args:
cmd:
Command to perform. Supported commands are qconvex,
qdelaunay and qvoronoi.
options:
Options to be provided for qhull command. See specific met... | [
"def",
"qhull_cmd",
"(",
"cmd",
",",
"options",
",",
"points",
")",
":",
"prep_str",
"=",
"[",
"str",
"(",
"len",
"(",
"points",
"[",
"0",
"]",
")",
")",
",",
"str",
"(",
"len",
"(",
"points",
")",
")",
"]",
"prep_str",
".",
"extend",
"(",
"[",... | Generalized helper method to perform a qhull based command.
Args:
cmd:
Command to perform. Supported commands are qconvex,
qdelaunay and qvoronoi.
options:
Options to be provided for qhull command. See specific methods for
info on supported options. U... | [
"Generalized",
"helper",
"method",
"to",
"perform",
"a",
"qhull",
"based",
"command",
"."
] | 01d4ee2c108ab3d8faa9b9ff476290ffee90073f | https://github.com/materialsvirtuallab/pyhull/blob/01d4ee2c108ab3d8faa9b9ff476290ffee90073f/pyhull/__init__.py#L19-L40 | train |
materialsvirtuallab/pyhull | pyhull/__init__.py | qhalf | def qhalf(options, halfspaces, interior_point):
"""
Similar to qvoronoi command in command-line qhull.
Args:
option:
An options string. Up to two options separated by spaces
are supported. See Qhull's qhalf help for info. Typically
used options are:
F... | python | def qhalf(options, halfspaces, interior_point):
"""
Similar to qvoronoi command in command-line qhull.
Args:
option:
An options string. Up to two options separated by spaces
are supported. See Qhull's qhalf help for info. Typically
used options are:
F... | [
"def",
"qhalf",
"(",
"options",
",",
"halfspaces",
",",
"interior_point",
")",
":",
"points",
"=",
"[",
"list",
"(",
"h",
".",
"normal",
")",
"+",
"[",
"h",
".",
"offset",
"]",
"for",
"h",
"in",
"halfspaces",
"]",
"data",
"=",
"[",
"[",
"len",
"(... | Similar to qvoronoi command in command-line qhull.
Args:
option:
An options string. Up to two options separated by spaces
are supported. See Qhull's qhalf help for info. Typically
used options are:
Fp
halfspaces:
List of Halfspaces as inpu... | [
"Similar",
"to",
"qvoronoi",
"command",
"in",
"command",
"-",
"line",
"qhull",
"."
] | 01d4ee2c108ab3d8faa9b9ff476290ffee90073f | https://github.com/materialsvirtuallab/pyhull/blob/01d4ee2c108ab3d8faa9b9ff476290ffee90073f/pyhull/__init__.py#L111-L139 | train |
materialsvirtuallab/pyhull | pyhull/halfspace.py | Halfspace.from_hyperplane | def from_hyperplane(basis, origin, point, internal = True):
"""
Returns a Halfspace defined by a list of vectors parallel to the
bounding hyperplane.
Args:
basis: basis for the hyperplane (array with vector rows)
origin: point on the hyperplane
point:... | python | def from_hyperplane(basis, origin, point, internal = True):
"""
Returns a Halfspace defined by a list of vectors parallel to the
bounding hyperplane.
Args:
basis: basis for the hyperplane (array with vector rows)
origin: point on the hyperplane
point:... | [
"def",
"from_hyperplane",
"(",
"basis",
",",
"origin",
",",
"point",
",",
"internal",
"=",
"True",
")",
":",
"basis",
"=",
"np",
".",
"array",
"(",
"basis",
")",
"assert",
"basis",
".",
"shape",
"[",
"0",
"]",
"+",
"1",
"==",
"basis",
".",
"shape",... | Returns a Halfspace defined by a list of vectors parallel to the
bounding hyperplane.
Args:
basis: basis for the hyperplane (array with vector rows)
origin: point on the hyperplane
point: point not on the hyperplane
internal: whether point is inside the h... | [
"Returns",
"a",
"Halfspace",
"defined",
"by",
"a",
"list",
"of",
"vectors",
"parallel",
"to",
"the",
"bounding",
"hyperplane",
"."
] | 01d4ee2c108ab3d8faa9b9ff476290ffee90073f | https://github.com/materialsvirtuallab/pyhull/blob/01d4ee2c108ab3d8faa9b9ff476290ffee90073f/pyhull/halfspace.py#L36-L64 | train |
materialsvirtuallab/pyhull | pyhull/halfspace.py | HalfspaceIntersection.vertices | def vertices(self):
"""
Returns the vertices of the halfspace intersection
"""
if self._v_out is None:
output = qhalf('Fp', self.halfspaces, self.interior_point)
pts = []
for l in output[2:]:
pt = []
for c in l.split():
... | python | def vertices(self):
"""
Returns the vertices of the halfspace intersection
"""
if self._v_out is None:
output = qhalf('Fp', self.halfspaces, self.interior_point)
pts = []
for l in output[2:]:
pt = []
for c in l.split():
... | [
"def",
"vertices",
"(",
"self",
")",
":",
"if",
"self",
".",
"_v_out",
"is",
"None",
":",
"output",
"=",
"qhalf",
"(",
"'Fp'",
",",
"self",
".",
"halfspaces",
",",
"self",
".",
"interior_point",
")",
"pts",
"=",
"[",
"]",
"for",
"l",
"in",
"output"... | Returns the vertices of the halfspace intersection | [
"Returns",
"the",
"vertices",
"of",
"the",
"halfspace",
"intersection"
] | 01d4ee2c108ab3d8faa9b9ff476290ffee90073f | https://github.com/materialsvirtuallab/pyhull/blob/01d4ee2c108ab3d8faa9b9ff476290ffee90073f/pyhull/halfspace.py#L80-L97 | train |
roclark/sportsreference | sportsreference/mlb/boxscore.py | Boxscore._extract_player_stats | def _extract_player_stats(self, table, player_dict, home_or_away):
"""
Combine all player stats into a single object.
Since each player generally has a couple of rows worth of stats (one
for basic stats and another for advanced stats) on the boxscore page,
both rows should be co... | python | def _extract_player_stats(self, table, player_dict, home_or_away):
"""
Combine all player stats into a single object.
Since each player generally has a couple of rows worth of stats (one
for basic stats and another for advanced stats) on the boxscore page,
both rows should be co... | [
"def",
"_extract_player_stats",
"(",
"self",
",",
"table",
",",
"player_dict",
",",
"home_or_away",
")",
":",
"for",
"row",
"in",
"table",
"(",
"'tbody tr'",
")",
".",
"items",
"(",
")",
":",
"player_id",
"=",
"self",
".",
"_find_player_id",
"(",
"row",
... | Combine all player stats into a single object.
Since each player generally has a couple of rows worth of stats (one
for basic stats and another for advanced stats) on the boxscore page,
both rows should be combined into a single string object to easily
query all fields from a single obj... | [
"Combine",
"all",
"player",
"stats",
"into",
"a",
"single",
"object",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/boxscore.py#L601-L647 | train |
roclark/sportsreference | sportsreference/mlb/boxscore.py | Boxscore._instantiate_players | def _instantiate_players(self, player_dict):
"""
Create a list of player instances for both the home and away teams.
For every player listed on the boxscores page, create an instance of
the BoxscorePlayer class for that player and add them to a list of
players for their respecti... | python | def _instantiate_players(self, player_dict):
"""
Create a list of player instances for both the home and away teams.
For every player listed on the boxscores page, create an instance of
the BoxscorePlayer class for that player and add them to a list of
players for their respecti... | [
"def",
"_instantiate_players",
"(",
"self",
",",
"player_dict",
")",
":",
"home_players",
"=",
"[",
"]",
"away_players",
"=",
"[",
"]",
"for",
"player_id",
",",
"details",
"in",
"player_dict",
".",
"items",
"(",
")",
":",
"player",
"=",
"BoxscorePlayer",
"... | Create a list of player instances for both the home and away teams.
For every player listed on the boxscores page, create an instance of
the BoxscorePlayer class for that player and add them to a list of
players for their respective team.
Parameters
----------
player_di... | [
"Create",
"a",
"list",
"of",
"player",
"instances",
"for",
"both",
"the",
"home",
"and",
"away",
"teams",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/boxscore.py#L649-L683 | train |
roclark/sportsreference | sportsreference/mlb/boxscore.py | Boxscore.winning_name | def winning_name(self):
"""
Returns a ``string`` of the winning team's name, such as 'Houston
Astros'.
"""
if self.winner == HOME:
return self._home_name.text()
return self._away_name.text() | python | def winning_name(self):
"""
Returns a ``string`` of the winning team's name, such as 'Houston
Astros'.
"""
if self.winner == HOME:
return self._home_name.text()
return self._away_name.text() | [
"def",
"winning_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"winner",
"==",
"HOME",
":",
"return",
"self",
".",
"_home_name",
".",
"text",
"(",
")",
"return",
"self",
".",
"_away_name",
".",
"text",
"(",
")"
] | Returns a ``string`` of the winning team's name, such as 'Houston
Astros'. | [
"Returns",
"a",
"string",
"of",
"the",
"winning",
"team",
"s",
"name",
"such",
"as",
"Houston",
"Astros",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/boxscore.py#L953-L960 | train |
roclark/sportsreference | sportsreference/mlb/boxscore.py | Boxscore.winning_abbr | def winning_abbr(self):
"""
Returns a ``string`` of the winning team's abbreviation, such as 'HOU'
for the Houston Astros.
"""
if self.winner == HOME:
return utils._parse_abbreviation(self._home_name)
return utils._parse_abbreviation(self._away_name) | python | def winning_abbr(self):
"""
Returns a ``string`` of the winning team's abbreviation, such as 'HOU'
for the Houston Astros.
"""
if self.winner == HOME:
return utils._parse_abbreviation(self._home_name)
return utils._parse_abbreviation(self._away_name) | [
"def",
"winning_abbr",
"(",
"self",
")",
":",
"if",
"self",
".",
"winner",
"==",
"HOME",
":",
"return",
"utils",
".",
"_parse_abbreviation",
"(",
"self",
".",
"_home_name",
")",
"return",
"utils",
".",
"_parse_abbreviation",
"(",
"self",
".",
"_away_name",
... | Returns a ``string`` of the winning team's abbreviation, such as 'HOU'
for the Houston Astros. | [
"Returns",
"a",
"string",
"of",
"the",
"winning",
"team",
"s",
"abbreviation",
"such",
"as",
"HOU",
"for",
"the",
"Houston",
"Astros",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/boxscore.py#L963-L970 | train |
roclark/sportsreference | sportsreference/mlb/boxscore.py | Boxscore.losing_name | def losing_name(self):
"""
Returns a ``string`` of the losing team's name, such as 'Los Angeles
Dodgers'.
"""
if self.winner == HOME:
return self._away_name.text()
return self._home_name.text() | python | def losing_name(self):
"""
Returns a ``string`` of the losing team's name, such as 'Los Angeles
Dodgers'.
"""
if self.winner == HOME:
return self._away_name.text()
return self._home_name.text() | [
"def",
"losing_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"winner",
"==",
"HOME",
":",
"return",
"self",
".",
"_away_name",
".",
"text",
"(",
")",
"return",
"self",
".",
"_home_name",
".",
"text",
"(",
")"
] | Returns a ``string`` of the losing team's name, such as 'Los Angeles
Dodgers'. | [
"Returns",
"a",
"string",
"of",
"the",
"losing",
"team",
"s",
"name",
"such",
"as",
"Los",
"Angeles",
"Dodgers",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/boxscore.py#L973-L980 | train |
roclark/sportsreference | sportsreference/mlb/boxscore.py | Boxscore.losing_abbr | def losing_abbr(self):
"""
Returns a ``string`` of the losing team's abbreviation, such as 'LAD'
for the Los Angeles Dodgers.
"""
if self.winner == HOME:
return utils._parse_abbreviation(self._away_name)
return utils._parse_abbreviation(self._home_name) | python | def losing_abbr(self):
"""
Returns a ``string`` of the losing team's abbreviation, such as 'LAD'
for the Los Angeles Dodgers.
"""
if self.winner == HOME:
return utils._parse_abbreviation(self._away_name)
return utils._parse_abbreviation(self._home_name) | [
"def",
"losing_abbr",
"(",
"self",
")",
":",
"if",
"self",
".",
"winner",
"==",
"HOME",
":",
"return",
"utils",
".",
"_parse_abbreviation",
"(",
"self",
".",
"_away_name",
")",
"return",
"utils",
".",
"_parse_abbreviation",
"(",
"self",
".",
"_home_name",
... | Returns a ``string`` of the losing team's abbreviation, such as 'LAD'
for the Los Angeles Dodgers. | [
"Returns",
"a",
"string",
"of",
"the",
"losing",
"team",
"s",
"abbreviation",
"such",
"as",
"LAD",
"for",
"the",
"Los",
"Angeles",
"Dodgers",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/boxscore.py#L983-L990 | train |
roclark/sportsreference | sportsreference/mlb/boxscore.py | Boxscores._create_url | def _create_url(self, date):
"""
Build the URL based on the passed datetime object.
In order to get the proper boxscore page, the URL needs to include the
requested month, day, and year.
Parameters
----------
date : datetime object
The date to search... | python | def _create_url(self, date):
"""
Build the URL based on the passed datetime object.
In order to get the proper boxscore page, the URL needs to include the
requested month, day, and year.
Parameters
----------
date : datetime object
The date to search... | [
"def",
"_create_url",
"(",
"self",
",",
"date",
")",
":",
"return",
"BOXSCORES_URL",
"%",
"(",
"date",
".",
"year",
",",
"date",
".",
"month",
",",
"date",
".",
"day",
")"
] | Build the URL based on the passed datetime object.
In order to get the proper boxscore page, the URL needs to include the
requested month, day, and year.
Parameters
----------
date : datetime object
The date to search for any matches. The month, day, and year are
... | [
"Build",
"the",
"URL",
"based",
"on",
"the",
"passed",
"datetime",
"object",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/boxscore.py#L1606-L1625 | train |
roclark/sportsreference | sportsreference/mlb/boxscore.py | Boxscores._get_score | def _get_score(self, score_link):
"""
Find a team's final score.
Given an HTML string of a team's boxscore, extract the integer
representing the final score and return the number.
Parameters
----------
score_link : string
An HTML string representing ... | python | def _get_score(self, score_link):
"""
Find a team's final score.
Given an HTML string of a team's boxscore, extract the integer
representing the final score and return the number.
Parameters
----------
score_link : string
An HTML string representing ... | [
"def",
"_get_score",
"(",
"self",
",",
"score_link",
")",
":",
"score",
"=",
"score_link",
".",
"replace",
"(",
"'<td class=\"right\">'",
",",
"''",
")",
"score",
"=",
"score",
".",
"replace",
"(",
"'</td>'",
",",
"''",
")",
"return",
"int",
"(",
"score"... | Find a team's final score.
Given an HTML string of a team's boxscore, extract the integer
representing the final score and return the number.
Parameters
----------
score_link : string
An HTML string representing a team's final score in the format
'<td cl... | [
"Find",
"a",
"team",
"s",
"final",
"score",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/boxscore.py#L1711-L1731 | train |
roclark/sportsreference | sportsreference/mlb/boxscore.py | Boxscores._get_team_results | def _get_team_results(self, team_result_html):
"""
Extract the winning or losing team's name and abbreviation.
Depending on which team's data field is passed (either the winner or
loser), return the name and abbreviation of that team to denote which
team won and which lost the g... | python | def _get_team_results(self, team_result_html):
"""
Extract the winning or losing team's name and abbreviation.
Depending on which team's data field is passed (either the winner or
loser), return the name and abbreviation of that team to denote which
team won and which lost the g... | [
"def",
"_get_team_results",
"(",
"self",
",",
"team_result_html",
")",
":",
"link",
"=",
"[",
"i",
"for",
"i",
"in",
"team_result_html",
"(",
"'td a'",
")",
".",
"items",
"(",
")",
"]",
"if",
"len",
"(",
"link",
")",
"<",
"1",
":",
"return",
"None",
... | Extract the winning or losing team's name and abbreviation.
Depending on which team's data field is passed (either the winner or
loser), return the name and abbreviation of that team to denote which
team won and which lost the game.
Parameters
----------
team_result_htm... | [
"Extract",
"the",
"winning",
"or",
"losing",
"team",
"s",
"name",
"and",
"abbreviation",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/boxscore.py#L1771-L1796 | train |
roclark/sportsreference | sportsreference/mlb/boxscore.py | Boxscores._find_games | def _find_games(self, date, end_date):
"""
Retrieve all major games played on a given day.
Builds a URL based on the requested date and downloads the HTML
contents before parsing any and all games played during that day. Any
games that are found are added to the boxscores dictio... | python | def _find_games(self, date, end_date):
"""
Retrieve all major games played on a given day.
Builds a URL based on the requested date and downloads the HTML
contents before parsing any and all games played during that day. Any
games that are found are added to the boxscores dictio... | [
"def",
"_find_games",
"(",
"self",
",",
"date",
",",
"end_date",
")",
":",
"if",
"not",
"end_date",
"or",
"date",
">",
"end_date",
":",
"end_date",
"=",
"date",
"date_step",
"=",
"date",
"while",
"date_step",
"<=",
"end_date",
":",
"url",
"=",
"self",
... | Retrieve all major games played on a given day.
Builds a URL based on the requested date and downloads the HTML
contents before parsing any and all games played during that day. Any
games that are found are added to the boxscores dictionary with
high-level game information such as the h... | [
"Retrieve",
"all",
"major",
"games",
"played",
"on",
"a",
"given",
"day",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/boxscore.py#L1866-L1902 | train |
roclark/sportsreference | sportsreference/nfl/roster.py | Player._parse_season | def _parse_season(self, row):
"""
Parse the season string from the table.
The season is generally located in the first column of the stats tables
and should be parsed to detonate which season metrics are being pulled
from.
Parameters
----------
row : PyQ... | python | def _parse_season(self, row):
"""
Parse the season string from the table.
The season is generally located in the first column of the stats tables
and should be parsed to detonate which season metrics are being pulled
from.
Parameters
----------
row : PyQ... | [
"def",
"_parse_season",
"(",
"self",
",",
"row",
")",
":",
"season",
"=",
"utils",
".",
"_parse_field",
"(",
"PLAYER_SCHEME",
",",
"row",
",",
"'season'",
")",
"return",
"season",
".",
"replace",
"(",
"'*'",
",",
"''",
")",
".",
"replace",
"(",
"'+'",
... | Parse the season string from the table.
The season is generally located in the first column of the stats tables
and should be parsed to detonate which season metrics are being pulled
from.
Parameters
----------
row : PyQuery object
A PyQuery object of a sing... | [
"Parse",
"the",
"season",
"string",
"from",
"the",
"table",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nfl/roster.py#L249-L269 | train |
roclark/sportsreference | sportsreference/nfl/roster.py | Player._combine_season_stats | def _combine_season_stats(self, table_rows, career_stats, all_stats_dict):
"""
Combine all stats for each season.
Since all of the stats are spread across multiple tables, they should
be combined into a single field which can be used to easily query stats
at once.
Param... | python | def _combine_season_stats(self, table_rows, career_stats, all_stats_dict):
"""
Combine all stats for each season.
Since all of the stats are spread across multiple tables, they should
be combined into a single field which can be used to easily query stats
at once.
Param... | [
"def",
"_combine_season_stats",
"(",
"self",
",",
"table_rows",
",",
"career_stats",
",",
"all_stats_dict",
")",
":",
"most_recent_season",
"=",
"self",
".",
"_most_recent_season",
"if",
"not",
"table_rows",
":",
"table_rows",
"=",
"[",
"]",
"for",
"row",
"in",
... | Combine all stats for each season.
Since all of the stats are spread across multiple tables, they should
be combined into a single field which can be used to easily query stats
at once.
Parameters
----------
table_rows : generator
A generator where each elem... | [
"Combine",
"all",
"stats",
"for",
"each",
"season",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nfl/roster.py#L271-L320 | train |
roclark/sportsreference | sportsreference/nfl/roster.py | Player._parse_player_information | def _parse_player_information(self, player_info):
"""
Parse general player information.
Parse general player information such as height, weight, and name. The
attribute for the requested field will be set with the value prior to
returning.
Parameters
----------
... | python | def _parse_player_information(self, player_info):
"""
Parse general player information.
Parse general player information such as height, weight, and name. The
attribute for the requested field will be set with the value prior to
returning.
Parameters
----------
... | [
"def",
"_parse_player_information",
"(",
"self",
",",
"player_info",
")",
":",
"for",
"field",
"in",
"[",
"'_height'",
",",
"'_weight'",
",",
"'_name'",
"]",
":",
"short_field",
"=",
"str",
"(",
"field",
")",
"[",
"1",
":",
"]",
"value",
"=",
"utils",
... | Parse general player information.
Parse general player information such as height, weight, and name. The
attribute for the requested field will be set with the value prior to
returning.
Parameters
----------
player_info : PyQuery object
A PyQuery object cont... | [
"Parse",
"general",
"player",
"information",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nfl/roster.py#L357-L373 | train |
roclark/sportsreference | sportsreference/nfl/roster.py | Player.dataframe | def dataframe(self):
"""
Returns a ``pandas DataFrame`` containing all other relevant class
properties and values where each index is a different season plus the
career stats.
"""
temp_index = self._index
rows = []
indices = []
if not self._season:... | python | def dataframe(self):
"""
Returns a ``pandas DataFrame`` containing all other relevant class
properties and values where each index is a different season plus the
career stats.
"""
temp_index = self._index
rows = []
indices = []
if not self._season:... | [
"def",
"dataframe",
"(",
"self",
")",
":",
"temp_index",
"=",
"self",
".",
"_index",
"rows",
"=",
"[",
"]",
"indices",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"_season",
":",
"return",
"None",
"for",
"season",
"in",
"self",
".",
"_season",
":",
"s... | Returns a ``pandas DataFrame`` containing all other relevant class
properties and values where each index is a different season plus the
career stats. | [
"Returns",
"a",
"pandas",
"DataFrame",
"containing",
"all",
"other",
"relevant",
"class",
"properties",
"and",
"values",
"where",
"each",
"index",
"is",
"a",
"different",
"season",
"plus",
"the",
"career",
"stats",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nfl/roster.py#L611-L627 | train |
roclark/sportsreference | sportsreference/utils.py | _find_year_for_season | def _find_year_for_season(league):
"""
Return the necessary seaons's year based on the current date.
Since all sports start and end at different times throughout the year,
simply using the current year is not sufficient to describe a season. For
example, the NCAA Men's Basketball season begins in N... | python | def _find_year_for_season(league):
"""
Return the necessary seaons's year based on the current date.
Since all sports start and end at different times throughout the year,
simply using the current year is not sufficient to describe a season. For
example, the NCAA Men's Basketball season begins in N... | [
"def",
"_find_year_for_season",
"(",
"league",
")",
":",
"today",
"=",
"_todays_date",
"(",
")",
"if",
"league",
"not",
"in",
"SEASON_START_MONTH",
":",
"raise",
"ValueError",
"(",
"'\"%s\" league cannot be found!'",
")",
"start",
"=",
"SEASON_START_MONTH",
"[",
"... | Return the necessary seaons's year based on the current date.
Since all sports start and end at different times throughout the year,
simply using the current year is not sufficient to describe a season. For
example, the NCAA Men's Basketball season begins in November every year.
However, for the Novemb... | [
"Return",
"the",
"necessary",
"seaons",
"s",
"year",
"based",
"on",
"the",
"current",
"date",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/utils.py#L41-L90 | train |
roclark/sportsreference | sportsreference/utils.py | _parse_abbreviation | def _parse_abbreviation(uri_link):
"""
Returns a team's abbreviation.
A school or team's abbreviation is generally embedded in a URI link which
contains other relative link information. For example, the URI for the
New England Patriots for the 2017 season is "/teams/nwe/2017.htm". This
function... | python | def _parse_abbreviation(uri_link):
"""
Returns a team's abbreviation.
A school or team's abbreviation is generally embedded in a URI link which
contains other relative link information. For example, the URI for the
New England Patriots for the 2017 season is "/teams/nwe/2017.htm". This
function... | [
"def",
"_parse_abbreviation",
"(",
"uri_link",
")",
":",
"abbr",
"=",
"re",
".",
"sub",
"(",
"r'/[0-9]+\\..*htm.*'",
",",
"''",
",",
"uri_link",
"(",
"'a'",
")",
".",
"attr",
"(",
"'href'",
")",
")",
"abbr",
"=",
"re",
".",
"sub",
"(",
"r'/.*/schools/'... | Returns a team's abbreviation.
A school or team's abbreviation is generally embedded in a URI link which
contains other relative link information. For example, the URI for the
New England Patriots for the 2017 season is "/teams/nwe/2017.htm". This
function strips all of the contents before and after "n... | [
"Returns",
"a",
"team",
"s",
"abbreviation",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/utils.py#L93-L117 | train |
roclark/sportsreference | sportsreference/utils.py | _parse_field | def _parse_field(parsing_scheme, html_data, field, index=0):
"""
Parse an HTML table to find the requested field's value.
All of the values are passed in an HTML table row instead of as individual
items. The values need to be parsed by matching the requested attribute
with a parsing scheme that spo... | python | def _parse_field(parsing_scheme, html_data, field, index=0):
"""
Parse an HTML table to find the requested field's value.
All of the values are passed in an HTML table row instead of as individual
items. The values need to be parsed by matching the requested attribute
with a parsing scheme that spo... | [
"def",
"_parse_field",
"(",
"parsing_scheme",
",",
"html_data",
",",
"field",
",",
"index",
"=",
"0",
")",
":",
"if",
"field",
"==",
"'abbreviation'",
":",
"return",
"_parse_abbreviation",
"(",
"html_data",
")",
"scheme",
"=",
"parsing_scheme",
"[",
"field",
... | Parse an HTML table to find the requested field's value.
All of the values are passed in an HTML table row instead of as individual
items. The values need to be parsed by matching the requested attribute
with a parsing scheme that sports-reference uses to differentiate stats.
This function returns a si... | [
"Parse",
"an",
"HTML",
"table",
"to",
"find",
"the",
"requested",
"field",
"s",
"value",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/utils.py#L120-L169 | train |
roclark/sportsreference | sportsreference/utils.py | _get_stats_table | def _get_stats_table(html_page, div, footer=False):
"""
Returns a generator of all rows in a requested table.
When given a PyQuery HTML object and a requested div, this function creates
a generator where every item is a PyQuery object pertaining to every row in
the table. Generally, each row will c... | python | def _get_stats_table(html_page, div, footer=False):
"""
Returns a generator of all rows in a requested table.
When given a PyQuery HTML object and a requested div, this function creates
a generator where every item is a PyQuery object pertaining to every row in
the table. Generally, each row will c... | [
"def",
"_get_stats_table",
"(",
"html_page",
",",
"div",
",",
"footer",
"=",
"False",
")",
":",
"stats_html",
"=",
"html_page",
"(",
"div",
")",
"try",
":",
"stats_table",
"=",
"pq",
"(",
"_remove_html_comment_tags",
"(",
"stats_html",
")",
")",
"except",
... | Returns a generator of all rows in a requested table.
When given a PyQuery HTML object and a requested div, this function creates
a generator where every item is a PyQuery object pertaining to every row in
the table. Generally, each row will contain multiple stats for a given
player or team.
Param... | [
"Returns",
"a",
"generator",
"of",
"all",
"rows",
"in",
"a",
"requested",
"table",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/utils.py#L194-L228 | train |
roclark/sportsreference | sportsreference/nhl/teams.py | Teams.dataframes | def dataframes(self):
"""
Returns a pandas DataFrame where each row is a representation of the
Team class. Rows are indexed by the team abbreviation.
"""
frames = []
for team in self.__iter__():
frames.append(team.dataframe)
return pd.concat(frames) | python | def dataframes(self):
"""
Returns a pandas DataFrame where each row is a representation of the
Team class. Rows are indexed by the team abbreviation.
"""
frames = []
for team in self.__iter__():
frames.append(team.dataframe)
return pd.concat(frames) | [
"def",
"dataframes",
"(",
"self",
")",
":",
"frames",
"=",
"[",
"]",
"for",
"team",
"in",
"self",
".",
"__iter__",
"(",
")",
":",
"frames",
".",
"append",
"(",
"team",
".",
"dataframe",
")",
"return",
"pd",
".",
"concat",
"(",
"frames",
")"
] | Returns a pandas DataFrame where each row is a representation of the
Team class. Rows are indexed by the team abbreviation. | [
"Returns",
"a",
"pandas",
"DataFrame",
"where",
"each",
"row",
"is",
"a",
"representation",
"of",
"the",
"Team",
"class",
".",
"Rows",
"are",
"indexed",
"by",
"the",
"team",
"abbreviation",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nhl/teams.py#L486-L494 | train |
roclark/sportsreference | sportsreference/ncaaf/rankings.py | Rankings._get_team | def _get_team(self, team):
"""
Retrieve team's name and abbreviation.
The team's name and abbreviation are embedded within the 'school_name'
tag and, in the case of the abbreviation, require special parsing as it
is located in the middle of a URI. The name and abbreviation are
... | python | def _get_team(self, team):
"""
Retrieve team's name and abbreviation.
The team's name and abbreviation are embedded within the 'school_name'
tag and, in the case of the abbreviation, require special parsing as it
is located in the middle of a URI. The name and abbreviation are
... | [
"def",
"_get_team",
"(",
"self",
",",
"team",
")",
":",
"name_tag",
"=",
"team",
"(",
"'td[data-stat=\"school_name\"]'",
")",
"abbreviation",
"=",
"re",
".",
"sub",
"(",
"r'.*/cfb/schools/'",
",",
"''",
",",
"str",
"(",
"name_tag",
"(",
"'a'",
")",
")",
... | Retrieve team's name and abbreviation.
The team's name and abbreviation are embedded within the 'school_name'
tag and, in the case of the abbreviation, require special parsing as it
is located in the middle of a URI. The name and abbreviation are
returned for the requested school.
... | [
"Retrieve",
"team",
"s",
"name",
"and",
"abbreviation",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/rankings.py#L49-L75 | train |
roclark/sportsreference | sportsreference/ncaaf/rankings.py | Rankings._find_rankings | def _find_rankings(self, year):
"""
Retrieve the rankings for each week.
Find and retrieve all AP rankings for the requested year and combine
them on a per-week basis. Each week contains information about the
name, abbreviation, rank, movement, and previous rank for each team
... | python | def _find_rankings(self, year):
"""
Retrieve the rankings for each week.
Find and retrieve all AP rankings for the requested year and combine
them on a per-week basis. Each week contains information about the
name, abbreviation, rank, movement, and previous rank for each team
... | [
"def",
"_find_rankings",
"(",
"self",
",",
"year",
")",
":",
"if",
"not",
"year",
":",
"year",
"=",
"utils",
".",
"_find_year_for_season",
"(",
"'ncaaf'",
")",
"page",
"=",
"self",
".",
"_pull_rankings_page",
"(",
"year",
")",
"if",
"not",
"page",
":",
... | Retrieve the rankings for each week.
Find and retrieve all AP rankings for the requested year and combine
them on a per-week basis. Each week contains information about the
name, abbreviation, rank, movement, and previous rank for each team
as well as the date and week number the result... | [
"Retrieve",
"the",
"rankings",
"for",
"each",
"week",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/rankings.py#L77-L133 | train |
roclark/sportsreference | sportsreference/ncaaf/rankings.py | Rankings.current | def current(self):
"""
Returns a ``dictionary`` of the most recent rankings from the
Associated Press where each key is a ``string`` of the team's
abbreviation and each value is an ``int`` of the team's rank for the
current week.
"""
rankings_dict = {}
fo... | python | def current(self):
"""
Returns a ``dictionary`` of the most recent rankings from the
Associated Press where each key is a ``string`` of the team's
abbreviation and each value is an ``int`` of the team's rank for the
current week.
"""
rankings_dict = {}
fo... | [
"def",
"current",
"(",
"self",
")",
":",
"rankings_dict",
"=",
"{",
"}",
"for",
"team",
"in",
"self",
".",
"current_extended",
":",
"rankings_dict",
"[",
"team",
"[",
"'abbreviation'",
"]",
"]",
"=",
"team",
"[",
"'rank'",
"]",
"return",
"rankings_dict"
] | Returns a ``dictionary`` of the most recent rankings from the
Associated Press where each key is a ``string`` of the team's
abbreviation and each value is an ``int`` of the team's rank for the
current week. | [
"Returns",
"a",
"dictionary",
"of",
"the",
"most",
"recent",
"rankings",
"from",
"the",
"Associated",
"Press",
"where",
"each",
"key",
"is",
"a",
"string",
"of",
"the",
"team",
"s",
"abbreviation",
"and",
"each",
"value",
"is",
"an",
"int",
"of",
"the",
... | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/rankings.py#L164-L175 | train |
roclark/sportsreference | sportsreference/nfl/boxscore.py | Boxscore._retrieve_html_page | def _retrieve_html_page(self, uri):
"""
Download the requested HTML page.
Given a relative link, download the requested page and strip it of all
comment tags before returning a pyquery object which will be used to
parse the data.
Parameters
----------
ur... | python | def _retrieve_html_page(self, uri):
"""
Download the requested HTML page.
Given a relative link, download the requested page and strip it of all
comment tags before returning a pyquery object which will be used to
parse the data.
Parameters
----------
ur... | [
"def",
"_retrieve_html_page",
"(",
"self",
",",
"uri",
")",
":",
"url",
"=",
"BOXSCORE_URL",
"%",
"uri",
"try",
":",
"url_data",
"=",
"pq",
"(",
"url",
")",
"except",
"HTTPError",
":",
"return",
"None",
"if",
"'404 error'",
"in",
"str",
"(",
"url_data",
... | Download the requested HTML page.
Given a relative link, download the requested page and strip it of all
comment tags before returning a pyquery object which will be used to
parse the data.
Parameters
----------
uri : string
The relative link to the boxscore... | [
"Download",
"the",
"requested",
"HTML",
"page",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nfl/boxscore.py#L292-L321 | train |
roclark/sportsreference | sportsreference/nfl/boxscore.py | Boxscore.dataframe | def dataframe(self):
"""
Returns a pandas DataFrame containing all other class properties and
values. The index for the DataFrame is the string URI that is used to
instantiate the class, such as '201802040nwe'.
"""
if self._away_points is None and self._home_points is Non... | python | def dataframe(self):
"""
Returns a pandas DataFrame containing all other class properties and
values. The index for the DataFrame is the string URI that is used to
instantiate the class, such as '201802040nwe'.
"""
if self._away_points is None and self._home_points is Non... | [
"def",
"dataframe",
"(",
"self",
")",
":",
"if",
"self",
".",
"_away_points",
"is",
"None",
"and",
"self",
".",
"_home_points",
"is",
"None",
":",
"return",
"None",
"fields_to_include",
"=",
"{",
"'attendance'",
":",
"self",
".",
"attendance",
",",
"'away_... | Returns a pandas DataFrame containing all other class properties and
values. The index for the DataFrame is the string URI that is used to
instantiate the class, such as '201802040nwe'. | [
"Returns",
"a",
"pandas",
"DataFrame",
"containing",
"all",
"other",
"class",
"properties",
"and",
"values",
".",
"The",
"index",
"for",
"the",
"DataFrame",
"is",
"the",
"string",
"URI",
"that",
"is",
"used",
"to",
"instantiate",
"the",
"class",
"such",
"as"... | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nfl/boxscore.py#L650-L718 | train |
roclark/sportsreference | sportsreference/nfl/boxscore.py | Boxscore.away_abbreviation | def away_abbreviation(self):
"""
Returns a ``string`` of the away team's abbreviation, such as 'NWE'.
"""
abbr = re.sub(r'.*/teams/', '', str(self._away_name))
abbr = re.sub(r'/.*', '', abbr)
return abbr | python | def away_abbreviation(self):
"""
Returns a ``string`` of the away team's abbreviation, such as 'NWE'.
"""
abbr = re.sub(r'.*/teams/', '', str(self._away_name))
abbr = re.sub(r'/.*', '', abbr)
return abbr | [
"def",
"away_abbreviation",
"(",
"self",
")",
":",
"abbr",
"=",
"re",
".",
"sub",
"(",
"r'.*/teams/'",
",",
"''",
",",
"str",
"(",
"self",
".",
"_away_name",
")",
")",
"abbr",
"=",
"re",
".",
"sub",
"(",
"r'/.*'",
",",
"''",
",",
"abbr",
")",
"re... | Returns a ``string`` of the away team's abbreviation, such as 'NWE'. | [
"Returns",
"a",
"string",
"of",
"the",
"away",
"team",
"s",
"abbreviation",
"such",
"as",
"NWE",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nfl/boxscore.py#L737-L743 | train |
roclark/sportsreference | sportsreference/nfl/boxscore.py | Boxscore.home_abbreviation | def home_abbreviation(self):
"""
Returns a ``string`` of the home team's abbreviation, such as 'KAN'.
"""
abbr = re.sub(r'.*/teams/', '', str(self._home_name))
abbr = re.sub(r'/.*', '', abbr)
return abbr | python | def home_abbreviation(self):
"""
Returns a ``string`` of the home team's abbreviation, such as 'KAN'.
"""
abbr = re.sub(r'.*/teams/', '', str(self._home_name))
abbr = re.sub(r'/.*', '', abbr)
return abbr | [
"def",
"home_abbreviation",
"(",
"self",
")",
":",
"abbr",
"=",
"re",
".",
"sub",
"(",
"r'.*/teams/'",
",",
"''",
",",
"str",
"(",
"self",
".",
"_home_name",
")",
")",
"abbr",
"=",
"re",
".",
"sub",
"(",
"r'/.*'",
",",
"''",
",",
"abbr",
")",
"re... | Returns a ``string`` of the home team's abbreviation, such as 'KAN'. | [
"Returns",
"a",
"string",
"of",
"the",
"home",
"team",
"s",
"abbreviation",
"such",
"as",
"KAN",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nfl/boxscore.py#L746-L752 | train |
roclark/sportsreference | sportsreference/nfl/boxscore.py | Boxscores._find_games | def _find_games(self, week, year, end_week):
"""
Retrieve all major games played for a given week.
Builds a URL based on the requested date and downloads the HTML
contents before parsing any and all games played during that week. Any
games that are found are added to the boxscor... | python | def _find_games(self, week, year, end_week):
"""
Retrieve all major games played for a given week.
Builds a URL based on the requested date and downloads the HTML
contents before parsing any and all games played during that week. Any
games that are found are added to the boxscor... | [
"def",
"_find_games",
"(",
"self",
",",
"week",
",",
"year",
",",
"end_week",
")",
":",
"if",
"not",
"end_week",
"or",
"week",
">",
"end_week",
":",
"end_week",
"=",
"week",
"while",
"week",
"<=",
"end_week",
":",
"url",
"=",
"self",
".",
"_create_url"... | Retrieve all major games played for a given week.
Builds a URL based on the requested date and downloads the HTML
contents before parsing any and all games played during that week. Any
games that are found are added to the boxscores dictionary with
high-level game information such as th... | [
"Retrieve",
"all",
"major",
"games",
"played",
"for",
"a",
"given",
"week",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nfl/boxscore.py#L1531-L1564 | train |
roclark/sportsreference | sportsreference/nhl/schedule.py | Game.result | def result(self):
"""
Returns a ``string`` constant to indicate whether the team lost in
regulation, lost in overtime, or won.
"""
if self._result.lower() == 'w':
return WIN
if self._result.lower() == 'l' and \
self.overtime != 0:
return... | python | def result(self):
"""
Returns a ``string`` constant to indicate whether the team lost in
regulation, lost in overtime, or won.
"""
if self._result.lower() == 'w':
return WIN
if self._result.lower() == 'l' and \
self.overtime != 0:
return... | [
"def",
"result",
"(",
"self",
")",
":",
"if",
"self",
".",
"_result",
".",
"lower",
"(",
")",
"==",
"'w'",
":",
"return",
"WIN",
"if",
"self",
".",
"_result",
".",
"lower",
"(",
")",
"==",
"'l'",
"and",
"self",
".",
"overtime",
"!=",
"0",
":",
... | Returns a ``string`` constant to indicate whether the team lost in
regulation, lost in overtime, or won. | [
"Returns",
"a",
"string",
"constant",
"to",
"indicate",
"whether",
"the",
"team",
"lost",
"in",
"regulation",
"lost",
"in",
"overtime",
"or",
"won",
"."
] | ea0bae432be76450e137671d2998eb38f962dffd | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nhl/schedule.py#L271-L281 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.