repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
AustralianSynchrotron/lightflow | lightflow/queue/app.py | create_app | def create_app(config):
""" Create a fully configured Celery application object.
Args:
config (Config): A reference to a lightflow configuration object.
Returns:
Celery: A fully configured Celery application object.
"""
# configure the celery logging system with the lightflow sett... | python | def create_app(config):
""" Create a fully configured Celery application object.
Args:
config (Config): A reference to a lightflow configuration object.
Returns:
Celery: A fully configured Celery application object.
"""
# configure the celery logging system with the lightflow sett... | [
"def",
"create_app",
"(",
"config",
")",
":",
"# configure the celery logging system with the lightflow settings",
"setup_logging",
".",
"connect",
"(",
"partial",
"(",
"_initialize_logging",
",",
"config",
")",
",",
"weak",
"=",
"False",
")",
"task_postrun",
".",
"co... | Create a fully configured Celery application object.
Args:
config (Config): A reference to a lightflow configuration object.
Returns:
Celery: A fully configured Celery application object. | [
"Create",
"a",
"fully",
"configured",
"Celery",
"application",
"object",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/app.py#L16-L53 |
AustralianSynchrotron/lightflow | lightflow/queue/app.py | _cleanup_workflow | def _cleanup_workflow(config, task_id, args, **kwargs):
""" Cleanup the results of a workflow when it finished.
Connects to the postrun signal of Celery. If the signal was sent by a workflow,
remove the result from the result backend.
Args:
task_id (str): The id of the task.
args (tupl... | python | def _cleanup_workflow(config, task_id, args, **kwargs):
""" Cleanup the results of a workflow when it finished.
Connects to the postrun signal of Celery. If the signal was sent by a workflow,
remove the result from the result backend.
Args:
task_id (str): The id of the task.
args (tupl... | [
"def",
"_cleanup_workflow",
"(",
"config",
",",
"task_id",
",",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"lightflow",
".",
"models",
"import",
"Workflow",
"if",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"Workflow",
")",
":",
"if",
"confi... | Cleanup the results of a workflow when it finished.
Connects to the postrun signal of Celery. If the signal was sent by a workflow,
remove the result from the result backend.
Args:
task_id (str): The id of the task.
args (tuple): The arguments the task was started with.
**kwargs: K... | [
"Cleanup",
"the",
"results",
"of",
"a",
"workflow",
"when",
"it",
"finished",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/app.py#L70-L84 |
AustralianSynchrotron/lightflow | lightflow/queue/jobs.py | execute_workflow | def execute_workflow(self, workflow, workflow_id=None):
""" Celery task (aka job) that runs a workflow on a worker.
This celery task starts, manages and monitors the dags that make up a workflow.
Args:
self (Task): Reference to itself, the celery task object.
workflow (Workflow): Reference... | python | def execute_workflow(self, workflow, workflow_id=None):
""" Celery task (aka job) that runs a workflow on a worker.
This celery task starts, manages and monitors the dags that make up a workflow.
Args:
self (Task): Reference to itself, the celery task object.
workflow (Workflow): Reference... | [
"def",
"execute_workflow",
"(",
"self",
",",
"workflow",
",",
"workflow_id",
"=",
"None",
")",
":",
"start_time",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"logger",
".",
"info",
"(",
"'Running workflow <{}>'",
".",
"format",
"(",
"workflow",
".",
"name",
... | Celery task (aka job) that runs a workflow on a worker.
This celery task starts, manages and monitors the dags that make up a workflow.
Args:
self (Task): Reference to itself, the celery task object.
workflow (Workflow): Reference to the workflow object that is being used to
... | [
"Celery",
"task",
"(",
"aka",
"job",
")",
"that",
"runs",
"a",
"workflow",
"on",
"a",
"worker",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/jobs.py#L17-L96 |
AustralianSynchrotron/lightflow | lightflow/queue/jobs.py | execute_dag | def execute_dag(self, dag, workflow_id, data=None):
""" Celery task that runs a single dag on a worker.
This celery task starts, manages and monitors the individual tasks of a dag.
Args:
self (Task): Reference to itself, the celery task object.
dag (Dag): Reference to a Dag object that is ... | python | def execute_dag(self, dag, workflow_id, data=None):
""" Celery task that runs a single dag on a worker.
This celery task starts, manages and monitors the individual tasks of a dag.
Args:
self (Task): Reference to itself, the celery task object.
dag (Dag): Reference to a Dag object that is ... | [
"def",
"execute_dag",
"(",
"self",
",",
"dag",
",",
"workflow_id",
",",
"data",
"=",
"None",
")",
":",
"start_time",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"logger",
".",
"info",
"(",
"'Running DAG <{}>'",
".",
"format",
"(",
"dag",
".",
"name",
")"... | Celery task that runs a single dag on a worker.
This celery task starts, manages and monitors the individual tasks of a dag.
Args:
self (Task): Reference to itself, the celery task object.
dag (Dag): Reference to a Dag object that is being used to start, manage and
monitor t... | [
"Celery",
"task",
"that",
"runs",
"a",
"single",
"dag",
"on",
"a",
"worker",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/jobs.py#L100-L168 |
AustralianSynchrotron/lightflow | lightflow/queue/jobs.py | execute_task | def execute_task(self, task, workflow_id, data=None):
""" Celery task that runs a single task on a worker.
Args:
self (Task): Reference to itself, the celery task object.
task (BaseTask): Reference to the task object that performs the work
in its run() method.
w... | python | def execute_task(self, task, workflow_id, data=None):
""" Celery task that runs a single task on a worker.
Args:
self (Task): Reference to itself, the celery task object.
task (BaseTask): Reference to the task object that performs the work
in its run() method.
w... | [
"def",
"execute_task",
"(",
"self",
",",
"task",
",",
"workflow_id",
",",
"data",
"=",
"None",
")",
":",
"start_time",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"store_doc",
"=",
"DataStore",
"(",
"*",
"*",
"self",
".",
"app",
".",
"user_options",
"[",... | Celery task that runs a single task on a worker.
Args:
self (Task): Reference to itself, the celery task object.
task (BaseTask): Reference to the task object that performs the work
in its run() method.
workflow_id (string): The unique ID of the workflow run that st... | [
"Celery",
"task",
"that",
"runs",
"a",
"single",
"task",
"on",
"a",
"worker",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/jobs.py#L172-L265 |
AustralianSynchrotron/lightflow | lightflow/queue/models.py | BrokerStats.from_celery | def from_celery(cls, broker_dict):
""" Create a BrokerStats object from the dictionary returned by celery.
Args:
broker_dict (dict): The dictionary as returned by celery.
Returns:
BrokerStats: A fully initialized BrokerStats object.
"""
return BrokerStat... | python | def from_celery(cls, broker_dict):
""" Create a BrokerStats object from the dictionary returned by celery.
Args:
broker_dict (dict): The dictionary as returned by celery.
Returns:
BrokerStats: A fully initialized BrokerStats object.
"""
return BrokerStat... | [
"def",
"from_celery",
"(",
"cls",
",",
"broker_dict",
")",
":",
"return",
"BrokerStats",
"(",
"hostname",
"=",
"broker_dict",
"[",
"'hostname'",
"]",
",",
"port",
"=",
"broker_dict",
"[",
"'port'",
"]",
",",
"transport",
"=",
"broker_dict",
"[",
"'transport'... | Create a BrokerStats object from the dictionary returned by celery.
Args:
broker_dict (dict): The dictionary as returned by celery.
Returns:
BrokerStats: A fully initialized BrokerStats object. | [
"Create",
"a",
"BrokerStats",
"object",
"from",
"the",
"dictionary",
"returned",
"by",
"celery",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/models.py#L22-L36 |
AustralianSynchrotron/lightflow | lightflow/queue/models.py | BrokerStats.to_dict | def to_dict(self):
""" Return a dictionary of the broker stats.
Returns:
dict: Dictionary of the stats.
"""
return {
'hostname': self.hostname,
'port': self.port,
'transport': self.transport,
'virtual_host': self.virtual_host
... | python | def to_dict(self):
""" Return a dictionary of the broker stats.
Returns:
dict: Dictionary of the stats.
"""
return {
'hostname': self.hostname,
'port': self.port,
'transport': self.transport,
'virtual_host': self.virtual_host
... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"{",
"'hostname'",
":",
"self",
".",
"hostname",
",",
"'port'",
":",
"self",
".",
"port",
",",
"'transport'",
":",
"self",
".",
"transport",
",",
"'virtual_host'",
":",
"self",
".",
"virtual_host",
"}"
] | Return a dictionary of the broker stats.
Returns:
dict: Dictionary of the stats. | [
"Return",
"a",
"dictionary",
"of",
"the",
"broker",
"stats",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/models.py#L38-L49 |
AustralianSynchrotron/lightflow | lightflow/queue/models.py | WorkerStats.from_celery | def from_celery(cls, name, worker_dict, queues):
""" Create a WorkerStats object from the dictionary returned by celery.
Args:
name (str): The name of the worker.
worker_dict (dict): The dictionary as returned by celery.
queues (list): A list of QueueStats objects th... | python | def from_celery(cls, name, worker_dict, queues):
""" Create a WorkerStats object from the dictionary returned by celery.
Args:
name (str): The name of the worker.
worker_dict (dict): The dictionary as returned by celery.
queues (list): A list of QueueStats objects th... | [
"def",
"from_celery",
"(",
"cls",
",",
"name",
",",
"worker_dict",
",",
"queues",
")",
":",
"return",
"WorkerStats",
"(",
"name",
"=",
"name",
",",
"broker",
"=",
"BrokerStats",
".",
"from_celery",
"(",
"worker_dict",
"[",
"'broker'",
"]",
")",
",",
"pid... | Create a WorkerStats object from the dictionary returned by celery.
Args:
name (str): The name of the worker.
worker_dict (dict): The dictionary as returned by celery.
queues (list): A list of QueueStats objects that represent the queues this
worker is listen... | [
"Create",
"a",
"WorkerStats",
"object",
"from",
"the",
"dictionary",
"returned",
"by",
"celery",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/models.py#L114-L134 |
AustralianSynchrotron/lightflow | lightflow/queue/models.py | WorkerStats.to_dict | def to_dict(self):
""" Return a dictionary of the worker stats.
Returns:
dict: Dictionary of the stats.
"""
return {
'name': self.name,
'broker': self.broker.to_dict(),
'pid': self.pid,
'process_pids': self.process_pids,
... | python | def to_dict(self):
""" Return a dictionary of the worker stats.
Returns:
dict: Dictionary of the stats.
"""
return {
'name': self.name,
'broker': self.broker.to_dict(),
'pid': self.pid,
'process_pids': self.process_pids,
... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"{",
"'name'",
":",
"self",
".",
"name",
",",
"'broker'",
":",
"self",
".",
"broker",
".",
"to_dict",
"(",
")",
",",
"'pid'",
":",
"self",
".",
"pid",
",",
"'process_pids'",
":",
"self",
".",
"proc... | Return a dictionary of the worker stats.
Returns:
dict: Dictionary of the stats. | [
"Return",
"a",
"dictionary",
"of",
"the",
"worker",
"stats",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/models.py#L136-L150 |
AustralianSynchrotron/lightflow | lightflow/queue/models.py | JobStats.from_celery | def from_celery(cls, worker_name, job_dict, celery_app):
""" Create a JobStats object from the dictionary returned by celery.
Args:
worker_name (str): The name of the worker this jobs runs on.
job_dict (dict): The dictionary as returned by celery.
celery_app: Referen... | python | def from_celery(cls, worker_name, job_dict, celery_app):
""" Create a JobStats object from the dictionary returned by celery.
Args:
worker_name (str): The name of the worker this jobs runs on.
job_dict (dict): The dictionary as returned by celery.
celery_app: Referen... | [
"def",
"from_celery",
"(",
"cls",
",",
"worker_name",
",",
"job_dict",
",",
"celery_app",
")",
":",
"if",
"not",
"isinstance",
"(",
"job_dict",
",",
"dict",
")",
"or",
"'id'",
"not",
"in",
"job_dict",
":",
"raise",
"JobStatInvalid",
"(",
"'The job descriptio... | Create a JobStats object from the dictionary returned by celery.
Args:
worker_name (str): The name of the worker this jobs runs on.
job_dict (dict): The dictionary as returned by celery.
celery_app: Reference to a celery application object.
Returns:
JobS... | [
"Create",
"a",
"JobStats",
"object",
"from",
"the",
"dictionary",
"returned",
"by",
"celery",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/models.py#L188-L219 |
AustralianSynchrotron/lightflow | lightflow/queue/models.py | JobStats.to_dict | def to_dict(self):
""" Return a dictionary of the job stats.
Returns:
dict: Dictionary of the stats.
"""
return {
'name': self.name,
'id': self.id,
'type': self.type,
'workflow_id': self.workflow_id,
'queue': self.q... | python | def to_dict(self):
""" Return a dictionary of the job stats.
Returns:
dict: Dictionary of the stats.
"""
return {
'name': self.name,
'id': self.id,
'type': self.type,
'workflow_id': self.workflow_id,
'queue': self.q... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"{",
"'name'",
":",
"self",
".",
"name",
",",
"'id'",
":",
"self",
".",
"id",
",",
"'type'",
":",
"self",
".",
"type",
",",
"'workflow_id'",
":",
"self",
".",
"workflow_id",
",",
"'queue'",
":",
"s... | Return a dictionary of the job stats.
Returns:
dict: Dictionary of the stats. | [
"Return",
"a",
"dictionary",
"of",
"the",
"job",
"stats",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/models.py#L221-L241 |
AustralianSynchrotron/lightflow | lightflow/queue/models.py | JobEvent.from_event | def from_event(cls, event):
""" Create a JobEvent object from the event dictionary returned by celery.
Args:
event (dict): The dictionary as returned by celery.
Returns:
JobEvent: A fully initialized JobEvent object.
"""
return cls(
uuid=even... | python | def from_event(cls, event):
""" Create a JobEvent object from the event dictionary returned by celery.
Args:
event (dict): The dictionary as returned by celery.
Returns:
JobEvent: A fully initialized JobEvent object.
"""
return cls(
uuid=even... | [
"def",
"from_event",
"(",
"cls",
",",
"event",
")",
":",
"return",
"cls",
"(",
"uuid",
"=",
"event",
"[",
"'uuid'",
"]",
",",
"job_type",
"=",
"event",
"[",
"'job_type'",
"]",
",",
"event_type",
"=",
"event",
"[",
"'type'",
"]",
",",
"queue",
"=",
... | Create a JobEvent object from the event dictionary returned by celery.
Args:
event (dict): The dictionary as returned by celery.
Returns:
JobEvent: A fully initialized JobEvent object. | [
"Create",
"a",
"JobEvent",
"object",
"from",
"the",
"event",
"dictionary",
"returned",
"by",
"celery",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/models.py#L273-L293 |
AustralianSynchrotron/lightflow | lightflow/workflows.py | start_workflow | def start_workflow(name, config, *, queue=DefaultJobQueueName.Workflow,
clear_data_store=True, store_args=None):
""" Start a single workflow by sending it to the workflow queue.
Args:
name (str): The name of the workflow that should be started. Refers to the
name of the w... | python | def start_workflow(name, config, *, queue=DefaultJobQueueName.Workflow,
clear_data_store=True, store_args=None):
""" Start a single workflow by sending it to the workflow queue.
Args:
name (str): The name of the workflow that should be started. Refers to the
name of the w... | [
"def",
"start_workflow",
"(",
"name",
",",
"config",
",",
"*",
",",
"queue",
"=",
"DefaultJobQueueName",
".",
"Workflow",
",",
"clear_data_store",
"=",
"True",
",",
"store_args",
"=",
"None",
")",
":",
"try",
":",
"wf",
"=",
"Workflow",
".",
"from_name",
... | Start a single workflow by sending it to the workflow queue.
Args:
name (str): The name of the workflow that should be started. Refers to the
name of the workflow file without the .py extension.
config (Config): Reference to the configuration object from which the
settings f... | [
"Start",
"a",
"single",
"workflow",
"by",
"sending",
"it",
"to",
"the",
"workflow",
"queue",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/workflows.py#L16-L49 |
AustralianSynchrotron/lightflow | lightflow/workflows.py | stop_workflow | def stop_workflow(config, *, names=None):
""" Stop one or more workflows.
Args:
config (Config): Reference to the configuration object from which the
settings for the workflow are retrieved.
names (list): List of workflow names, workflow ids or workflow job ids for the
w... | python | def stop_workflow(config, *, names=None):
""" Stop one or more workflows.
Args:
config (Config): Reference to the configuration object from which the
settings for the workflow are retrieved.
names (list): List of workflow names, workflow ids or workflow job ids for the
w... | [
"def",
"stop_workflow",
"(",
"config",
",",
"*",
",",
"names",
"=",
"None",
")",
":",
"jobs",
"=",
"list_jobs",
"(",
"config",
",",
"filter_by_type",
"=",
"JobType",
".",
"Workflow",
")",
"if",
"names",
"is",
"not",
"None",
":",
"filtered_jobs",
"=",
"... | Stop one or more workflows.
Args:
config (Config): Reference to the configuration object from which the
settings for the workflow are retrieved.
names (list): List of workflow names, workflow ids or workflow job ids for the
workflows that should be stopped. If all workflows ... | [
"Stop",
"one",
"or",
"more",
"workflows",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/workflows.py#L52-L87 |
AustralianSynchrotron/lightflow | lightflow/workflows.py | list_workflows | def list_workflows(config):
""" List all available workflows.
Returns a list of all workflows that are available from the paths specified
in the config. A workflow is defined as a Python file with at least one DAG.
Args:
config (Config): Reference to the configuration object from which the
... | python | def list_workflows(config):
""" List all available workflows.
Returns a list of all workflows that are available from the paths specified
in the config. A workflow is defined as a Python file with at least one DAG.
Args:
config (Config): Reference to the configuration object from which the
... | [
"def",
"list_workflows",
"(",
"config",
")",
":",
"workflows",
"=",
"[",
"]",
"for",
"path",
"in",
"config",
".",
"workflows",
":",
"filenames",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"abspath",
... | List all available workflows.
Returns a list of all workflows that are available from the paths specified
in the config. A workflow is defined as a Python file with at least one DAG.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
... | [
"List",
"all",
"available",
"workflows",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/workflows.py#L90-L119 |
AustralianSynchrotron/lightflow | lightflow/workflows.py | list_jobs | def list_jobs(config, *, status=JobStatus.Active,
filter_by_type=None, filter_by_worker=None):
""" Return a list of Celery jobs.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
status (JobStatus): The status of the jo... | python | def list_jobs(config, *, status=JobStatus.Active,
filter_by_type=None, filter_by_worker=None):
""" Return a list of Celery jobs.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
status (JobStatus): The status of the jo... | [
"def",
"list_jobs",
"(",
"config",
",",
"*",
",",
"status",
"=",
"JobStatus",
".",
"Active",
",",
"filter_by_type",
"=",
"None",
",",
"filter_by_worker",
"=",
"None",
")",
":",
"celery_app",
"=",
"create_app",
"(",
"config",
")",
"# option to filter by the wor... | Return a list of Celery jobs.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
status (JobStatus): The status of the jobs that should be returned.
filter_by_type (list): Restrict the returned jobs to the types in this list.
... | [
"Return",
"a",
"list",
"of",
"Celery",
"jobs",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/workflows.py#L122-L174 |
AustralianSynchrotron/lightflow | lightflow/workflows.py | events | def events(config):
""" Return a generator that yields workflow events.
For every workflow event that is sent from celery this generator yields an event
object.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
Returns:
... | python | def events(config):
""" Return a generator that yields workflow events.
For every workflow event that is sent from celery this generator yields an event
object.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
Returns:
... | [
"def",
"events",
"(",
"config",
")",
":",
"celery_app",
"=",
"create_app",
"(",
"config",
")",
"for",
"event",
"in",
"event_stream",
"(",
"celery_app",
",",
"filter_by_prefix",
"=",
"'task'",
")",
":",
"try",
":",
"yield",
"create_event_model",
"(",
"event",... | Return a generator that yields workflow events.
For every workflow event that is sent from celery this generator yields an event
object.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
Returns:
generator: A generator that... | [
"Return",
"a",
"generator",
"that",
"yields",
"workflow",
"events",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/workflows.py#L177-L197 |
AustralianSynchrotron/lightflow | lightflow/tasks/bash_task.py | BashTaskOutputReader.run | def run(self):
""" Drain the process output streams. """
read_stdout = partial(self._read_output, stream=self._process.stdout,
callback=self._callback_stdout,
output_file=self._stdout_file)
read_stderr = partial(self._read_output, stre... | python | def run(self):
""" Drain the process output streams. """
read_stdout = partial(self._read_output, stream=self._process.stdout,
callback=self._callback_stdout,
output_file=self._stdout_file)
read_stderr = partial(self._read_output, stre... | [
"def",
"run",
"(",
"self",
")",
":",
"read_stdout",
"=",
"partial",
"(",
"self",
".",
"_read_output",
",",
"stream",
"=",
"self",
".",
"_process",
".",
"stdout",
",",
"callback",
"=",
"self",
".",
"_callback_stdout",
",",
"output_file",
"=",
"self",
".",... | Drain the process output streams. | [
"Drain",
"the",
"process",
"output",
"streams",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/tasks/bash_task.py#L64-L91 |
AustralianSynchrotron/lightflow | lightflow/tasks/bash_task.py | BashTaskOutputReader._read_output | def _read_output(self, stream, callback, output_file):
""" Read the output of the process, executed the callback and save the output.
Args:
stream: A file object pointing to the output stream that should be read.
callback(callable, None): A callback function that is called for e... | python | def _read_output(self, stream, callback, output_file):
""" Read the output of the process, executed the callback and save the output.
Args:
stream: A file object pointing to the output stream that should be read.
callback(callable, None): A callback function that is called for e... | [
"def",
"_read_output",
"(",
"self",
",",
"stream",
",",
"callback",
",",
"output_file",
")",
":",
"if",
"(",
"callback",
"is",
"None",
"and",
"output_file",
"is",
"None",
")",
"or",
"stream",
".",
"closed",
":",
"return",
"False",
"line",
"=",
"stream",
... | Read the output of the process, executed the callback and save the output.
Args:
stream: A file object pointing to the output stream that should be read.
callback(callable, None): A callback function that is called for each new
line of output.
output_file: A ... | [
"Read",
"the",
"output",
"of",
"the",
"process",
"executed",
"the",
"callback",
"and",
"save",
"the",
"output",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/tasks/bash_task.py#L93-L119 |
AustralianSynchrotron/lightflow | lightflow/tasks/bash_task.py | BashTask.run | def run(self, data, store, signal, context, **kwargs):
""" The main run method of the Python task.
Args:
data (:class:`.MultiTaskData`): The data object that has been passed from the
predecessor task.
store (:class:`.DataStoreDocument`): The persistent data store... | python | def run(self, data, store, signal, context, **kwargs):
""" The main run method of the Python task.
Args:
data (:class:`.MultiTaskData`): The data object that has been passed from the
predecessor task.
store (:class:`.DataStoreDocument`): The persistent data store... | [
"def",
"run",
"(",
"self",
",",
"data",
",",
"store",
",",
"signal",
",",
"context",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"self",
".",
"params",
".",
"eval",
"(",
"data",
",",
"store",
",",
"exclude",
"=",
"[",
"'command'",
"]",
")",... | The main run method of the Python task.
Args:
data (:class:`.MultiTaskData`): The data object that has been passed from the
predecessor task.
store (:class:`.DataStoreDocument`): The persistent data store object that allows the
task to store data for acce... | [
"The",
"main",
"run",
"method",
"of",
"the",
"Python",
"task",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/tasks/bash_task.py#L293-L389 |
AustralianSynchrotron/lightflow | lightflow/tasks/bash_task.py | BashTask._run_as | def _run_as(user, group):
""" Function wrapper that sets the user and group for the process """
def wrapper():
if user is not None:
os.setuid(user)
if group is not None:
os.setgid(group)
return wrapper | python | def _run_as(user, group):
""" Function wrapper that sets the user and group for the process """
def wrapper():
if user is not None:
os.setuid(user)
if group is not None:
os.setgid(group)
return wrapper | [
"def",
"_run_as",
"(",
"user",
",",
"group",
")",
":",
"def",
"wrapper",
"(",
")",
":",
"if",
"user",
"is",
"not",
"None",
":",
"os",
".",
"setuid",
"(",
"user",
")",
"if",
"group",
"is",
"not",
"None",
":",
"os",
".",
"setgid",
"(",
"group",
"... | Function wrapper that sets the user and group for the process | [
"Function",
"wrapper",
"that",
"sets",
"the",
"user",
"and",
"group",
"for",
"the",
"process"
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/tasks/bash_task.py#L392-L399 |
AustralianSynchrotron/lightflow | lightflow/models/parameters.py | Option.convert | def convert(self, value):
""" Convert the specified value to the type of the option.
Args:
value: The value that should be converted.
Returns:
The value with the type given by the option.
"""
if self._type is str:
return str(value)
el... | python | def convert(self, value):
""" Convert the specified value to the type of the option.
Args:
value: The value that should be converted.
Returns:
The value with the type given by the option.
"""
if self._type is str:
return str(value)
el... | [
"def",
"convert",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"_type",
"is",
"str",
":",
"return",
"str",
"(",
"value",
")",
"elif",
"self",
".",
"_type",
"is",
"int",
":",
"try",
":",
"return",
"int",
"(",
"value",
")",
"except",
"("... | Convert the specified value to the type of the option.
Args:
value: The value that should be converted.
Returns:
The value with the type given by the option. | [
"Convert",
"the",
"specified",
"value",
"to",
"the",
"type",
"of",
"the",
"option",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/parameters.py#L62-L93 |
AustralianSynchrotron/lightflow | lightflow/models/parameters.py | Parameters.check_missing | def check_missing(self, args):
""" Returns the names of all options that are required but were not specified.
All options that don't have a default value are required in order to run the
workflow.
Args:
args (dict): A dictionary of the provided arguments that is checked for... | python | def check_missing(self, args):
""" Returns the names of all options that are required but were not specified.
All options that don't have a default value are required in order to run the
workflow.
Args:
args (dict): A dictionary of the provided arguments that is checked for... | [
"def",
"check_missing",
"(",
"self",
",",
"args",
")",
":",
"return",
"[",
"opt",
".",
"name",
"for",
"opt",
"in",
"self",
"if",
"(",
"opt",
".",
"name",
"not",
"in",
"args",
")",
"and",
"(",
"opt",
".",
"default",
"is",
"None",
")",
"]"
] | Returns the names of all options that are required but were not specified.
All options that don't have a default value are required in order to run the
workflow.
Args:
args (dict): A dictionary of the provided arguments that is checked for
missing options.
... | [
"Returns",
"the",
"names",
"of",
"all",
"options",
"that",
"are",
"required",
"but",
"were",
"not",
"specified",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/parameters.py#L99-L114 |
AustralianSynchrotron/lightflow | lightflow/models/parameters.py | Parameters.consolidate | def consolidate(self, args):
""" Consolidate the provided arguments.
If the provided arguments have matching options, this performs a type conversion.
For any option that has a default value and is not present in the provided
arguments, the default value is added.
Args:
... | python | def consolidate(self, args):
""" Consolidate the provided arguments.
If the provided arguments have matching options, this performs a type conversion.
For any option that has a default value and is not present in the provided
arguments, the default value is added.
Args:
... | [
"def",
"consolidate",
"(",
"self",
",",
"args",
")",
":",
"result",
"=",
"dict",
"(",
"args",
")",
"for",
"opt",
"in",
"self",
":",
"if",
"opt",
".",
"name",
"in",
"result",
":",
"result",
"[",
"opt",
".",
"name",
"]",
"=",
"opt",
".",
"convert",... | Consolidate the provided arguments.
If the provided arguments have matching options, this performs a type conversion.
For any option that has a default value and is not present in the provided
arguments, the default value is added.
Args:
args (dict): A dictionary of the pro... | [
"Consolidate",
"the",
"provided",
"arguments",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/parameters.py#L116-L139 |
AustralianSynchrotron/lightflow | lightflow/models/dag.py | Dag.define | def define(self, schema, *, validate=True):
""" Store the task graph definition (schema).
The schema has to adhere to the following rules:
A key in the schema dict represents a parent task and the value one or more
children:
{parent: [child]} or {parent: [child1, child2]}
... | python | def define(self, schema, *, validate=True):
""" Store the task graph definition (schema).
The schema has to adhere to the following rules:
A key in the schema dict represents a parent task and the value one or more
children:
{parent: [child]} or {parent: [child1, child2]}
... | [
"def",
"define",
"(",
"self",
",",
"schema",
",",
"*",
",",
"validate",
"=",
"True",
")",
":",
"self",
".",
"_schema",
"=",
"schema",
"if",
"validate",
":",
"self",
".",
"validate",
"(",
"self",
".",
"make_graph",
"(",
"self",
".",
"_schema",
")",
... | Store the task graph definition (schema).
The schema has to adhere to the following rules:
A key in the schema dict represents a parent task and the value one or more
children:
{parent: [child]} or {parent: [child1, child2]}
The data output of one task can be routed to a l... | [
"Store",
"the",
"task",
"graph",
"definition",
"(",
"schema",
")",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/dag.py#L77-L100 |
AustralianSynchrotron/lightflow | lightflow/models/dag.py | Dag.run | def run(self, config, workflow_id, signal, *, data=None):
""" Run the dag by calling the tasks in the correct order.
Args:
config (Config): Reference to the configuration object from which the
settings for the dag are retrieved.
workflow_id (str): Th... | python | def run(self, config, workflow_id, signal, *, data=None):
""" Run the dag by calling the tasks in the correct order.
Args:
config (Config): Reference to the configuration object from which the
settings for the dag are retrieved.
workflow_id (str): Th... | [
"def",
"run",
"(",
"self",
",",
"config",
",",
"workflow_id",
",",
"signal",
",",
"*",
",",
"data",
"=",
"None",
")",
":",
"graph",
"=",
"self",
".",
"make_graph",
"(",
"self",
".",
"_schema",
")",
"# pre-checks",
"self",
".",
"validate",
"(",
"graph... | Run the dag by calling the tasks in the correct order.
Args:
config (Config): Reference to the configuration object from which the
settings for the dag are retrieved.
workflow_id (str): The unique ID of the workflow that runs this dag.
signal (Da... | [
"Run",
"the",
"dag",
"by",
"calling",
"the",
"tasks",
"in",
"the",
"correct",
"order",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/dag.py#L102-L241 |
AustralianSynchrotron/lightflow | lightflow/models/dag.py | Dag.validate | def validate(self, graph):
""" Validate the graph by checking whether it is a directed acyclic graph.
Args:
graph (DiGraph): Reference to a DiGraph object from NetworkX.
Raises:
DirectedAcyclicGraphInvalid: If the graph is not a valid dag.
"""
if not nx.... | python | def validate(self, graph):
""" Validate the graph by checking whether it is a directed acyclic graph.
Args:
graph (DiGraph): Reference to a DiGraph object from NetworkX.
Raises:
DirectedAcyclicGraphInvalid: If the graph is not a valid dag.
"""
if not nx.... | [
"def",
"validate",
"(",
"self",
",",
"graph",
")",
":",
"if",
"not",
"nx",
".",
"is_directed_acyclic_graph",
"(",
"graph",
")",
":",
"raise",
"DirectedAcyclicGraphInvalid",
"(",
"graph_name",
"=",
"self",
".",
"_name",
")"
] | Validate the graph by checking whether it is a directed acyclic graph.
Args:
graph (DiGraph): Reference to a DiGraph object from NetworkX.
Raises:
DirectedAcyclicGraphInvalid: If the graph is not a valid dag. | [
"Validate",
"the",
"graph",
"by",
"checking",
"whether",
"it",
"is",
"a",
"directed",
"acyclic",
"graph",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/dag.py#L243-L253 |
AustralianSynchrotron/lightflow | lightflow/models/dag.py | Dag.make_graph | def make_graph(schema):
""" Construct the task graph (dag) from a given schema.
Parses the graph schema definition and creates the task graph. Tasks are the
vertices of the graph and the connections defined in the schema become the edges.
A key in the schema dict represents a parent ta... | python | def make_graph(schema):
""" Construct the task graph (dag) from a given schema.
Parses the graph schema definition and creates the task graph. Tasks are the
vertices of the graph and the connections defined in the schema become the edges.
A key in the schema dict represents a parent ta... | [
"def",
"make_graph",
"(",
"schema",
")",
":",
"if",
"schema",
"is",
"None",
":",
"raise",
"DirectedAcyclicGraphUndefined",
"(",
")",
"# sanitize the input schema such that it follows the structure:",
"# {parent: {child_1: slot_1, child_2: slot_2, ...}, ...}",
"sanitized_schema",... | Construct the task graph (dag) from a given schema.
Parses the graph schema definition and creates the task graph. Tasks are the
vertices of the graph and the connections defined in the schema become the edges.
A key in the schema dict represents a parent task and the value one or more
... | [
"Construct",
"the",
"task",
"graph",
"(",
"dag",
")",
"from",
"a",
"given",
"schema",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/dag.py#L256-L318 |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | TaskData.merge | def merge(self, dataset):
""" Merge the specified dataset on top of the existing data.
This replaces all values in the existing dataset with the values from the
given dataset.
Args:
dataset (TaskData): A reference to the TaskData object that should be merged
... | python | def merge(self, dataset):
""" Merge the specified dataset on top of the existing data.
This replaces all values in the existing dataset with the values from the
given dataset.
Args:
dataset (TaskData): A reference to the TaskData object that should be merged
... | [
"def",
"merge",
"(",
"self",
",",
"dataset",
")",
":",
"def",
"merge_data",
"(",
"source",
",",
"dest",
")",
":",
"for",
"key",
",",
"value",
"in",
"source",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"m... | Merge the specified dataset on top of the existing data.
This replaces all values in the existing dataset with the values from the
given dataset.
Args:
dataset (TaskData): A reference to the TaskData object that should be merged
on top of the existing object. | [
"Merge",
"the",
"specified",
"dataset",
"on",
"top",
"of",
"the",
"existing",
"data",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L59-L81 |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | MultiTaskData.add_dataset | def add_dataset(self, task_name, dataset=None, *, aliases=None):
""" Add a new dataset to the MultiTaskData.
Args:
task_name (str): The name of the task from which the dataset was received.
dataset (TaskData): The dataset that should be added.
aliases (list): A list ... | python | def add_dataset(self, task_name, dataset=None, *, aliases=None):
""" Add a new dataset to the MultiTaskData.
Args:
task_name (str): The name of the task from which the dataset was received.
dataset (TaskData): The dataset that should be added.
aliases (list): A list ... | [
"def",
"add_dataset",
"(",
"self",
",",
"task_name",
",",
"dataset",
"=",
"None",
",",
"*",
",",
"aliases",
"=",
"None",
")",
":",
"self",
".",
"_datasets",
".",
"append",
"(",
"dataset",
"if",
"dataset",
"is",
"not",
"None",
"else",
"TaskData",
"(",
... | Add a new dataset to the MultiTaskData.
Args:
task_name (str): The name of the task from which the dataset was received.
dataset (TaskData): The dataset that should be added.
aliases (list): A list of aliases that should be registered with the dataset. | [
"Add",
"a",
"new",
"dataset",
"to",
"the",
"MultiTaskData",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L146-L163 |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | MultiTaskData.add_alias | def add_alias(self, alias, index):
""" Add an alias pointing to the specified index.
Args:
alias (str): The alias that should point to the given index.
index (int): The index of the dataset for which an alias should be added.
Raises:
DataInvalidIndex: If the... | python | def add_alias(self, alias, index):
""" Add an alias pointing to the specified index.
Args:
alias (str): The alias that should point to the given index.
index (int): The index of the dataset for which an alias should be added.
Raises:
DataInvalidIndex: If the... | [
"def",
"add_alias",
"(",
"self",
",",
"alias",
",",
"index",
")",
":",
"if",
"index",
">=",
"len",
"(",
"self",
".",
"_datasets",
")",
":",
"raise",
"DataInvalidIndex",
"(",
"'A dataset with index {} does not exist'",
".",
"format",
"(",
"index",
")",
")",
... | Add an alias pointing to the specified index.
Args:
alias (str): The alias that should point to the given index.
index (int): The index of the dataset for which an alias should be added.
Raises:
DataInvalidIndex: If the index does not represent a valid dataset. | [
"Add",
"an",
"alias",
"pointing",
"to",
"the",
"specified",
"index",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L165-L177 |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | MultiTaskData.flatten | def flatten(self, in_place=True):
""" Merge all datasets into a single dataset.
The default dataset is the last dataset to be merged, as it is considered to be
the primary source of information and should overwrite all existing fields with
the same key.
Args:
in_pla... | python | def flatten(self, in_place=True):
""" Merge all datasets into a single dataset.
The default dataset is the last dataset to be merged, as it is considered to be
the primary source of information and should overwrite all existing fields with
the same key.
Args:
in_pla... | [
"def",
"flatten",
"(",
"self",
",",
"in_place",
"=",
"True",
")",
":",
"new_dataset",
"=",
"TaskData",
"(",
")",
"for",
"i",
",",
"dataset",
"in",
"enumerate",
"(",
"self",
".",
"_datasets",
")",
":",
"if",
"i",
"!=",
"self",
".",
"_default_index",
"... | Merge all datasets into a single dataset.
The default dataset is the last dataset to be merged, as it is considered to be
the primary source of information and should overwrite all existing fields with
the same key.
Args:
in_place (bool): Set to ``True`` to replace the exis... | [
"Merge",
"all",
"datasets",
"into",
"a",
"single",
"dataset",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L179-L211 |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | MultiTaskData.set_default_by_alias | def set_default_by_alias(self, alias):
""" Set the default dataset by its alias.
After changing the default dataset, all calls without explicitly specifying the
dataset by index or alias will be redirected to this dataset.
Args:
alias (str): The alias of the dataset that sh... | python | def set_default_by_alias(self, alias):
""" Set the default dataset by its alias.
After changing the default dataset, all calls without explicitly specifying the
dataset by index or alias will be redirected to this dataset.
Args:
alias (str): The alias of the dataset that sh... | [
"def",
"set_default_by_alias",
"(",
"self",
",",
"alias",
")",
":",
"if",
"alias",
"not",
"in",
"self",
".",
"_aliases",
":",
"raise",
"DataInvalidAlias",
"(",
"'A dataset with alias {} does not exist'",
".",
"format",
"(",
"alias",
")",
")",
"self",
".",
"_de... | Set the default dataset by its alias.
After changing the default dataset, all calls without explicitly specifying the
dataset by index or alias will be redirected to this dataset.
Args:
alias (str): The alias of the dataset that should be made the default.
Raises:
... | [
"Set",
"the",
"default",
"dataset",
"by",
"its",
"alias",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L213-L228 |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | MultiTaskData.set_default_by_index | def set_default_by_index(self, index):
""" Set the default dataset by its index.
After changing the default dataset, all calls without explicitly specifying the
dataset by index or alias will be redirected to this dataset.
Args:
index (int): The index of the dataset that sh... | python | def set_default_by_index(self, index):
""" Set the default dataset by its index.
After changing the default dataset, all calls without explicitly specifying the
dataset by index or alias will be redirected to this dataset.
Args:
index (int): The index of the dataset that sh... | [
"def",
"set_default_by_index",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
">=",
"len",
"(",
"self",
".",
"_datasets",
")",
":",
"raise",
"DataInvalidIndex",
"(",
"'A dataset with index {} does not exist'",
".",
"format",
"(",
"index",
")",
")",
"self"... | Set the default dataset by its index.
After changing the default dataset, all calls without explicitly specifying the
dataset by index or alias will be redirected to this dataset.
Args:
index (int): The index of the dataset that should be made the default.
Raises:
... | [
"Set",
"the",
"default",
"dataset",
"by",
"its",
"index",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L230-L245 |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | MultiTaskData.get_by_alias | def get_by_alias(self, alias):
""" Return a dataset by its alias.
Args:
alias (str): The alias of the dataset that should be returned.
Raises:
DataInvalidAlias: If the alias does not represent a valid dataset.
"""
if alias not in self._aliases:
... | python | def get_by_alias(self, alias):
""" Return a dataset by its alias.
Args:
alias (str): The alias of the dataset that should be returned.
Raises:
DataInvalidAlias: If the alias does not represent a valid dataset.
"""
if alias not in self._aliases:
... | [
"def",
"get_by_alias",
"(",
"self",
",",
"alias",
")",
":",
"if",
"alias",
"not",
"in",
"self",
".",
"_aliases",
":",
"raise",
"DataInvalidAlias",
"(",
"'A dataset with alias {} does not exist'",
".",
"format",
"(",
"alias",
")",
")",
"return",
"self",
".",
... | Return a dataset by its alias.
Args:
alias (str): The alias of the dataset that should be returned.
Raises:
DataInvalidAlias: If the alias does not represent a valid dataset. | [
"Return",
"a",
"dataset",
"by",
"its",
"alias",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L247-L259 |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | MultiTaskData.get_by_index | def get_by_index(self, index):
""" Return a dataset by its index.
Args:
index (int): The index of the dataset that should be returned.
Raises:
DataInvalidIndex: If the index does not represent a valid dataset.
"""
if index >= len(self._datasets):
... | python | def get_by_index(self, index):
""" Return a dataset by its index.
Args:
index (int): The index of the dataset that should be returned.
Raises:
DataInvalidIndex: If the index does not represent a valid dataset.
"""
if index >= len(self._datasets):
... | [
"def",
"get_by_index",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
">=",
"len",
"(",
"self",
".",
"_datasets",
")",
":",
"raise",
"DataInvalidIndex",
"(",
"'A dataset with index {} does not exist'",
".",
"format",
"(",
"index",
")",
")",
"return",
"s... | Return a dataset by its index.
Args:
index (int): The index of the dataset that should be returned.
Raises:
DataInvalidIndex: If the index does not represent a valid dataset. | [
"Return",
"a",
"dataset",
"by",
"its",
"index",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L261-L273 |
AustralianSynchrotron/lightflow | lightflow/tasks/python_task.py | PythonTask.run | def run(self, data, store, signal, context, **kwargs):
""" The main run method of the Python task.
Args:
data (:class:`.MultiTaskData`): The data object that has been passed from the
predecessor task.
store (:class:`.DataStoreDocument`): The persistent data store... | python | def run(self, data, store, signal, context, **kwargs):
""" The main run method of the Python task.
Args:
data (:class:`.MultiTaskData`): The data object that has been passed from the
predecessor task.
store (:class:`.DataStoreDocument`): The persistent data store... | [
"def",
"run",
"(",
"self",
",",
"data",
",",
"store",
",",
"signal",
",",
"context",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_callback",
"is",
"not",
"None",
":",
"result",
"=",
"self",
".",
"_callback",
"(",
"data",
",",
"store",
... | The main run method of the Python task.
Args:
data (:class:`.MultiTaskData`): The data object that has been passed from the
predecessor task.
store (:class:`.DataStoreDocument`): The persistent data store object that allows the
task to store data for acce... | [
"The",
"main",
"run",
"method",
"of",
"the",
"Python",
"task",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/tasks/python_task.py#L80-L99 |
AustralianSynchrotron/lightflow | lightflow/models/task_context.py | TaskContext.to_dict | def to_dict(self):
""" Return the task context content as a dictionary. """
return {
'task_name': self.task_name,
'dag_name': self.dag_name,
'workflow_name': self.workflow_name,
'workflow_id': self.workflow_id,
'worker_hostname': self.worker_ho... | python | def to_dict(self):
""" Return the task context content as a dictionary. """
return {
'task_name': self.task_name,
'dag_name': self.dag_name,
'workflow_name': self.workflow_name,
'workflow_id': self.workflow_id,
'worker_hostname': self.worker_ho... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"{",
"'task_name'",
":",
"self",
".",
"task_name",
",",
"'dag_name'",
":",
"self",
".",
"dag_name",
",",
"'workflow_name'",
":",
"self",
".",
"workflow_name",
",",
"'workflow_id'",
":",
"self",
".",
"workf... | Return the task context content as a dictionary. | [
"Return",
"the",
"task",
"context",
"content",
"as",
"a",
"dictionary",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_context.py#L21-L29 |
AustralianSynchrotron/lightflow | lightflow/workers.py | start_worker | def start_worker(queues, config, *, name=None, celery_args=None, check_datastore=True):
""" Start a worker process.
Args:
queues (list): List of queue names this worker accepts jobs from.
config (Config): Reference to the configuration object from which the
settings for the worker a... | python | def start_worker(queues, config, *, name=None, celery_args=None, check_datastore=True):
""" Start a worker process.
Args:
queues (list): List of queue names this worker accepts jobs from.
config (Config): Reference to the configuration object from which the
settings for the worker a... | [
"def",
"start_worker",
"(",
"queues",
",",
"config",
",",
"*",
",",
"name",
"=",
"None",
",",
"celery_args",
"=",
"None",
",",
"check_datastore",
"=",
"True",
")",
":",
"celery_app",
"=",
"create_app",
"(",
"config",
")",
"if",
"check_datastore",
":",
"w... | Start a worker process.
Args:
queues (list): List of queue names this worker accepts jobs from.
config (Config): Reference to the configuration object from which the
settings for the worker are retrieved.
name (string): Unique name for the worker. The hostname template variables... | [
"Start",
"a",
"worker",
"process",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/workers.py#L10-L42 |
AustralianSynchrotron/lightflow | lightflow/workers.py | stop_worker | def stop_worker(config, *, worker_ids=None):
""" Stop a worker process.
Args:
config (Config): Reference to the configuration object from which the
settings for the worker are retrieved.
worker_ids (list): An optional list of ids for the worker that should be stopped.
"""
if... | python | def stop_worker(config, *, worker_ids=None):
""" Stop a worker process.
Args:
config (Config): Reference to the configuration object from which the
settings for the worker are retrieved.
worker_ids (list): An optional list of ids for the worker that should be stopped.
"""
if... | [
"def",
"stop_worker",
"(",
"config",
",",
"*",
",",
"worker_ids",
"=",
"None",
")",
":",
"if",
"worker_ids",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"worker_ids",
",",
"list",
")",
":",
"worker_ids",
"=",
"[",
"worker_ids",
"]",
"celery_app... | Stop a worker process.
Args:
config (Config): Reference to the configuration object from which the
settings for the worker are retrieved.
worker_ids (list): An optional list of ids for the worker that should be stopped. | [
"Stop",
"a",
"worker",
"process",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/workers.py#L45-L57 |
AustralianSynchrotron/lightflow | lightflow/workers.py | list_workers | def list_workers(config, *, filter_by_queues=None):
""" Return a list of all available workers.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
filter_by_queues (list): Restrict the returned workers to workers that listen to
... | python | def list_workers(config, *, filter_by_queues=None):
""" Return a list of all available workers.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
filter_by_queues (list): Restrict the returned workers to workers that listen to
... | [
"def",
"list_workers",
"(",
"config",
",",
"*",
",",
"filter_by_queues",
"=",
"None",
")",
":",
"celery_app",
"=",
"create_app",
"(",
"config",
")",
"worker_stats",
"=",
"celery_app",
".",
"control",
".",
"inspect",
"(",
")",
".",
"stats",
"(",
")",
"que... | Return a list of all available workers.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
filter_by_queues (list): Restrict the returned workers to workers that listen to
at least one of the queue names in this list.
Ret... | [
"Return",
"a",
"list",
"of",
"all",
"available",
"workers",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/workers.py#L60-L93 |
AustralianSynchrotron/lightflow | lightflow/models/task_parameters.py | TaskParameters.eval | def eval(self, data, data_store, *, exclude=None):
""" Return a new object in which callable parameters have been evaluated.
Native types are not touched and simply returned, while callable methods are
executed and their return value is returned.
Args:
data (MultiTaskData):... | python | def eval(self, data, data_store, *, exclude=None):
""" Return a new object in which callable parameters have been evaluated.
Native types are not touched and simply returned, while callable methods are
executed and their return value is returned.
Args:
data (MultiTaskData):... | [
"def",
"eval",
"(",
"self",
",",
"data",
",",
"data_store",
",",
"*",
",",
"exclude",
"=",
"None",
")",
":",
"exclude",
"=",
"[",
"]",
"if",
"exclude",
"is",
"None",
"else",
"exclude",
"result",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"s... | Return a new object in which callable parameters have been evaluated.
Native types are not touched and simply returned, while callable methods are
executed and their return value is returned.
Args:
data (MultiTaskData): The data object that has been passed from the
... | [
"Return",
"a",
"new",
"object",
"in",
"which",
"callable",
"parameters",
"have",
"been",
"evaluated",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_parameters.py#L60-L90 |
AustralianSynchrotron/lightflow | lightflow/models/task_parameters.py | TaskParameters.eval_single | def eval_single(self, key, data, data_store):
""" Evaluate the value of a single parameter taking into account callables .
Native types are not touched and simply returned, while callable methods are
executed and their return value is returned.
Args:
key (str): The name of ... | python | def eval_single(self, key, data, data_store):
""" Evaluate the value of a single parameter taking into account callables .
Native types are not touched and simply returned, while callable methods are
executed and their return value is returned.
Args:
key (str): The name of ... | [
"def",
"eval_single",
"(",
"self",
",",
"key",
",",
"data",
",",
"data_store",
")",
":",
"if",
"key",
"in",
"self",
":",
"value",
"=",
"self",
"[",
"key",
"]",
"if",
"value",
"is",
"not",
"None",
"and",
"callable",
"(",
"value",
")",
":",
"return",... | Evaluate the value of a single parameter taking into account callables .
Native types are not touched and simply returned, while callable methods are
executed and their return value is returned.
Args:
key (str): The name of the parameter that should be evaluated.
data (... | [
"Evaluate",
"the",
"value",
"of",
"a",
"single",
"parameter",
"taking",
"into",
"account",
"callables",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_parameters.py#L92-L114 |
dh1tw/pyhamtools | pyhamtools/qsl.py | get_lotw_users | def get_lotw_users(**kwargs):
"""Download the latest offical list of `ARRL Logbook of the World (LOTW)`__ users.
Args:
url (str, optional): Download URL
Returns:
dict: Dictionary containing the callsign (unicode) date of the last LOTW upload (datetime)
Raises:
... | python | def get_lotw_users(**kwargs):
"""Download the latest offical list of `ARRL Logbook of the World (LOTW)`__ users.
Args:
url (str, optional): Download URL
Returns:
dict: Dictionary containing the callsign (unicode) date of the last LOTW upload (datetime)
Raises:
... | [
"def",
"get_lotw_users",
"(",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"\"\"",
"lotw",
"=",
"{",
"}",
"try",
":",
"url",
"=",
"kwargs",
"[",
"'url'",
"]",
"except",
"KeyError",
":",
"# url = \"http://wd5eae.org/LoTW_Data.txt\"",
"url",
"=",
"\"https://lotw.... | Download the latest offical list of `ARRL Logbook of the World (LOTW)`__ users.
Args:
url (str, optional): Download URL
Returns:
dict: Dictionary containing the callsign (unicode) date of the last LOTW upload (datetime)
Raises:
IOError: When network is unav... | [
"Download",
"the",
"latest",
"offical",
"list",
"of",
"ARRL",
"Logbook",
"of",
"the",
"World",
"(",
"LOTW",
")",
"__",
"users",
"."
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/qsl.py#L12-L69 |
dh1tw/pyhamtools | pyhamtools/qsl.py | get_clublog_users | def get_clublog_users(**kwargs):
"""Download the latest offical list of `Clublog`__ users.
Args:
url (str, optional): Download URL
Returns:
dict: Dictionary containing (if data available) the fields:
firstqso, lastqso, last-lotw, lastupload (datetime),
... | python | def get_clublog_users(**kwargs):
"""Download the latest offical list of `Clublog`__ users.
Args:
url (str, optional): Download URL
Returns:
dict: Dictionary containing (if data available) the fields:
firstqso, lastqso, last-lotw, lastupload (datetime),
... | [
"def",
"get_clublog_users",
"(",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"\"\"",
"clublog",
"=",
"{",
"}",
"try",
":",
"url",
"=",
"kwargs",
"[",
"'url'",
"]",
"except",
"KeyError",
":",
"url",
"=",
"\"https://secure.clublog.org/clublog-users.json.zip\"",
... | Download the latest offical list of `Clublog`__ users.
Args:
url (str, optional): Download URL
Returns:
dict: Dictionary containing (if data available) the fields:
firstqso, lastqso, last-lotw, lastupload (datetime),
locator (string) and oqrs (bo... | [
"Download",
"the",
"latest",
"offical",
"list",
"of",
"Clublog",
"__",
"users",
"."
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/qsl.py#L71-L157 |
dh1tw/pyhamtools | pyhamtools/qsl.py | get_eqsl_users | def get_eqsl_users(**kwargs):
"""Download the latest official list of `EQSL.cc`__ users. The list of users can be found here_.
Args:
url (str, optional): Download URL
Returns:
list: List containing the callsigns of EQSL users (unicode)
Raises:
IOError: ... | python | def get_eqsl_users(**kwargs):
"""Download the latest official list of `EQSL.cc`__ users. The list of users can be found here_.
Args:
url (str, optional): Download URL
Returns:
list: List containing the callsigns of EQSL users (unicode)
Raises:
IOError: ... | [
"def",
"get_eqsl_users",
"(",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"\"\"",
"eqsl",
"=",
"[",
"]",
"try",
":",
"url",
"=",
"kwargs",
"[",
"'url'",
"]",
"except",
"KeyError",
":",
"url",
"=",
"\"http://www.eqsl.cc/QSLCard/DownloadedFiles/AGMemberlist.txt\""... | Download the latest official list of `EQSL.cc`__ users. The list of users can be found here_.
Args:
url (str, optional): Download URL
Returns:
list: List containing the callsigns of EQSL users (unicode)
Raises:
IOError: When network is unavailable, file can... | [
"Download",
"the",
"latest",
"official",
"list",
"of",
"EQSL",
".",
"cc",
"__",
"users",
".",
"The",
"list",
"of",
"users",
"can",
"be",
"found",
"here_",
"."
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/qsl.py#L159-L206 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib.copy_data_in_redis | def copy_data_in_redis(self, redis_prefix, redis_instance):
"""
Copy the complete lookup data into redis. Old data will be overwritten.
Args:
redis_prefix (str): Prefix to distinguish the data in redis for the different looktypes
redis_instance (str): an Instance of Redi... | python | def copy_data_in_redis(self, redis_prefix, redis_instance):
"""
Copy the complete lookup data into redis. Old data will be overwritten.
Args:
redis_prefix (str): Prefix to distinguish the data in redis for the different looktypes
redis_instance (str): an Instance of Redi... | [
"def",
"copy_data_in_redis",
"(",
"self",
",",
"redis_prefix",
",",
"redis_instance",
")",
":",
"if",
"redis_instance",
"is",
"not",
"None",
":",
"self",
".",
"_redis",
"=",
"redis_instance",
"if",
"self",
".",
"_redis",
"is",
"None",
":",
"raise",
"Attribut... | Copy the complete lookup data into redis. Old data will be overwritten.
Args:
redis_prefix (str): Prefix to distinguish the data in redis for the different looktypes
redis_instance (str): an Instance of Redis
Returns:
bool: returns True when the data has been copied... | [
"Copy",
"the",
"complete",
"lookup",
"data",
"into",
"redis",
".",
"Old",
"data",
"will",
"be",
"overwritten",
"."
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L151-L223 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib.lookup_entity | def lookup_entity(self, entity=None):
"""Returns lookup data of an ADIF Entity
Args:
entity (int): ADIF identifier of country
Returns:
dict: Dictionary containing the country specific data
Raises:
KeyError: No matching entity found
Example:... | python | def lookup_entity(self, entity=None):
"""Returns lookup data of an ADIF Entity
Args:
entity (int): ADIF identifier of country
Returns:
dict: Dictionary containing the country specific data
Raises:
KeyError: No matching entity found
Example:... | [
"def",
"lookup_entity",
"(",
"self",
",",
"entity",
"=",
"None",
")",
":",
"if",
"self",
".",
"_lookuptype",
"==",
"\"clublogxml\"",
":",
"entity",
"=",
"int",
"(",
"entity",
")",
"if",
"entity",
"in",
"self",
".",
"_entities",
":",
"return",
"self",
"... | Returns lookup data of an ADIF Entity
Args:
entity (int): ADIF identifier of country
Returns:
dict: Dictionary containing the country specific data
Raises:
KeyError: No matching entity found
Example:
The following code queries the the Cl... | [
"Returns",
"lookup",
"data",
"of",
"an",
"ADIF",
"Entity"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L243-L302 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._strip_metadata | def _strip_metadata(self, my_dict):
"""
Create a copy of dict and remove not needed data
"""
new_dict = copy.deepcopy(my_dict)
if const.START in new_dict:
del new_dict[const.START]
if const.END in new_dict:
del new_dict[const.END]
if const.... | python | def _strip_metadata(self, my_dict):
"""
Create a copy of dict and remove not needed data
"""
new_dict = copy.deepcopy(my_dict)
if const.START in new_dict:
del new_dict[const.START]
if const.END in new_dict:
del new_dict[const.END]
if const.... | [
"def",
"_strip_metadata",
"(",
"self",
",",
"my_dict",
")",
":",
"new_dict",
"=",
"copy",
".",
"deepcopy",
"(",
"my_dict",
")",
"if",
"const",
".",
"START",
"in",
"new_dict",
":",
"del",
"new_dict",
"[",
"const",
".",
"START",
"]",
"if",
"const",
".",
... | Create a copy of dict and remove not needed data | [
"Create",
"a",
"copy",
"of",
"dict",
"and",
"remove",
"not",
"needed",
"data"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L304-L319 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib.lookup_callsign | def lookup_callsign(self, callsign=None, timestamp=timestamp_now):
"""
Returns lookup data if an exception exists for a callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
... | python | def lookup_callsign(self, callsign=None, timestamp=timestamp_now):
"""
Returns lookup data if an exception exists for a callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
... | [
"def",
"lookup_callsign",
"(",
"self",
",",
"callsign",
"=",
"None",
",",
"timestamp",
"=",
"timestamp_now",
")",
":",
"callsign",
"=",
"callsign",
".",
"strip",
"(",
")",
".",
"upper",
"(",
")",
"if",
"self",
".",
"_lookuptype",
"==",
"\"clublogapi\"",
... | Returns lookup data if an exception exists for a callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
dict: Dictionary containing the country specific data of the callsign
Raises... | [
"Returns",
"lookup",
"data",
"if",
"an",
"exception",
"exists",
"for",
"a",
"callsign"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L322-L388 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._get_dicts_from_redis | def _get_dicts_from_redis(self, name, index_name, redis_prefix, item):
"""
Retrieve the data of an item from redis and put it in an index and data dictionary to match the
common query interface.
"""
r = self._redis
data_dict = {}
data_index_dict = {}
if r... | python | def _get_dicts_from_redis(self, name, index_name, redis_prefix, item):
"""
Retrieve the data of an item from redis and put it in an index and data dictionary to match the
common query interface.
"""
r = self._redis
data_dict = {}
data_index_dict = {}
if r... | [
"def",
"_get_dicts_from_redis",
"(",
"self",
",",
"name",
",",
"index_name",
",",
"redis_prefix",
",",
"item",
")",
":",
"r",
"=",
"self",
".",
"_redis",
"data_dict",
"=",
"{",
"}",
"data_index_dict",
"=",
"{",
"}",
"if",
"redis_prefix",
"is",
"None",
":... | Retrieve the data of an item from redis and put it in an index and data dictionary to match the
common query interface. | [
"Retrieve",
"the",
"data",
"of",
"an",
"item",
"from",
"redis",
"and",
"put",
"it",
"in",
"an",
"index",
"and",
"data",
"dictionary",
"to",
"match",
"the",
"common",
"query",
"interface",
"."
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L390-L411 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._check_data_for_date | def _check_data_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks if the item is found in the index. An entry in the index points to the data
in the data_dict. This is mainly used retrieve callsigns and prefixes.
In case data is found for item, a dict containing the... | python | def _check_data_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks if the item is found in the index. An entry in the index points to the data
in the data_dict. This is mainly used retrieve callsigns and prefixes.
In case data is found for item, a dict containing the... | [
"def",
"_check_data_for_date",
"(",
"self",
",",
"item",
",",
"timestamp",
",",
"data_dict",
",",
"data_index_dict",
")",
":",
"if",
"item",
"in",
"data_index_dict",
":",
"for",
"item",
"in",
"data_index_dict",
"[",
"item",
"]",
":",
"# startdate < timestamp",
... | Checks if the item is found in the index. An entry in the index points to the data
in the data_dict. This is mainly used retrieve callsigns and prefixes.
In case data is found for item, a dict containing the data is returned. Otherwise a KeyError is raised. | [
"Checks",
"if",
"the",
"item",
"is",
"found",
"in",
"the",
"index",
".",
"An",
"entry",
"in",
"the",
"index",
"points",
"to",
"the",
"data",
"in",
"the",
"data_dict",
".",
"This",
"is",
"mainly",
"used",
"retrieve",
"callsigns",
"and",
"prefixes",
".",
... | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L413-L450 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._check_inv_operation_for_date | def _check_inv_operation_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks if the callsign is marked as an invalid operation for a given timestamp.
In case the operation is invalid, True is returned. Otherwise a KeyError is raised.
"""
if item in data_index... | python | def _check_inv_operation_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks if the callsign is marked as an invalid operation for a given timestamp.
In case the operation is invalid, True is returned. Otherwise a KeyError is raised.
"""
if item in data_index... | [
"def",
"_check_inv_operation_for_date",
"(",
"self",
",",
"item",
",",
"timestamp",
",",
"data_dict",
",",
"data_index_dict",
")",
":",
"if",
"item",
"in",
"data_index_dict",
":",
"for",
"item",
"in",
"data_index_dict",
"[",
"item",
"]",
":",
"# startdate < time... | Checks if the callsign is marked as an invalid operation for a given timestamp.
In case the operation is invalid, True is returned. Otherwise a KeyError is raised. | [
"Checks",
"if",
"the",
"callsign",
"is",
"marked",
"as",
"an",
"invalid",
"operation",
"for",
"a",
"given",
"timestamp",
".",
"In",
"case",
"the",
"operation",
"is",
"invalid",
"True",
"is",
"returned",
".",
"Otherwise",
"a",
"KeyError",
"is",
"raised",
".... | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L453-L482 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib.lookup_prefix | def lookup_prefix(self, prefix, timestamp=timestamp_now):
"""
Returns lookup data of a Prefix
Args:
prefix (string): Prefix of a Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
dict: Dictionary contai... | python | def lookup_prefix(self, prefix, timestamp=timestamp_now):
"""
Returns lookup data of a Prefix
Args:
prefix (string): Prefix of a Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
dict: Dictionary contai... | [
"def",
"lookup_prefix",
"(",
"self",
",",
"prefix",
",",
"timestamp",
"=",
"timestamp_now",
")",
":",
"prefix",
"=",
"prefix",
".",
"strip",
"(",
")",
".",
"upper",
"(",
")",
"if",
"self",
".",
"_lookuptype",
"==",
"\"clublogxml\"",
"or",
"self",
".",
... | Returns lookup data of a Prefix
Args:
prefix (string): Prefix of a Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
dict: Dictionary containing the country specific data of the Prefix
Raises:
KeyE... | [
"Returns",
"lookup",
"data",
"of",
"a",
"Prefix"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L485-L538 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib.is_invalid_operation | def is_invalid_operation(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
"""
Returns True if an operations is known as invalid
Args:
callsign (string): Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Ret... | python | def is_invalid_operation(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
"""
Returns True if an operations is known as invalid
Args:
callsign (string): Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Ret... | [
"def",
"is_invalid_operation",
"(",
"self",
",",
"callsign",
",",
"timestamp",
"=",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"UTC",
")",
")",
":",
"callsign",
"=",
"callsign",
".",
"strip",
"(",
")",
".",
"upper",
"(",
... | Returns True if an operations is known as invalid
Args:
callsign (string): Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
bool: True if a record exists for this callsign (at the given time)
Raises:
... | [
"Returns",
"True",
"if",
"an",
"operations",
"is",
"known",
"as",
"invalid"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L540-L591 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._check_zone_exception_for_date | def _check_zone_exception_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks the index and data if a cq-zone exception exists for the callsign
When a zone exception is found, the zone is returned. If no exception is found
a KeyError is raised
"""
if ... | python | def _check_zone_exception_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks the index and data if a cq-zone exception exists for the callsign
When a zone exception is found, the zone is returned. If no exception is found
a KeyError is raised
"""
if ... | [
"def",
"_check_zone_exception_for_date",
"(",
"self",
",",
"item",
",",
"timestamp",
",",
"data_dict",
",",
"data_index_dict",
")",
":",
"if",
"item",
"in",
"data_index_dict",
":",
"for",
"item",
"in",
"data_index_dict",
"[",
"item",
"]",
":",
"# startdate < tim... | Checks the index and data if a cq-zone exception exists for the callsign
When a zone exception is found, the zone is returned. If no exception is found
a KeyError is raised | [
"Checks",
"the",
"index",
"and",
"data",
"if",
"a",
"cq",
"-",
"zone",
"exception",
"exists",
"for",
"the",
"callsign",
"When",
"a",
"zone",
"exception",
"is",
"found",
"the",
"zone",
"is",
"returned",
".",
"If",
"no",
"exception",
"is",
"found",
"a",
... | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L594-L624 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib.lookup_zone_exception | def lookup_zone_exception(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
"""
Returns a CQ Zone if an exception exists for the given callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
... | python | def lookup_zone_exception(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
"""
Returns a CQ Zone if an exception exists for the given callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
... | [
"def",
"lookup_zone_exception",
"(",
"self",
",",
"callsign",
",",
"timestamp",
"=",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"UTC",
")",
")",
":",
"callsign",
"=",
"callsign",
".",
"strip",
"(",
")",
".",
"upper",
"(",
... | Returns a CQ Zone if an exception exists for the given callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
int: Value of the the CQ Zone exception which exists for this callsign (at the given ti... | [
"Returns",
"a",
"CQ",
"Zone",
"if",
"an",
"exception",
"exists",
"for",
"the",
"given",
"callsign"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L627-L673 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._lookup_clublogAPI | def _lookup_clublogAPI(self, callsign=None, timestamp=timestamp_now, url="https://secure.clublog.org/dxcc", apikey=None):
""" Set up the Lookup object for Clublog Online API
"""
params = {"year" : timestamp.strftime("%Y"),
"month" : timestamp.strftime("%m"),
"day" : time... | python | def _lookup_clublogAPI(self, callsign=None, timestamp=timestamp_now, url="https://secure.clublog.org/dxcc", apikey=None):
""" Set up the Lookup object for Clublog Online API
"""
params = {"year" : timestamp.strftime("%Y"),
"month" : timestamp.strftime("%m"),
"day" : time... | [
"def",
"_lookup_clublogAPI",
"(",
"self",
",",
"callsign",
"=",
"None",
",",
"timestamp",
"=",
"timestamp_now",
",",
"url",
"=",
"\"https://secure.clublog.org/dxcc\"",
",",
"apikey",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"year\"",
":",
"timestamp",
".",... | Set up the Lookup object for Clublog Online API | [
"Set",
"up",
"the",
"Lookup",
"object",
"for",
"Clublog",
"Online",
"API"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L675-L712 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._lookup_qrz_dxcc | def _lookup_qrz_dxcc(self, dxcc_or_callsign, apikey, apiv="1.3.3"):
""" Performs the dxcc lookup against the QRZ.com XML API:
"""
response = self._request_dxcc_info_from_qrz(dxcc_or_callsign, apikey, apiv=apiv)
root = BeautifulSoup(response.text, "html.parser")
lookup = {}
... | python | def _lookup_qrz_dxcc(self, dxcc_or_callsign, apikey, apiv="1.3.3"):
""" Performs the dxcc lookup against the QRZ.com XML API:
"""
response = self._request_dxcc_info_from_qrz(dxcc_or_callsign, apikey, apiv=apiv)
root = BeautifulSoup(response.text, "html.parser")
lookup = {}
... | [
"def",
"_lookup_qrz_dxcc",
"(",
"self",
",",
"dxcc_or_callsign",
",",
"apikey",
",",
"apiv",
"=",
"\"1.3.3\"",
")",
":",
"response",
"=",
"self",
".",
"_request_dxcc_info_from_qrz",
"(",
"dxcc_or_callsign",
",",
"apikey",
",",
"apiv",
"=",
"apiv",
")",
"root",... | Performs the dxcc lookup against the QRZ.com XML API: | [
"Performs",
"the",
"dxcc",
"lookup",
"against",
"the",
"QRZ",
".",
"com",
"XML",
"API",
":"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L746-L790 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._lookup_qrz_callsign | def _lookup_qrz_callsign(self, callsign=None, apikey=None, apiv="1.3.3"):
""" Performs the callsign lookup against the QRZ.com XML API:
"""
if apikey is None:
raise AttributeError("Session Key Missing")
callsign = callsign.upper()
response = self._request_callsign_... | python | def _lookup_qrz_callsign(self, callsign=None, apikey=None, apiv="1.3.3"):
""" Performs the callsign lookup against the QRZ.com XML API:
"""
if apikey is None:
raise AttributeError("Session Key Missing")
callsign = callsign.upper()
response = self._request_callsign_... | [
"def",
"_lookup_qrz_callsign",
"(",
"self",
",",
"callsign",
"=",
"None",
",",
"apikey",
"=",
"None",
",",
"apiv",
"=",
"\"1.3.3\"",
")",
":",
"if",
"apikey",
"is",
"None",
":",
"raise",
"AttributeError",
"(",
"\"Session Key Missing\"",
")",
"callsign",
"=",... | Performs the callsign lookup against the QRZ.com XML API: | [
"Performs",
"the",
"callsign",
"lookup",
"against",
"the",
"QRZ",
".",
"com",
"XML",
"API",
":"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L793-L958 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._load_clublogXML | def _load_clublogXML(self,
url="https://secure.clublog.org/cty.php",
apikey=None,
cty_file=None):
""" Load and process the ClublogXML file either as a download or from file
"""
if self._download:
cty_file = self... | python | def _load_clublogXML(self,
url="https://secure.clublog.org/cty.php",
apikey=None,
cty_file=None):
""" Load and process the ClublogXML file either as a download or from file
"""
if self._download:
cty_file = self... | [
"def",
"_load_clublogXML",
"(",
"self",
",",
"url",
"=",
"\"https://secure.clublog.org/cty.php\"",
",",
"apikey",
"=",
"None",
",",
"cty_file",
"=",
"None",
")",
":",
"if",
"self",
".",
"_download",
":",
"cty_file",
"=",
"self",
".",
"_download_file",
"(",
"... | Load and process the ClublogXML file either as a download or from file | [
"Load",
"and",
"process",
"the",
"ClublogXML",
"file",
"either",
"as",
"a",
"download",
"or",
"from",
"file"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L960-L989 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._load_countryfile | def _load_countryfile(self,
url="https://www.country-files.com/cty/cty.plist",
country_mapping_filename="countryfilemapping.json",
cty_file=None):
""" Load and process the ClublogXML file either as a download or from file
"""
... | python | def _load_countryfile(self,
url="https://www.country-files.com/cty/cty.plist",
country_mapping_filename="countryfilemapping.json",
cty_file=None):
""" Load and process the ClublogXML file either as a download or from file
"""
... | [
"def",
"_load_countryfile",
"(",
"self",
",",
"url",
"=",
"\"https://www.country-files.com/cty/cty.plist\"",
",",
"country_mapping_filename",
"=",
"\"countryfilemapping.json\"",
",",
"cty_file",
"=",
"None",
")",
":",
"cwdFile",
"=",
"os",
".",
"path",
".",
"abspath",... | Load and process the ClublogXML file either as a download or from file | [
"Load",
"and",
"process",
"the",
"ClublogXML",
"file",
"either",
"as",
"a",
"download",
"or",
"from",
"file"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L991-L1023 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._download_file | def _download_file(self, url, apikey=None):
""" Download lookup files either from Clublog or Country-files.com
"""
import gzip
import tempfile
cty = {}
cty_date = ""
cty_file_path = None
filename = None
# download file
if apikey: # clubl... | python | def _download_file(self, url, apikey=None):
""" Download lookup files either from Clublog or Country-files.com
"""
import gzip
import tempfile
cty = {}
cty_date = ""
cty_file_path = None
filename = None
# download file
if apikey: # clubl... | [
"def",
"_download_file",
"(",
"self",
",",
"url",
",",
"apikey",
"=",
"None",
")",
":",
"import",
"gzip",
"import",
"tempfile",
"cty",
"=",
"{",
"}",
"cty_date",
"=",
"\"\"",
"cty_file_path",
"=",
"None",
"filename",
"=",
"None",
"# download file",
"if",
... | Download lookup files either from Clublog or Country-files.com | [
"Download",
"lookup",
"files",
"either",
"from",
"Clublog",
"or",
"Country",
"-",
"files",
".",
"com"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1025-L1082 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._extract_clublog_header | def _extract_clublog_header(self, cty_xml_filename):
"""
Extract the header of the Clublog XML File
"""
cty_header = {}
try:
with open(cty_xml_filename, "r") as cty:
raw_header = cty.readline()
cty_date = re.search("date='.+'", raw_heade... | python | def _extract_clublog_header(self, cty_xml_filename):
"""
Extract the header of the Clublog XML File
"""
cty_header = {}
try:
with open(cty_xml_filename, "r") as cty:
raw_header = cty.readline()
cty_date = re.search("date='.+'", raw_heade... | [
"def",
"_extract_clublog_header",
"(",
"self",
",",
"cty_xml_filename",
")",
":",
"cty_header",
"=",
"{",
"}",
"try",
":",
"with",
"open",
"(",
"cty_xml_filename",
",",
"\"r\"",
")",
"as",
"cty",
":",
"raw_header",
"=",
"cty",
".",
"readline",
"(",
")",
... | Extract the header of the Clublog XML File | [
"Extract",
"the",
"header",
"of",
"the",
"Clublog",
"XML",
"File"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1084-L1119 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._remove_clublog_xml_header | def _remove_clublog_xml_header(self, cty_xml_filename):
"""
remove the header of the Clublog XML File to make it
properly parseable for the python ElementTree XML parser
"""
import tempfile
try:
with open(cty_xml_filename, "r") as f:
c... | python | def _remove_clublog_xml_header(self, cty_xml_filename):
"""
remove the header of the Clublog XML File to make it
properly parseable for the python ElementTree XML parser
"""
import tempfile
try:
with open(cty_xml_filename, "r") as f:
c... | [
"def",
"_remove_clublog_xml_header",
"(",
"self",
",",
"cty_xml_filename",
")",
":",
"import",
"tempfile",
"try",
":",
"with",
"open",
"(",
"cty_xml_filename",
",",
"\"r\"",
")",
"as",
"f",
":",
"content",
"=",
"f",
".",
"readlines",
"(",
")",
"cty_dir",
"... | remove the header of the Clublog XML File to make it
properly parseable for the python ElementTree XML parser | [
"remove",
"the",
"header",
"of",
"the",
"Clublog",
"XML",
"File",
"to",
"make",
"it",
"properly",
"parseable",
"for",
"the",
"python",
"ElementTree",
"XML",
"parser"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1122-L1147 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._parse_clublog_xml | def _parse_clublog_xml(self, cty_xml_filename):
"""
parse the content of a clublog XML file and return the
parsed values in dictionaries
"""
entities = {}
call_exceptions = {}
prefixes = {}
invalid_operations = {}
zone_exceptions = {}
ca... | python | def _parse_clublog_xml(self, cty_xml_filename):
"""
parse the content of a clublog XML file and return the
parsed values in dictionaries
"""
entities = {}
call_exceptions = {}
prefixes = {}
invalid_operations = {}
zone_exceptions = {}
ca... | [
"def",
"_parse_clublog_xml",
"(",
"self",
",",
"cty_xml_filename",
")",
":",
"entities",
"=",
"{",
"}",
"call_exceptions",
"=",
"{",
"}",
"prefixes",
"=",
"{",
"}",
"invalid_operations",
"=",
"{",
"}",
"zone_exceptions",
"=",
"{",
"}",
"call_exceptions_index",... | parse the content of a clublog XML file and return the
parsed values in dictionaries | [
"parse",
"the",
"content",
"of",
"a",
"clublog",
"XML",
"file",
"and",
"return",
"the",
"parsed",
"values",
"in",
"dictionaries"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1149-L1364 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._parse_country_file | def _parse_country_file(self, cty_file, country_mapping_filename=None):
"""
Parse the content of a PLIST file from country-files.com return the
parsed values in dictionaries.
Country-files.com provides Prefixes and Exceptions
"""
import plistlib
cty_list = None... | python | def _parse_country_file(self, cty_file, country_mapping_filename=None):
"""
Parse the content of a PLIST file from country-files.com return the
parsed values in dictionaries.
Country-files.com provides Prefixes and Exceptions
"""
import plistlib
cty_list = None... | [
"def",
"_parse_country_file",
"(",
"self",
",",
"cty_file",
",",
"country_mapping_filename",
"=",
"None",
")",
":",
"import",
"plistlib",
"cty_list",
"=",
"None",
"entities",
"=",
"{",
"}",
"exceptions",
"=",
"{",
"}",
"prefixes",
"=",
"{",
"}",
"exceptions_... | Parse the content of a PLIST file from country-files.com return the
parsed values in dictionaries.
Country-files.com provides Prefixes and Exceptions | [
"Parse",
"the",
"content",
"of",
"a",
"PLIST",
"file",
"from",
"country",
"-",
"files",
".",
"com",
"return",
"the",
"parsed",
"values",
"in",
"dictionaries",
".",
"Country",
"-",
"files",
".",
"com",
"provides",
"Prefixes",
"and",
"Exceptions"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1366-L1433 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._generate_random_word | def _generate_random_word(self, length):
"""
Generates a random word
"""
return ''.join(random.choice(string.ascii_lowercase) for _ in range(length)) | python | def _generate_random_word(self, length):
"""
Generates a random word
"""
return ''.join(random.choice(string.ascii_lowercase) for _ in range(length)) | [
"def",
"_generate_random_word",
"(",
"self",
",",
"length",
")",
":",
"return",
"''",
".",
"join",
"(",
"random",
".",
"choice",
"(",
"string",
".",
"ascii_lowercase",
")",
"for",
"_",
"in",
"range",
"(",
"length",
")",
")"
] | Generates a random word | [
"Generates",
"a",
"random",
"word"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1435-L1439 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._check_html_response | def _check_html_response(self, response):
"""
Checks if the API Key is valid and if the request returned a 200 status (ok)
"""
error1 = "Access to this form requires a valid API key. For more info see: http://www.clublog.org/need_api.php"
error2 = "Invalid or missing API Key... | python | def _check_html_response(self, response):
"""
Checks if the API Key is valid and if the request returned a 200 status (ok)
"""
error1 = "Access to this form requires a valid API key. For more info see: http://www.clublog.org/need_api.php"
error2 = "Invalid or missing API Key... | [
"def",
"_check_html_response",
"(",
"self",
",",
"response",
")",
":",
"error1",
"=",
"\"Access to this form requires a valid API key. For more info see: http://www.clublog.org/need_api.php\"",
"error2",
"=",
"\"Invalid or missing API Key\"",
"if",
"response",
".",
"status_code",
... | Checks if the API Key is valid and if the request returned a 200 status (ok) | [
"Checks",
"if",
"the",
"API",
"Key",
"is",
"valid",
"and",
"if",
"the",
"request",
"returned",
"a",
"200",
"status",
"(",
"ok",
")"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1441-L1457 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._serialize_data | def _serialize_data(self, my_dict):
"""
Serialize a Dictionary into JSON
"""
new_dict = {}
for item in my_dict:
if isinstance(my_dict[item], datetime):
new_dict[item] = my_dict[item].strftime('%Y-%m-%d%H:%M:%S')
else:
new_di... | python | def _serialize_data(self, my_dict):
"""
Serialize a Dictionary into JSON
"""
new_dict = {}
for item in my_dict:
if isinstance(my_dict[item], datetime):
new_dict[item] = my_dict[item].strftime('%Y-%m-%d%H:%M:%S')
else:
new_di... | [
"def",
"_serialize_data",
"(",
"self",
",",
"my_dict",
")",
":",
"new_dict",
"=",
"{",
"}",
"for",
"item",
"in",
"my_dict",
":",
"if",
"isinstance",
"(",
"my_dict",
"[",
"item",
"]",
",",
"datetime",
")",
":",
"new_dict",
"[",
"item",
"]",
"=",
"my_d... | Serialize a Dictionary into JSON | [
"Serialize",
"a",
"Dictionary",
"into",
"JSON"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1460-L1471 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._deserialize_data | def _deserialize_data(self, json_data):
"""
Deserialize a JSON into a dictionary
"""
my_dict = json.loads(json_data.decode('utf8').replace("'", '"'),
encoding='UTF-8')
for item in my_dict:
if item == const.ADIF:
my_dict[item] = int(my_dic... | python | def _deserialize_data(self, json_data):
"""
Deserialize a JSON into a dictionary
"""
my_dict = json.loads(json_data.decode('utf8').replace("'", '"'),
encoding='UTF-8')
for item in my_dict:
if item == const.ADIF:
my_dict[item] = int(my_dic... | [
"def",
"_deserialize_data",
"(",
"self",
",",
"json_data",
")",
":",
"my_dict",
"=",
"json",
".",
"loads",
"(",
"json_data",
".",
"decode",
"(",
"'utf8'",
")",
".",
"replace",
"(",
"\"'\"",
",",
"'\"'",
")",
",",
"encoding",
"=",
"'UTF-8'",
")",
"for",... | Deserialize a JSON into a dictionary | [
"Deserialize",
"a",
"JSON",
"into",
"a",
"dictionary"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1473-L1507 |
AustralianSynchrotron/lightflow | lightflow/models/mongo_proxy.py | get_methods | def get_methods(*objs):
""" Return the names of all callable attributes of an object"""
return set(
attr
for obj in objs
for attr in dir(obj)
if not attr.startswith('_') and callable(getattr(obj, attr))
) | python | def get_methods(*objs):
""" Return the names of all callable attributes of an object"""
return set(
attr
for obj in objs
for attr in dir(obj)
if not attr.startswith('_') and callable(getattr(obj, attr))
) | [
"def",
"get_methods",
"(",
"*",
"objs",
")",
":",
"return",
"set",
"(",
"attr",
"for",
"obj",
"in",
"objs",
"for",
"attr",
"in",
"dir",
"(",
"obj",
")",
"if",
"not",
"attr",
".",
"startswith",
"(",
"'_'",
")",
"and",
"callable",
"(",
"getattr",
"("... | Return the names of all callable attributes of an object | [
"Return",
"the",
"names",
"of",
"all",
"callable",
"attributes",
"of",
"an",
"object"
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/mongo_proxy.py#L18-L25 |
AustralianSynchrotron/lightflow | lightflow/config.py | Config.from_file | def from_file(cls, filename, *, strict=True):
""" Create a new Config object from a configuration file.
Args:
filename (str): The location and name of the configuration file.
strict (bool): If true raises a ConfigLoadError when the configuration
cannot be found.
... | python | def from_file(cls, filename, *, strict=True):
""" Create a new Config object from a configuration file.
Args:
filename (str): The location and name of the configuration file.
strict (bool): If true raises a ConfigLoadError when the configuration
cannot be found.
... | [
"def",
"from_file",
"(",
"cls",
",",
"filename",
",",
"*",
",",
"strict",
"=",
"True",
")",
":",
"config",
"=",
"cls",
"(",
")",
"config",
".",
"load_from_file",
"(",
"filename",
",",
"strict",
"=",
"strict",
")",
"return",
"config"
] | Create a new Config object from a configuration file.
Args:
filename (str): The location and name of the configuration file.
strict (bool): If true raises a ConfigLoadError when the configuration
cannot be found.
Returns:
An instance of the Config cl... | [
"Create",
"a",
"new",
"Config",
"object",
"from",
"a",
"configuration",
"file",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L43-L59 |
AustralianSynchrotron/lightflow | lightflow/config.py | Config.load_from_file | def load_from_file(self, filename=None, *, strict=True):
""" Load the configuration from a file.
The location of the configuration file can either be specified directly in the
parameter filename or is searched for in the following order:
1. In the environment variable given by LIGH... | python | def load_from_file(self, filename=None, *, strict=True):
""" Load the configuration from a file.
The location of the configuration file can either be specified directly in the
parameter filename or is searched for in the following order:
1. In the environment variable given by LIGH... | [
"def",
"load_from_file",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"*",
",",
"strict",
"=",
"True",
")",
":",
"self",
".",
"set_to_default",
"(",
")",
"if",
"filename",
":",
"self",
".",
"_update_from_file",
"(",
"filename",
")",
"else",
":",
"if... | Load the configuration from a file.
The location of the configuration file can either be specified directly in the
parameter filename or is searched for in the following order:
1. In the environment variable given by LIGHTFLOW_CONFIG_ENV
2. In the current execution directory
... | [
"Load",
"the",
"configuration",
"from",
"a",
"file",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L61-L97 |
AustralianSynchrotron/lightflow | lightflow/config.py | Config.load_from_dict | def load_from_dict(self, conf_dict=None):
""" Load the configuration from a dictionary.
Args:
conf_dict (dict): Dictionary with the configuration.
"""
self.set_to_default()
self._update_dict(self._config, conf_dict)
self._update_python_paths() | python | def load_from_dict(self, conf_dict=None):
""" Load the configuration from a dictionary.
Args:
conf_dict (dict): Dictionary with the configuration.
"""
self.set_to_default()
self._update_dict(self._config, conf_dict)
self._update_python_paths() | [
"def",
"load_from_dict",
"(",
"self",
",",
"conf_dict",
"=",
"None",
")",
":",
"self",
".",
"set_to_default",
"(",
")",
"self",
".",
"_update_dict",
"(",
"self",
".",
"_config",
",",
"conf_dict",
")",
"self",
".",
"_update_python_paths",
"(",
")"
] | Load the configuration from a dictionary.
Args:
conf_dict (dict): Dictionary with the configuration. | [
"Load",
"the",
"configuration",
"from",
"a",
"dictionary",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L99-L107 |
AustralianSynchrotron/lightflow | lightflow/config.py | Config._update_from_file | def _update_from_file(self, filename):
""" Helper method to update an existing configuration with the values from a file.
Loads a configuration file and replaces all values in the existing configuration
dictionary with the values from the file.
Args:
filename (str): The pat... | python | def _update_from_file(self, filename):
""" Helper method to update an existing configuration with the values from a file.
Loads a configuration file and replaces all values in the existing configuration
dictionary with the values from the file.
Args:
filename (str): The pat... | [
"def",
"_update_from_file",
"(",
"self",
",",
"filename",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"config_file",
":",
"yaml_dict",
"=",
"yaml",
"... | Helper method to update an existing configuration with the values from a file.
Loads a configuration file and replaces all values in the existing configuration
dictionary with the values from the file.
Args:
filename (str): The path and name to the configuration file. | [
"Helper",
"method",
"to",
"update",
"an",
"existing",
"configuration",
"with",
"the",
"values",
"from",
"a",
"file",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L169-L188 |
AustralianSynchrotron/lightflow | lightflow/config.py | Config._update_dict | def _update_dict(self, to_dict, from_dict):
""" Recursively merges the fields for two dictionaries.
Args:
to_dict (dict): The dictionary onto which the merge is executed.
from_dict (dict): The dictionary merged into to_dict
"""
for key, value in from_dict.items()... | python | def _update_dict(self, to_dict, from_dict):
""" Recursively merges the fields for two dictionaries.
Args:
to_dict (dict): The dictionary onto which the merge is executed.
from_dict (dict): The dictionary merged into to_dict
"""
for key, value in from_dict.items()... | [
"def",
"_update_dict",
"(",
"self",
",",
"to_dict",
",",
"from_dict",
")",
":",
"for",
"key",
",",
"value",
"in",
"from_dict",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"to_dict",
"and",
"isinstance",
"(",
"to_dict",
"[",
"key",
"]",
",",
"dict... | Recursively merges the fields for two dictionaries.
Args:
to_dict (dict): The dictionary onto which the merge is executed.
from_dict (dict): The dictionary merged into to_dict | [
"Recursively",
"merges",
"the",
"fields",
"for",
"two",
"dictionaries",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L190-L202 |
AustralianSynchrotron/lightflow | lightflow/config.py | Config._update_python_paths | def _update_python_paths(self):
""" Append the workflow and libraries paths to the PYTHONPATH. """
for path in self._config['workflows'] + self._config['libraries']:
if os.path.isdir(os.path.abspath(path)):
if path not in sys.path:
sys.path.append(path)
... | python | def _update_python_paths(self):
""" Append the workflow and libraries paths to the PYTHONPATH. """
for path in self._config['workflows'] + self._config['libraries']:
if os.path.isdir(os.path.abspath(path)):
if path not in sys.path:
sys.path.append(path)
... | [
"def",
"_update_python_paths",
"(",
"self",
")",
":",
"for",
"path",
"in",
"self",
".",
"_config",
"[",
"'workflows'",
"]",
"+",
"self",
".",
"_config",
"[",
"'libraries'",
"]",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",... | Append the workflow and libraries paths to the PYTHONPATH. | [
"Append",
"the",
"workflow",
"and",
"libraries",
"paths",
"to",
"the",
"PYTHONPATH",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L204-L212 |
dh1tw/pyhamtools | pyhamtools/dxcluster.py | decode_char_spot | def decode_char_spot(raw_string):
"""Chop Line from DX-Cluster into pieces and return a dict with the spot data"""
data = {}
# Spotter callsign
if re.match('[A-Za-z0-9\/]+[:$]', raw_string[6:15]):
data[const.SPOTTER] = re.sub(':', '', re.match('[A-Za-z0-9\/]+[:$]', raw_string[6:15]).group(0))
... | python | def decode_char_spot(raw_string):
"""Chop Line from DX-Cluster into pieces and return a dict with the spot data"""
data = {}
# Spotter callsign
if re.match('[A-Za-z0-9\/]+[:$]', raw_string[6:15]):
data[const.SPOTTER] = re.sub(':', '', re.match('[A-Za-z0-9\/]+[:$]', raw_string[6:15]).group(0))
... | [
"def",
"decode_char_spot",
"(",
"raw_string",
")",
":",
"data",
"=",
"{",
"}",
"# Spotter callsign",
"if",
"re",
".",
"match",
"(",
"'[A-Za-z0-9\\/]+[:$]'",
",",
"raw_string",
"[",
"6",
":",
"15",
"]",
")",
":",
"data",
"[",
"const",
".",
"SPOTTER",
"]",... | Chop Line from DX-Cluster into pieces and return a dict with the spot data | [
"Chop",
"Line",
"from",
"DX",
"-",
"Cluster",
"into",
"pieces",
"and",
"return",
"a",
"dict",
"with",
"the",
"spot",
"data"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/dxcluster.py#L16-L36 |
dh1tw/pyhamtools | pyhamtools/dxcluster.py | decode_pc11_message | def decode_pc11_message(raw_string):
"""Decode PC11 message, which usually contains DX Spots"""
data = {}
spot = raw_string.split("^")
data[const.FREQUENCY] = float(spot[1])
data[const.DX] = spot[2]
data[const.TIME] = datetime.fromtimestamp(mktime(strptime(spot[3]+" "+spot[4][:-1], "%d-%b-%Y %H... | python | def decode_pc11_message(raw_string):
"""Decode PC11 message, which usually contains DX Spots"""
data = {}
spot = raw_string.split("^")
data[const.FREQUENCY] = float(spot[1])
data[const.DX] = spot[2]
data[const.TIME] = datetime.fromtimestamp(mktime(strptime(spot[3]+" "+spot[4][:-1], "%d-%b-%Y %H... | [
"def",
"decode_pc11_message",
"(",
"raw_string",
")",
":",
"data",
"=",
"{",
"}",
"spot",
"=",
"raw_string",
".",
"split",
"(",
"\"^\"",
")",
"data",
"[",
"const",
".",
"FREQUENCY",
"]",
"=",
"float",
"(",
"spot",
"[",
"1",
"]",
")",
"data",
"[",
"... | Decode PC11 message, which usually contains DX Spots | [
"Decode",
"PC11",
"message",
"which",
"usually",
"contains",
"DX",
"Spots"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/dxcluster.py#L38-L50 |
dh1tw/pyhamtools | pyhamtools/dxcluster.py | decode_pc23_message | def decode_pc23_message(raw_string):
""" Decode PC23 Message which usually contains WCY """
data = {}
wcy = raw_string.split("^")
data[const.R] = int(wcy[1])
data[const.expk] = int(wcy[2])
data[const.CALLSIGN] = wcy[3]
data[const.A] = wcy[4]
data[const.SFI] = wcy[5]
data[const.K] = ... | python | def decode_pc23_message(raw_string):
""" Decode PC23 Message which usually contains WCY """
data = {}
wcy = raw_string.split("^")
data[const.R] = int(wcy[1])
data[const.expk] = int(wcy[2])
data[const.CALLSIGN] = wcy[3]
data[const.A] = wcy[4]
data[const.SFI] = wcy[5]
data[const.K] = ... | [
"def",
"decode_pc23_message",
"(",
"raw_string",
")",
":",
"data",
"=",
"{",
"}",
"wcy",
"=",
"raw_string",
".",
"split",
"(",
"\"^\"",
")",
"data",
"[",
"const",
".",
"R",
"]",
"=",
"int",
"(",
"wcy",
"[",
"1",
"]",
")",
"data",
"[",
"const",
".... | Decode PC23 Message which usually contains WCY | [
"Decode",
"PC23",
"Message",
"which",
"usually",
"contains",
"WCY"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/dxcluster.py#L68-L83 |
AustralianSynchrotron/lightflow | lightflow/models/task.py | BaseTask._run | def _run(self, data, store, signal, context, *,
success_callback=None, stop_callback=None, abort_callback=None):
""" The internal run method that decorates the public run method.
This method makes sure data is being passed to and from the task.
Args:
data (MultiTaskDat... | python | def _run(self, data, store, signal, context, *,
success_callback=None, stop_callback=None, abort_callback=None):
""" The internal run method that decorates the public run method.
This method makes sure data is being passed to and from the task.
Args:
data (MultiTaskDat... | [
"def",
"_run",
"(",
"self",
",",
"data",
",",
"store",
",",
"signal",
",",
"context",
",",
"*",
",",
"success_callback",
"=",
"None",
",",
"stop_callback",
"=",
"None",
",",
"abort_callback",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
":",
"d... | The internal run method that decorates the public run method.
This method makes sure data is being passed to and from the task.
Args:
data (MultiTaskData): The data object that has been passed from the
predecessor task.
store (DataStoreDocument... | [
"The",
"internal",
"run",
"method",
"that",
"decorates",
"the",
"public",
"run",
"method",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task.py#L208-L295 |
dh1tw/pyhamtools | pyhamtools/locator.py | latlong_to_locator | def latlong_to_locator (latitude, longitude):
"""converts WGS84 coordinates into the corresponding Maidenhead Locator
Args:
latitude (float): Latitude
longitude (float): Longitude
Returns:
string: Maidenhead locator
Raises:
ValueError: When ... | python | def latlong_to_locator (latitude, longitude):
"""converts WGS84 coordinates into the corresponding Maidenhead Locator
Args:
latitude (float): Latitude
longitude (float): Longitude
Returns:
string: Maidenhead locator
Raises:
ValueError: When ... | [
"def",
"latlong_to_locator",
"(",
"latitude",
",",
"longitude",
")",
":",
"if",
"longitude",
">=",
"180",
"or",
"longitude",
"<=",
"-",
"180",
":",
"raise",
"ValueError",
"if",
"latitude",
">=",
"90",
"or",
"latitude",
"<=",
"-",
"90",
":",
"raise",
"Val... | converts WGS84 coordinates into the corresponding Maidenhead Locator
Args:
latitude (float): Latitude
longitude (float): Longitude
Returns:
string: Maidenhead locator
Raises:
ValueError: When called with wrong or invalid input args
T... | [
"converts",
"WGS84",
"coordinates",
"into",
"the",
"corresponding",
"Maidenhead",
"Locator"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L10-L55 |
dh1tw/pyhamtools | pyhamtools/locator.py | locator_to_latlong | def locator_to_latlong (locator):
"""converts Maidenhead locator in the corresponding WGS84 coordinates
Args:
locator (string): Locator, either 4 or 6 characters
Returns:
tuple (float, float): Latitude, Longitude
Raises:
ValueError: When called with wro... | python | def locator_to_latlong (locator):
"""converts Maidenhead locator in the corresponding WGS84 coordinates
Args:
locator (string): Locator, either 4 or 6 characters
Returns:
tuple (float, float): Latitude, Longitude
Raises:
ValueError: When called with wro... | [
"def",
"locator_to_latlong",
"(",
"locator",
")",
":",
"locator",
"=",
"locator",
".",
"upper",
"(",
")",
"if",
"len",
"(",
"locator",
")",
"==",
"5",
"or",
"len",
"(",
"locator",
")",
"<",
"4",
":",
"raise",
"ValueError",
"if",
"ord",
"(",
"locator"... | converts Maidenhead locator in the corresponding WGS84 coordinates
Args:
locator (string): Locator, either 4 or 6 characters
Returns:
tuple (float, float): Latitude, Longitude
Raises:
ValueError: When called with wrong or invalid input arg
TypeE... | [
"converts",
"Maidenhead",
"locator",
"in",
"the",
"corresponding",
"WGS84",
"coordinates"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L57-L125 |
dh1tw/pyhamtools | pyhamtools/locator.py | calculate_distance | def calculate_distance(locator1, locator2):
"""calculates the (shortpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in km
... | python | def calculate_distance(locator1, locator2):
"""calculates the (shortpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in km
... | [
"def",
"calculate_distance",
"(",
"locator1",
",",
"locator2",
")",
":",
"R",
"=",
"6371",
"#earh radius",
"lat1",
",",
"long1",
"=",
"locator_to_latlong",
"(",
"locator1",
")",
"lat2",
",",
"long2",
"=",
"locator_to_latlong",
"(",
"locator2",
")",
"d_lat",
... | calculates the (shortpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in km
Raises:
ValueError: When called wi... | [
"calculates",
"the",
"(",
"shortpath",
")",
"distance",
"between",
"two",
"Maidenhead",
"locators"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L128-L167 |
dh1tw/pyhamtools | pyhamtools/locator.py | calculate_distance_longpath | def calculate_distance_longpath(locator1, locator2):
"""calculates the (longpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in... | python | def calculate_distance_longpath(locator1, locator2):
"""calculates the (longpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in... | [
"def",
"calculate_distance_longpath",
"(",
"locator1",
",",
"locator2",
")",
":",
"c",
"=",
"40008",
"#[km] earth circumference",
"sp",
"=",
"calculate_distance",
"(",
"locator1",
",",
"locator2",
")",
"return",
"c",
"-",
"sp"
] | calculates the (longpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in km
Raises:
ValueError: When called wit... | [
"calculates",
"the",
"(",
"longpath",
")",
"distance",
"between",
"two",
"Maidenhead",
"locators"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L170-L196 |
dh1tw/pyhamtools | pyhamtools/locator.py | calculate_heading | def calculate_heading(locator1, locator2):
"""calculates the heading from the first to the second locator
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Heading in deg
Rais... | python | def calculate_heading(locator1, locator2):
"""calculates the heading from the first to the second locator
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Heading in deg
Rais... | [
"def",
"calculate_heading",
"(",
"locator1",
",",
"locator2",
")",
":",
"lat1",
",",
"long1",
"=",
"locator_to_latlong",
"(",
"locator1",
")",
"lat2",
",",
"long2",
"=",
"locator_to_latlong",
"(",
"locator2",
")",
"r_lat1",
"=",
"radians",
"(",
"lat1",
")",
... | calculates the heading from the first to the second locator
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Heading in deg
Raises:
ValueError: When called with wrong... | [
"calculates",
"the",
"heading",
"from",
"the",
"first",
"to",
"the",
"second",
"locator"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L199-L237 |
dh1tw/pyhamtools | pyhamtools/locator.py | calculate_heading_longpath | def calculate_heading_longpath(locator1, locator2):
"""calculates the heading from the first to the second locator (long path)
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Long pa... | python | def calculate_heading_longpath(locator1, locator2):
"""calculates the heading from the first to the second locator (long path)
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Long pa... | [
"def",
"calculate_heading_longpath",
"(",
"locator1",
",",
"locator2",
")",
":",
"heading",
"=",
"calculate_heading",
"(",
"locator1",
",",
"locator2",
")",
"lp",
"=",
"(",
"heading",
"+",
"180",
")",
"%",
"360",
"return",
"lp"
] | calculates the heading from the first to the second locator (long path)
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Long path heading in deg
Raises:
ValueError: ... | [
"calculates",
"the",
"heading",
"from",
"the",
"first",
"to",
"the",
"second",
"locator",
"(",
"long",
"path",
")"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L239-L266 |
dh1tw/pyhamtools | pyhamtools/locator.py | calculate_sunrise_sunset | def calculate_sunrise_sunset(locator, calc_date=datetime.utcnow()):
"""calculates the next sunset and sunrise for a Maidenhead locator at a give date & time
Args:
locator1 (string): Maidenhead Locator, either 4 or 6 characters
calc_date (datetime, optional): Starting datetime for th... | python | def calculate_sunrise_sunset(locator, calc_date=datetime.utcnow()):
"""calculates the next sunset and sunrise for a Maidenhead locator at a give date & time
Args:
locator1 (string): Maidenhead Locator, either 4 or 6 characters
calc_date (datetime, optional): Starting datetime for th... | [
"def",
"calculate_sunrise_sunset",
"(",
"locator",
",",
"calc_date",
"=",
"datetime",
".",
"utcnow",
"(",
")",
")",
":",
"morning_dawn",
"=",
"None",
"sunrise",
"=",
"None",
"evening_dawn",
"=",
"None",
"sunset",
"=",
"None",
"latitude",
",",
"longitude",
"=... | calculates the next sunset and sunrise for a Maidenhead locator at a give date & time
Args:
locator1 (string): Maidenhead Locator, either 4 or 6 characters
calc_date (datetime, optional): Starting datetime for the calculations (UTC)
Returns:
dict: Containing datetim... | [
"calculates",
"the",
"next",
"sunset",
"and",
"sunrise",
"for",
"a",
"Maidenhead",
"locator",
"at",
"a",
"give",
"date",
"&",
"time"
] | train | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L268-L358 |
AustralianSynchrotron/lightflow | lightflow/queue/pickle.py | cloudpickle_dumps | def cloudpickle_dumps(obj, dumper=cloudpickle.dumps):
""" Encode Python objects into a byte stream using cloudpickle. """
return dumper(obj, protocol=serialization.pickle_protocol) | python | def cloudpickle_dumps(obj, dumper=cloudpickle.dumps):
""" Encode Python objects into a byte stream using cloudpickle. """
return dumper(obj, protocol=serialization.pickle_protocol) | [
"def",
"cloudpickle_dumps",
"(",
"obj",
",",
"dumper",
"=",
"cloudpickle",
".",
"dumps",
")",
":",
"return",
"dumper",
"(",
"obj",
",",
"protocol",
"=",
"serialization",
".",
"pickle_protocol",
")"
] | Encode Python objects into a byte stream using cloudpickle. | [
"Encode",
"Python",
"objects",
"into",
"a",
"byte",
"stream",
"using",
"cloudpickle",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/pickle.py#L18-L20 |
AustralianSynchrotron/lightflow | lightflow/queue/pickle.py | patch_celery | def patch_celery():
""" Monkey patch Celery to use cloudpickle instead of pickle. """
registry = serialization.registry
serialization.pickle = cloudpickle
registry.unregister('pickle')
registry.register('pickle', cloudpickle_dumps, cloudpickle_loads,
content_type='application/x... | python | def patch_celery():
""" Monkey patch Celery to use cloudpickle instead of pickle. """
registry = serialization.registry
serialization.pickle = cloudpickle
registry.unregister('pickle')
registry.register('pickle', cloudpickle_dumps, cloudpickle_loads,
content_type='application/x... | [
"def",
"patch_celery",
"(",
")",
":",
"registry",
"=",
"serialization",
".",
"registry",
"serialization",
".",
"pickle",
"=",
"cloudpickle",
"registry",
".",
"unregister",
"(",
"'pickle'",
")",
"registry",
".",
"register",
"(",
"'pickle'",
",",
"cloudpickle_dump... | Monkey patch Celery to use cloudpickle instead of pickle. | [
"Monkey",
"patch",
"Celery",
"to",
"use",
"cloudpickle",
"instead",
"of",
"pickle",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/pickle.py#L23-L40 |
AustralianSynchrotron/lightflow | lightflow/models/signal.py | SignalConnection.connect | def connect(self):
""" Connects to the redis database. """
self._connection = StrictRedis(
host=self._host,
port=self._port,
db=self._database,
password=self._password) | python | def connect(self):
""" Connects to the redis database. """
self._connection = StrictRedis(
host=self._host,
port=self._port,
db=self._database,
password=self._password) | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"_connection",
"=",
"StrictRedis",
"(",
"host",
"=",
"self",
".",
"_host",
",",
"port",
"=",
"self",
".",
"_port",
",",
"db",
"=",
"self",
".",
"_database",
",",
"password",
"=",
"self",
".",
"_... | Connects to the redis database. | [
"Connects",
"to",
"the",
"redis",
"database",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L47-L53 |
AustralianSynchrotron/lightflow | lightflow/models/signal.py | Server.receive | def receive(self):
""" Returns a single request.
Takes the first request from the list of requests and returns it. If the list
is empty, None is returned.
Returns:
Response: If a new request is available a Request object is returned,
otherwise None is ... | python | def receive(self):
""" Returns a single request.
Takes the first request from the list of requests and returns it. If the list
is empty, None is returned.
Returns:
Response: If a new request is available a Request object is returned,
otherwise None is ... | [
"def",
"receive",
"(",
"self",
")",
":",
"pickled_request",
"=",
"self",
".",
"_connection",
".",
"connection",
".",
"lpop",
"(",
"self",
".",
"_request_key",
")",
"return",
"pickle",
".",
"loads",
"(",
"pickled_request",
")",
"if",
"pickled_request",
"is",
... | Returns a single request.
Takes the first request from the list of requests and returns it. If the list
is empty, None is returned.
Returns:
Response: If a new request is available a Request object is returned,
otherwise None is returned. | [
"Returns",
"a",
"single",
"request",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L118-L129 |
AustralianSynchrotron/lightflow | lightflow/models/signal.py | Server.send | def send(self, response):
""" Send a response back to the client that issued a request.
Args:
response (Response): Reference to the response object that should be sent.
"""
self._connection.connection.set('{}:{}'.format(SIGNAL_REDIS_PREFIX, response.uid),
... | python | def send(self, response):
""" Send a response back to the client that issued a request.
Args:
response (Response): Reference to the response object that should be sent.
"""
self._connection.connection.set('{}:{}'.format(SIGNAL_REDIS_PREFIX, response.uid),
... | [
"def",
"send",
"(",
"self",
",",
"response",
")",
":",
"self",
".",
"_connection",
".",
"connection",
".",
"set",
"(",
"'{}:{}'",
".",
"format",
"(",
"SIGNAL_REDIS_PREFIX",
",",
"response",
".",
"uid",
")",
",",
"pickle",
".",
"dumps",
"(",
"response",
... | Send a response back to the client that issued a request.
Args:
response (Response): Reference to the response object that should be sent. | [
"Send",
"a",
"response",
"back",
"to",
"the",
"client",
"that",
"issued",
"a",
"request",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L131-L138 |
AustralianSynchrotron/lightflow | lightflow/models/signal.py | Server.restore | def restore(self, request):
""" Push the request back onto the queue.
Args:
request (Request): Reference to a request object that should be pushed back
onto the request queue.
"""
self._connection.connection.rpush(self._request_key, pickle.dump... | python | def restore(self, request):
""" Push the request back onto the queue.
Args:
request (Request): Reference to a request object that should be pushed back
onto the request queue.
"""
self._connection.connection.rpush(self._request_key, pickle.dump... | [
"def",
"restore",
"(",
"self",
",",
"request",
")",
":",
"self",
".",
"_connection",
".",
"connection",
".",
"rpush",
"(",
"self",
".",
"_request_key",
",",
"pickle",
".",
"dumps",
"(",
"request",
")",
")"
] | Push the request back onto the queue.
Args:
request (Request): Reference to a request object that should be pushed back
onto the request queue. | [
"Push",
"the",
"request",
"back",
"onto",
"the",
"queue",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L140-L147 |
AustralianSynchrotron/lightflow | lightflow/models/signal.py | Client.send | def send(self, request):
""" Send a request to the server and wait for its response.
Args:
request (Request): Reference to a request object that is sent to the server.
Returns:
Response: The response from the server to the request.
"""
self._connection.c... | python | def send(self, request):
""" Send a request to the server and wait for its response.
Args:
request (Request): Reference to a request object that is sent to the server.
Returns:
Response: The response from the server to the request.
"""
self._connection.c... | [
"def",
"send",
"(",
"self",
",",
"request",
")",
":",
"self",
".",
"_connection",
".",
"connection",
".",
"rpush",
"(",
"self",
".",
"_request_key",
",",
"pickle",
".",
"dumps",
"(",
"request",
")",
")",
"resp_key",
"=",
"'{}:{}'",
".",
"format",
"(",
... | Send a request to the server and wait for its response.
Args:
request (Request): Reference to a request object that is sent to the server.
Returns:
Response: The response from the server to the request. | [
"Send",
"a",
"request",
"to",
"the",
"server",
"and",
"wait",
"for",
"its",
"response",
"."
] | train | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L171-L192 |
krzysiekfonal/grammaregex | grammaregex/grammaregex.py | verify_pattern | def verify_pattern(pattern):
"""Verifies if pattern for matching and finding fulfill expected structure.
:param pattern: string pattern to verify
:return: True if pattern has proper syntax, False otherwise
"""
regex = re.compile("^!?[a-zA-Z]+$|[*]{1,2}$")
def __verify_pattern__(__pa... | python | def verify_pattern(pattern):
"""Verifies if pattern for matching and finding fulfill expected structure.
:param pattern: string pattern to verify
:return: True if pattern has proper syntax, False otherwise
"""
regex = re.compile("^!?[a-zA-Z]+$|[*]{1,2}$")
def __verify_pattern__(__pa... | [
"def",
"verify_pattern",
"(",
"pattern",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"\"^!?[a-zA-Z]+$|[*]{1,2}$\"",
")",
"def",
"__verify_pattern__",
"(",
"__pattern__",
")",
":",
"if",
"not",
"__pattern__",
":",
"return",
"False",
"elif",
"__pattern__",
... | Verifies if pattern for matching and finding fulfill expected structure.
:param pattern: string pattern to verify
:return: True if pattern has proper syntax, False otherwise | [
"Verifies",
"if",
"pattern",
"for",
"matching",
"and",
"finding",
"fulfill",
"expected",
"structure",
"."
] | train | https://github.com/krzysiekfonal/grammaregex/blob/5212075433fc5201da628acf09cdf5bf73aa1ad0/grammaregex/grammaregex.py#L40-L60 |
krzysiekfonal/grammaregex | grammaregex/grammaregex.py | print_tree | def print_tree(sent, token_attr):
"""Prints sentences tree as string using token_attr from token(like pos_, tag_ etc.)
:param sent: sentence to print
:param token_attr: choosen attr to present for tokens(e.g. dep_, pos_, tag_, ...)
"""
def __print_sent__(token, attr):
print("{", en... | python | def print_tree(sent, token_attr):
"""Prints sentences tree as string using token_attr from token(like pos_, tag_ etc.)
:param sent: sentence to print
:param token_attr: choosen attr to present for tokens(e.g. dep_, pos_, tag_, ...)
"""
def __print_sent__(token, attr):
print("{", en... | [
"def",
"print_tree",
"(",
"sent",
",",
"token_attr",
")",
":",
"def",
"__print_sent__",
"(",
"token",
",",
"attr",
")",
":",
"print",
"(",
"\"{\"",
",",
"end",
"=",
"\" \"",
")",
"[",
"__print_sent__",
"(",
"t",
",",
"attr",
")",
"for",
"t",
"in",
... | Prints sentences tree as string using token_attr from token(like pos_, tag_ etc.)
:param sent: sentence to print
:param token_attr: choosen attr to present for tokens(e.g. dep_, pos_, tag_, ...) | [
"Prints",
"sentences",
"tree",
"as",
"string",
"using",
"token_attr",
"from",
"token",
"(",
"like",
"pos_",
"tag_",
"etc",
".",
")"
] | train | https://github.com/krzysiekfonal/grammaregex/blob/5212075433fc5201da628acf09cdf5bf73aa1ad0/grammaregex/grammaregex.py#L63-L76 |
krzysiekfonal/grammaregex | grammaregex/grammaregex.py | match_tree | def match_tree(sentence, pattern):
"""Matches given sentence with provided pattern.
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which sentence will be compared
:return: True if sentence match to... | python | def match_tree(sentence, pattern):
"""Matches given sentence with provided pattern.
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which sentence will be compared
:return: True if sentence match to... | [
"def",
"match_tree",
"(",
"sentence",
",",
"pattern",
")",
":",
"if",
"not",
"verify_pattern",
"(",
"pattern",
")",
":",
"raise",
"PatternSyntaxException",
"(",
"pattern",
")",
"def",
"_match_node",
"(",
"t",
",",
"p",
")",
":",
"pat_node",
"=",
"p",
"."... | Matches given sentence with provided pattern.
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which sentence will be compared
:return: True if sentence match to pattern, False otherwise
:raises... | [
"Matches",
"given",
"sentence",
"with",
"provided",
"pattern",
"."
] | train | https://github.com/krzysiekfonal/grammaregex/blob/5212075433fc5201da628acf09cdf5bf73aa1ad0/grammaregex/grammaregex.py#L79-L111 |
krzysiekfonal/grammaregex | grammaregex/grammaregex.py | find_tokens | def find_tokens(sentence, pattern):
"""Find all tokens from parts of sentence fitted to pattern, being on the end of matched sub-tree(of sentence)
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which senten... | python | def find_tokens(sentence, pattern):
"""Find all tokens from parts of sentence fitted to pattern, being on the end of matched sub-tree(of sentence)
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which senten... | [
"def",
"find_tokens",
"(",
"sentence",
",",
"pattern",
")",
":",
"if",
"not",
"verify_pattern",
"(",
"pattern",
")",
":",
"raise",
"PatternSyntaxException",
"(",
"pattern",
")",
"def",
"_match_node",
"(",
"t",
",",
"p",
",",
"tokens",
")",
":",
"pat_node",... | Find all tokens from parts of sentence fitted to pattern, being on the end of matched sub-tree(of sentence)
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which sentence will be compared
:return: Spacy... | [
"Find",
"all",
"tokens",
"from",
"parts",
"of",
"sentence",
"fitted",
"to",
"pattern",
"being",
"on",
"the",
"end",
"of",
"matched",
"sub",
"-",
"tree",
"(",
"of",
"sentence",
")"
] | train | https://github.com/krzysiekfonal/grammaregex/blob/5212075433fc5201da628acf09cdf5bf73aa1ad0/grammaregex/grammaregex.py#L114-L146 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.