sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def set_user_project_permission(self, project_id, user_id, auth_role):
"""
Send PUT request to /projects/{project_id}/permissions/{user_id/ with auth_role value.
:param project_id: str uuid of the project
:param user_id: str uuid of the user
:param auth_role: str project role eg ... | Send PUT request to /projects/{project_id}/permissions/{user_id/ with auth_role value.
:param project_id: str uuid of the project
:param user_id: str uuid of the user
:param auth_role: str project role eg 'project_admin'
:return: requests.Response containing the successful result | entailment |
def get_api_token(self, agent_key, user_key):
"""
Send POST request to get an auth token.
This method doesn't require auth obviously.
:param agent_key: str agent key (who is acting on behalf of the user)
:param user_key: str secret user key
:return: requests.Response cont... | Send POST request to get an auth token.
This method doesn't require auth obviously.
:param agent_key: str agent key (who is acting on behalf of the user)
:param user_key: str secret user key
:return: requests.Response containing the successful result | entailment |
def create_project_transfer(self, project_id, to_user_ids):
"""
Send POST request to initiate transfer of a project to the specified user ids
:param project_id: str uuid of the project
:param to_users: list of user uuids to receive the project
:return: requests.Response containin... | Send POST request to initiate transfer of a project to the specified user ids
:param project_id: str uuid of the project
:param to_users: list of user uuids to receive the project
:return: requests.Response containing the successful result | entailment |
def _process_project_transfer(self, action, transfer_id, status_comment):
"""
Send PUT request to one of the project transfer action endpoints
:param action: str name of the action (reject/accept/cancel)
:param transfer_id: str uuid of the project_transfer
:param status_comment: ... | Send PUT request to one of the project transfer action endpoints
:param action: str name of the action (reject/accept/cancel)
:param transfer_id: str uuid of the project_transfer
:param status_comment: str comment about the action, optional
:return: requests.Response containing the succe... | entailment |
def create_activity(self, activity_name, desc=None, started_on=None, ended_on=None):
"""
Send POST to /activities creating a new activity with the specified name and desc.
Raises DataServiceError on error.
:param activity_name: str name of the activity
:param desc: str descriptio... | Send POST to /activities creating a new activity with the specified name and desc.
Raises DataServiceError on error.
:param activity_name: str name of the activity
:param desc: str description of the activity (optional)
:param started_on: str datetime when the activity started (optional)... | entailment |
def update_activity(self, activity_id, activity_name=None, desc=None,
started_on=None, ended_on=None):
"""
Send PUT request to /activities/{activity_id} to update the activity metadata.
Raises ValueError if at least one field is not updated.
:param activity_id: st... | Send PUT request to /activities/{activity_id} to update the activity metadata.
Raises ValueError if at least one field is not updated.
:param activity_id: str uuid of activity
:param activity_name: str new name of the activity (optional)
:param desc: str description of the activity (opti... | entailment |
def create_used_relation(self, activity_id, entity_kind, entity_id):
"""
Create a was used by relationship between an activity and a entity(file).
:param activity_id: str: uuid of the activity
:param entity_kind: str: kind of entity('dds-file')
:param entity_id: str: uuid of the ... | Create a was used by relationship between an activity and a entity(file).
:param activity_id: str: uuid of the activity
:param entity_kind: str: kind of entity('dds-file')
:param entity_id: str: uuid of the entity
:return: requests.Response containing the successful result | entailment |
def create_was_generated_by_relation(self, activity_id, entity_kind, entity_id):
"""
Create a was generated by relationship between an activity and a entity(file).
:param activity_id: str: uuid of the activity
:param entity_kind: str: kind of entity('dds-file')
:param entity_id: ... | Create a was generated by relationship between an activity and a entity(file).
:param activity_id: str: uuid of the activity
:param entity_kind: str: kind of entity('dds-file')
:param entity_id: str: uuid of the entity
:return: requests.Response containing the successful result | entailment |
def create_was_invalidated_by_relation(self, activity_id, entity_kind, entity_id):
"""
Create a was invalidated by relationship between an activity and a entity(file).
:param activity_id: str: uuid of the activity
:param entity_kind: str: kind of entity('dds-file')
:param entity_... | Create a was invalidated by relationship between an activity and a entity(file).
:param activity_id: str: uuid of the activity
:param entity_kind: str: kind of entity('dds-file')
:param entity_id: str: uuid of the entity
:return: requests.Response containing the successful result | entailment |
def create_was_derived_from_relation(self, used_entity_id, used_entity_kind,
generated_entity_id, generated_entity_kind):
"""
Create a was derived from relation.
:param used_entity_id: str: uuid of the used entity (file_version_id)
:param used_ent... | Create a was derived from relation.
:param used_entity_id: str: uuid of the used entity (file_version_id)
:param used_entity_kind: str: kind of entity ('dds-file')
:param generated_entity_id: uuid of the generated entity (file_version_id)
:param generated_entity_kind: str: kind of entity... | entailment |
def get_auth_provider_affiliates(self, auth_provider_id, full_name_contains=None, email=None, username=None):
"""
List affiliates for a specific auth provider.
:param auth_provider_id: str: uuid of the auth provider to list affiliates of
:param full_name_contains: str: filters affiliates... | List affiliates for a specific auth provider.
:param auth_provider_id: str: uuid of the auth provider to list affiliates of
:param full_name_contains: str: filters affiliates for this name
:param email: str: filters affiliates for this email address
:param username: str: filters affiliat... | entailment |
def auth_provider_add_user(self, auth_provider_id, username):
"""
Transform an institutional affiliates UID, such as a Duke NetID, to a DDS specific user identity;
can be used by clients prior to calling DDS APIs that require a DDS user in the request payload.
Returns user details. Can b... | Transform an institutional affiliates UID, such as a Duke NetID, to a DDS specific user identity;
can be used by clients prior to calling DDS APIs that require a DDS user in the request payload.
Returns user details. Can be safely called multiple times.
:param auth_provider_id: str: auth provide... | entailment |
def add_response(self, response):
"""
Add data from json() to data returned by json()
:param response: requests.Response containing the successful JSON result to be merged
"""
key = self.merge_array_field_name
response_json = response.json()
value = self.combined_... | Add data from json() to data returned by json()
:param response: requests.Response containing the successful JSON result to be merged | entailment |
def load(self, filename, format_file='cloudupdrs'):
"""
This is a general load data method where the format of data to load can be passed as a parameter,
:param str filename: The path to load data from
:param str format_file: format of the file. Default is CloudUPDRS. Set to... | This is a general load data method where the format of data to load can be passed as a parameter,
:param str filename: The path to load data from
:param str format_file: format of the file. Default is CloudUPDRS. Set to mpower for mpower data.
:return dataframe: data_frame.x, data_f... | entailment |
def get_method(self, call, *args, **kwargs):
"""Return the L{Method} instance to invoke for the given L{Call}.
@param args: Positional arguments to pass to the method constructor.
@param kwargs: Keyword arguments to pass to the method constructor.
"""
method_class = self.registr... | Return the L{Method} instance to invoke for the given L{Call}.
@param args: Positional arguments to pass to the method constructor.
@param kwargs: Keyword arguments to pass to the method constructor. | entailment |
def handle(self, request):
"""Handle an HTTP request for executing an API call.
This method authenticates the request checking its signature, and then
calls the C{execute} method, passing it a L{Call} object set with the
principal for the authenticated user and the generic parameters
... | Handle an HTTP request for executing an API call.
This method authenticates the request checking its signature, and then
calls the C{execute} method, passing it a L{Call} object set with the
principal for the authenticated user and the generic parameters
extracted from the request.
... | entailment |
def execute(self, call):
"""Execute an API L{Call}.
At this point the request has been authenticated and C{call.principal}
is set with the L{Principal} for the L{User} requesting the call.
@return: The response to write in the request for the given L{Call}.
@raises: An L{APIErr... | Execute an API L{Call}.
At this point the request has been authenticated and C{call.principal}
is set with the L{Principal} for the L{User} requesting the call.
@return: The response to write in the request for the given L{Call}.
@raises: An L{APIError} in case the execution fails, spo... | entailment |
def get_call_arguments(self, request):
"""
Get call arguments from a request. Override this if you want to use a
wire format different from AWS's.
The return value is a dictionary with three keys: 'transport_args',
'handler_args', and 'raw_args'.
The value of 'transport... | Get call arguments from a request. Override this if you want to use a
wire format different from AWS's.
The return value is a dictionary with three keys: 'transport_args',
'handler_args', and 'raw_args'.
The value of 'transport_args' must be a dictionary with the following
keys... | entailment |
def _validate(self, request):
"""Validate an L{HTTPRequest} before executing it.
The following conditions are checked:
- The request contains all the generic parameters.
- The action specified in the request is a supported one.
- The signature mechanism is a supported one.
... | Validate an L{HTTPRequest} before executing it.
The following conditions are checked:
- The request contains all the generic parameters.
- The action specified in the request is a supported one.
- The signature mechanism is a supported one.
- The provided signature matches the ... | entailment |
def _validate_generic_parameters(self, args):
"""Validate the generic request parameters.
@param args: Parsed schema arguments.
@raises APIError: In the following cases:
- Action is not included in C{self.actions}
- SignatureVersion is not included in C{self.signature_ve... | Validate the generic request parameters.
@param args: Parsed schema arguments.
@raises APIError: In the following cases:
- Action is not included in C{self.actions}
- SignatureVersion is not included in C{self.signature_versions}
- Expires and Timestamp are present
... | entailment |
def _validate_signature(self, request, principal, args, params):
"""Validate the signature."""
creds = AWSCredentials(principal.access_key, principal.secret_key)
endpoint = AWSServiceEndpoint()
endpoint.set_method(request.method)
endpoint.set_canonical_host(request.getHeader("Hos... | Validate the signature. | entailment |
def render_GET(self, request):
"""Handle a GET request."""
if not request.args:
request.setHeader("Content-Type", "text/plain")
return self.get_status_text()
else:
self.handle(request)
return NOT_DONE_YET | Handle a GET request. | entailment |
def get_exitcode_reactor():
"""
This is only neccesary until a fix like the one outlined here is
implemented for Twisted:
http://twistedmatrix.com/trac/ticket/2182
"""
from twisted.internet.main import installReactor
from twisted.internet.selectreactor import SelectReactor
class Exi... | This is only neccesary until a fix like the one outlined here is
implemented for Twisted:
http://twistedmatrix.com/trac/ticket/2182 | entailment |
def getSignatureKey(key, dateStamp, regionName, serviceName):
"""
Generate the signing key for AWS V4 requests.
@param key: The secret key to use.
@type key: L{bytes}
@param dateStamp: The UTC date and time, serialized as an AWS date
stamp.
@type dateStamp: L{bytes}
@param regionN... | Generate the signing key for AWS V4 requests.
@param key: The secret key to use.
@type key: L{bytes}
@param dateStamp: The UTC date and time, serialized as an AWS date
stamp.
@type dateStamp: L{bytes}
@param regionName: The name of the region.
@type regionName: L{bytes}
@param se... | entailment |
def _make_canonical_uri(parsed):
"""
Return the canonical URI for a parsed URL.
@param parsed: The parsed URL from which to extract the canonical
URI
@type parsed: L{urlparse.ParseResult}
@return: The canonical URI.
@rtype: L{str}
"""
path = urllib.quote(parsed.path)
canoni... | Return the canonical URI for a parsed URL.
@param parsed: The parsed URL from which to extract the canonical
URI
@type parsed: L{urlparse.ParseResult}
@return: The canonical URI.
@rtype: L{str} | entailment |
def _make_canonical_query_string(parsed):
"""
Return the canonical query string for a parsed URL.
@param parsed: The parsed URL from which to extract the canonical
query string.
@type parsed: L{urlparse.ParseResult}
@return: The canonical query string.
@rtype: L{str}
"""
query_... | Return the canonical query string for a parsed URL.
@param parsed: The parsed URL from which to extract the canonical
query string.
@type parsed: L{urlparse.ParseResult}
@return: The canonical query string.
@rtype: L{str} | entailment |
def _make_canonical_headers(headers, headers_to_sign):
"""
Return canonicalized headers.
@param headers: The request headers.
@type headers: L{dict}
@param headers_to_sign: A sequence of header names that should be
signed.
@type headers_to_sign: A sequence of L{bytes}
@return: The... | Return canonicalized headers.
@param headers: The request headers.
@type headers: L{dict}
@param headers_to_sign: A sequence of header names that should be
signed.
@type headers_to_sign: A sequence of L{bytes}
@return: The canonicalized headers.
@rtype: L{bytes} | entailment |
def _make_signed_headers(headers, headers_to_sign):
"""
Return a semicolon-delimited list of headers to sign.
@param headers: The request headers.
@type headers: L{dict}
@param headers_to_sign: A sequence of header names that should be
signed.
@type headers_to_sign: L{bytes}
@retu... | Return a semicolon-delimited list of headers to sign.
@param headers: The request headers.
@type headers: L{dict}
@param headers_to_sign: A sequence of header names that should be
signed.
@type headers_to_sign: L{bytes}
@return: The semicolon-delimited list of headers.
@rtype: L{bytes... | entailment |
def _make_authorization_header(region,
service,
canonical_request,
credentials,
instant):
"""
Construct an AWS version 4 authorization value for use in an
C{Authorization} header.
... | Construct an AWS version 4 authorization value for use in an
C{Authorization} header.
@param region: The AWS region name (e.g., C{'us-east-1'}).
@type region: L{str}
@param service: The AWS service's name (e.g., C{'s3'}).
@type service: L{str}
@param canonical_request: The canonical form of t... | entailment |
def linear_interpolation(first, last, steps):
"""Interpolates all missing values using linear interpolation.
:param numeric first: Start value for the interpolation.
:param numeric last: End Value for the interpolation
:param integer steps: Number of missing values that have to be calculated.
... | Interpolates all missing values using linear interpolation.
:param numeric first: Start value for the interpolation.
:param numeric last: End Value for the interpolation
:param integer steps: Number of missing values that have to be calculated.
:return: Returns a list of floats containing ... | entailment |
def upload_project_run(upload_context):
"""
Function run by CreateProjectCommand to create the project.
Runs in a background process.
:param upload_context: UploadContext: contains data service setup and project name to create.
"""
data_service = upload_context.make_data_service()
project_na... | Function run by CreateProjectCommand to create the project.
Runs in a background process.
:param upload_context: UploadContext: contains data service setup and project name to create. | entailment |
def upload_folder_run(upload_context):
"""
Function run by CreateFolderCommand to create the folder.
Runs in a background process.
:param upload_context: UploadContext: contains data service setup and folder details.
"""
data_service = upload_context.make_data_service()
folder_name, parent_k... | Function run by CreateFolderCommand to create the folder.
Runs in a background process.
:param upload_context: UploadContext: contains data service setup and folder details. | entailment |
def create_small_file(upload_context):
"""
Function run by CreateSmallFileCommand to create the file.
Runs in a background process.
:param upload_context: UploadContext: contains data service setup and file details.
:return dict: DukeDS file data
"""
data_service = upload_context.make_data_s... | Function run by CreateSmallFileCommand to create the file.
Runs in a background process.
:param upload_context: UploadContext: contains data service setup and file details.
:return dict: DukeDS file data | entailment |
def rebuild_data_service(config, data_service_auth_data):
"""
Deserialize value into DataServiceApi object.
:param config:
:param data_service_auth_data:
:return:
"""
auth = DataServiceAuth(config)
auth.set_auth_data(data_service_auth_data)
return ... | Deserialize value into DataServiceApi object.
:param config:
:param data_service_auth_data:
:return: | entailment |
def run(self, local_project):
"""
Upload a project by uploading project, folders, and small files then uploading the large files.
:param local_project: LocalProject: project to upload
"""
# Walk project adding small items to runner saving large items to large_items
Projec... | Upload a project by uploading project, folders, and small files then uploading the large files.
:param local_project: LocalProject: project to upload | entailment |
def visit_file(self, item, parent):
"""
If file is large add it to the large items to be processed after small task list.
else file is small add it to the small task list.
"""
if self.is_large_file(item):
self.large_items.append((item, parent))
else:
... | If file is large add it to the large items to be processed after small task list.
else file is small add it to the small task list. | entailment |
def upload_large_items(self):
"""
Upload files that were too large.
"""
for local_file, parent in self.large_items:
if local_file.need_to_send:
self.process_large_file(local_file, parent) | Upload files that were too large. | entailment |
def process_large_file(self, local_file, parent):
"""
Upload a single file using multiple processes to upload multiple chunks at the same time.
Updates local_file with it's remote_id when done.
:param local_file: LocalFile: file we are uploading
:param parent: LocalFolder/LocalPr... | Upload a single file using multiple processes to upload multiple chunks at the same time.
Updates local_file with it's remote_id when done.
:param local_file: LocalFile: file we are uploading
:param parent: LocalFolder/LocalProject: parent of the file | entailment |
def visit_project(self, item):
"""
Adds create project command to task runner if project doesn't already exist.
"""
if not item.remote_id:
command = CreateProjectCommand(self.settings, item)
self.task_runner_add(None, item, command)
else:
self.... | Adds create project command to task runner if project doesn't already exist. | entailment |
def visit_folder(self, item, parent):
"""
Adds create folder command to task runner if folder doesn't already exist.
"""
if not item.remote_id:
command = CreateFolderCommand(self.settings, item, parent)
self.task_runner_add(parent, item, command) | Adds create folder command to task runner if folder doesn't already exist. | entailment |
def visit_file(self, item, parent):
"""
If file is small add create small file command otherwise raise error.
Large files shouldn't be passed to SmallItemUploadTaskBuilder.
"""
if item.need_to_send:
if item.size > self.settings.config.upload_bytes_per_chunk:
... | If file is small add create small file command otherwise raise error.
Large files shouldn't be passed to SmallItemUploadTaskBuilder. | entailment |
def task_runner_add(self, parent, item, command):
"""
Add command to task runner with parent's task id createing a task id for item/command.
Save this item's id to a lookup.
:param parent: object: parent of item
:param item: object: item we are running command on
:param c... | Add command to task runner with parent's task id createing a task id for item/command.
Save this item's id to a lookup.
:param parent: object: parent of item
:param item: object: item we are running command on
:param command: parallel TaskCommand we want to have run | entailment |
def after_run(self, result_id):
"""
Save uuid associated with project we just created.
:param result_id: str: uuid of the project
"""
self.local_project.set_remote_id_after_send(result_id)
self.settings.project_id = result_id | Save uuid associated with project we just created.
:param result_id: str: uuid of the project | entailment |
def create_context(self, message_queue, task_id):
"""
Create values to be used by upload_folder_run function.
:param message_queue: Queue: queue background process can send messages to us on
:param task_id: int: id of this command's task so message will be routed correctly
"""
... | Create values to be used by upload_folder_run function.
:param message_queue: Queue: queue background process can send messages to us on
:param task_id: int: id of this command's task so message will be routed correctly | entailment |
def create_context(self, message_queue, task_id):
"""
Create values to be used by create_small_file function.
:param message_queue: Queue: queue background process can send messages to us on
:param task_id: int: id of this command's task so message will be routed correctly
"""
... | Create values to be used by create_small_file function.
:param message_queue: Queue: queue background process can send messages to us on
:param task_id: int: id of this command's task so message will be routed correctly | entailment |
def after_run(self, remote_file_data):
"""
Save uuid of file to our LocalFile
:param remote_file_data: dict: DukeDS file data
"""
if self.file_upload_post_processor:
self.file_upload_post_processor.run(self.settings.data_service, remote_file_data)
remote_file_... | Save uuid of file to our LocalFile
:param remote_file_data: dict: DukeDS file data | entailment |
def on_message(self, started_waiting):
"""
Receives started_waiting boolean from create_small_file method and notifies project_status_monitor in settings.
:param started_waiting: boolean: True when we start waiting, False when done
"""
watcher = self.settings.watcher
if s... | Receives started_waiting boolean from create_small_file method and notifies project_status_monitor in settings.
:param started_waiting: boolean: True when we start waiting, False when done | entailment |
def _visit_recur(self, item):
"""
Recursively visits children of item.
:param item: object: project, folder or file we will add to upload_items if necessary.
"""
if item.kind == KindType.file_str:
if item.need_to_send:
self.add_upload_item(item.path)
... | Recursively visits children of item.
:param item: object: project, folder or file we will add to upload_items if necessary. | entailment |
def add_project_name_arg(arg_parser, required, help_text):
"""
Adds project_name parameter to a parser.
:param arg_parser: ArgumentParser parser to add this argument to.
:param help_text: str label displayed in usage
"""
arg_parser.add_argument("-p", '--project-name',
... | Adds project_name parameter to a parser.
:param arg_parser: ArgumentParser parser to add this argument to.
:param help_text: str label displayed in usage | entailment |
def add_project_name_or_id_arg(arg_parser, required=True, help_text_suffix="manage"):
"""
Adds project name or project id argument. These two are mutually exclusive.
:param arg_parser:
:param required:
:param help_text:
:return:
"""
project_name_or_id = arg_parser.add_mutually_exclusive_... | Adds project name or project id argument. These two are mutually exclusive.
:param arg_parser:
:param required:
:param help_text:
:return: | entailment |
def _paths_must_exists(path):
"""
Raises error if path doesn't exist.
:param path: str path to check
:return: str same path passed in
"""
path = to_unicode(path)
if not os.path.exists(path):
raise argparse.ArgumentTypeError("{} is not a valid file/folder.".format(path))
return pa... | Raises error if path doesn't exist.
:param path: str path to check
:return: str same path passed in | entailment |
def _path_has_ok_chars(path):
"""
Validate path for invalid characters.
:param path: str possible filesystem path
:return: path if it was ok otherwise raises error
"""
basename = os.path.basename(path)
if any([bad_char in basename for bad_char in INVALID_PATH_CHARS]):
raise argpa... | Validate path for invalid characters.
:param path: str possible filesystem path
:return: path if it was ok otherwise raises error | entailment |
def _add_auth_role_arg(arg_parser, default_permissions):
"""
Adds optional auth_role parameter to a parser.
:param arg_parser: ArgumentParser parser to add this argument to.
:param default_permissions: default value to use for this argument
"""
help_text = "Specifies which project permissions to... | Adds optional auth_role parameter to a parser.
:param arg_parser: ArgumentParser parser to add this argument to.
:param default_permissions: default value to use for this argument | entailment |
def _add_project_filter_auth_role_arg(arg_parser):
"""
Adds optional auth_role filtering parameter to a parser.
:param arg_parser: ArgumentParser parser to add this argument to.
"""
help_text = "Filters project listing to just those projects with the specified role. "
help_text += "See command l... | Adds optional auth_role filtering parameter to a parser.
:param arg_parser: ArgumentParser parser to add this argument to. | entailment |
def _add_resend_arg(arg_parser, resend_help):
"""
Adds resend parameter to a parser.
:param arg_parser: ArgumentParser parser to add this argument to.
:param type_str
"""
arg_parser.add_argument("--resend",
action='store_true',
default=Fals... | Adds resend parameter to a parser.
:param arg_parser: ArgumentParser parser to add this argument to.
:param type_str | entailment |
def _add_include_arg(arg_parser):
"""
Adds optional repeatable include parameter to a parser.
:param arg_parser: ArgumentParser parser to add this argument to.
"""
arg_parser.add_argument("--include",
metavar='Path',
action='append',
... | Adds optional repeatable include parameter to a parser.
:param arg_parser: ArgumentParser parser to add this argument to. | entailment |
def _add_message_file(arg_parser, help_text):
"""
Add mesage file argument with help_text to arg_parser.
:param arg_parser: ArgumentParser parser to add this argument to.
:param help_text: str: help text for this argument
"""
arg_parser.add_argument('--msg-file',
type... | Add mesage file argument with help_text to arg_parser.
:param arg_parser: ArgumentParser parser to add this argument to.
:param help_text: str: help text for this argument | entailment |
def register_upload_command(self, upload_func):
"""
Add the upload command to the parser and call upload_func(project_name, folders, follow_symlinks) when chosen.
:param upload_func: func Called when this option is chosen: upload_func(project_name, folders, follow_symlinks).
"""
... | Add the upload command to the parser and call upload_func(project_name, folders, follow_symlinks) when chosen.
:param upload_func: func Called when this option is chosen: upload_func(project_name, folders, follow_symlinks). | entailment |
def register_add_user_command(self, add_user_func):
"""
Add the add-user command to the parser and call add_user_func(project_name, user_full_name, auth_role)
when chosen.
:param add_user_func: func Called when this option is chosen: upload_func(project_name, user_full_name, auth_role).
... | Add the add-user command to the parser and call add_user_func(project_name, user_full_name, auth_role)
when chosen.
:param add_user_func: func Called when this option is chosen: upload_func(project_name, user_full_name, auth_role). | entailment |
def register_remove_user_command(self, remove_user_func):
"""
Add the remove-user command to the parser and call remove_user_func(project_name, user_full_name) when chosen.
:param remove_user_func: func Called when this option is chosen: remove_user_func(project_name, user_full_name).
""... | Add the remove-user command to the parser and call remove_user_func(project_name, user_full_name) when chosen.
:param remove_user_func: func Called when this option is chosen: remove_user_func(project_name, user_full_name). | entailment |
def register_download_command(self, download_func):
"""
Add 'download' command for downloading a project to a directory.
For non empty directories it will download remote files replacing local files.
:param download_func: function to run when user choses this option
"""
d... | Add 'download' command for downloading a project to a directory.
For non empty directories it will download remote files replacing local files.
:param download_func: function to run when user choses this option | entailment |
def register_share_command(self, share_func):
"""
Add 'share' command for adding view only project permissions and sending email via another service.
:param share_func: function to run when user choses this option
"""
description = "Share a project with another user with specifie... | Add 'share' command for adding view only project permissions and sending email via another service.
:param share_func: function to run when user choses this option | entailment |
def register_deliver_command(self, deliver_func):
"""
Add 'deliver' command for transferring a project to another user.,
:param deliver_func: function to run when user choses this option
"""
description = "Initiate delivery of a project to another user. Removes other user's curre... | Add 'deliver' command for transferring a project to another user.,
:param deliver_func: function to run when user choses this option | entailment |
def register_list_command(self, list_func):
"""
Add 'list' command to get a list of projects or details about one project.
:param list_func: function: run when user choses this option.
"""
description = "Show a list of project names or folders/files of a single project."
... | Add 'list' command to get a list of projects or details about one project.
:param list_func: function: run when user choses this option. | entailment |
def register_delete_command(self, delete_func):
"""
Add 'delete' command delete a project from the remote store.
:param delete_func: function: run when user choses this option.
"""
description = "Permanently delete a project."
delete_parser = self.subparsers.add_parser('d... | Add 'delete' command delete a project from the remote store.
:param delete_func: function: run when user choses this option. | entailment |
def register_list_auth_roles_command(self, list_auth_roles_func):
"""
Add 'list_auth_roles' command to list project authorization roles that can be used with add_user.
:param list_auth_roles_func: function: run when user choses this option.
"""
description = "List authorization r... | Add 'list_auth_roles' command to list project authorization roles that can be used with add_user.
:param list_auth_roles_func: function: run when user choses this option. | entailment |
def run_command(self, args):
"""
Parse command line arguments and run function registered for the appropriate command.
:param args: [str] command line arguments
"""
parsed_args = self.parser.parse_args(args)
if hasattr(parsed_args, 'func'):
parsed_args.func(pa... | Parse command line arguments and run function registered for the appropriate command.
:param args: [str] command line arguments | entailment |
def resample_signal(self, data_frame):
"""
Convenience method for frequency conversion and resampling of data frame.
Object must have a DatetimeIndex. After re-sampling, this methods interpolate the time magnitude sum
acceleration values and the x,y,z values of the data fra... | Convenience method for frequency conversion and resampling of data frame.
Object must have a DatetimeIndex. After re-sampling, this methods interpolate the time magnitude sum
acceleration values and the x,y,z values of the data frame acceleration
:param data_frame: the data frame ... | entailment |
def filter_signal(self, data_frame, ts='mag_sum_acc'):
"""
This method filters a data frame signal as suggested in :cite:`Kassavetis2015`. First step is to high \
pass filter the data frame using a \
`Butterworth <https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/sc... | This method filters a data frame signal as suggested in :cite:`Kassavetis2015`. First step is to high \
pass filter the data frame using a \
`Butterworth <https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.signal.butter.html>`_ \
digital and analog filter. Then this me... | entailment |
def fft_signal(self, data_frame):
"""
This method perform Fast Fourier Transform on the data frame using a \
`hanning window <https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.signal.hann.html>`_
:param data_frame: the data frame
:type data_frame:... | This method perform Fast Fourier Transform on the data frame using a \
`hanning window <https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.signal.hann.html>`_
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return: data frame with a '... | entailment |
def amplitude_by_fft(self, data_frame):
"""
This methods extract the fft components and sum the ones from lower to upper freq as per \
:cite:`Kassavetis2015`
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return ampl: the ampl
... | This methods extract the fft components and sum the ones from lower to upper freq as per \
:cite:`Kassavetis2015`
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return ampl: the ampl
:rtype ampl: float
:return freq: the freq... | entailment |
def amplitude_by_welch(self, data_frame):
"""
This methods uses the Welch method :cite:`Welch1967` to obtain the power spectral density, this is a robust
alternative to using fft_signal & amplitude
:param data_frame: the data frame
:type data_frame: pandas.DataF... | This methods uses the Welch method :cite:`Welch1967` to obtain the power spectral density, this is a robust
alternative to using fft_signal & amplitude
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return: the ampl
:rtype ampl: float
... | entailment |
def approximate_entropy(self, x, m=None, r=None):
"""
As in tsfresh \
`approximate_entropy <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/feature_extraction/\
feature_calculators.py#L1601>`_
Implements a `vectorized approximate entropy algorithm <https://en.wikipedi... | As in tsfresh \
`approximate_entropy <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/feature_extraction/\
feature_calculators.py#L1601>`_
Implements a `vectorized approximate entropy algorithm <https://en.wikipedia.org/wiki/Approximate_entropy>`_
For short time-series this ... | entailment |
def autocorrelation(self, x, lag):
"""
As in tsfresh `autocorrelation <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/feature_extraction/\
feature_calculators.py#L1457>`_
Calculates the autocorrelation of the specified lag, according to the `formula <https://en.wikipedia.org... | As in tsfresh `autocorrelation <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/feature_extraction/\
feature_calculators.py#L1457>`_
Calculates the autocorrelation of the specified lag, according to the `formula <https://en.wikipedia.org/wiki/\
Autocorrelation#Estimation>`_:
... | entailment |
def partial_autocorrelation(self, x, param=None):
"""
As in tsfresh `partial_autocorrelation <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/\
feature_extraction/feature_calculators.py#L308>`_
Calculates the value of the partial autocorrelation function at the given lag. The... | As in tsfresh `partial_autocorrelation <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/\
feature_extraction/feature_calculators.py#L308>`_
Calculates the value of the partial autocorrelation function at the given lag. The lag `k` partial \
autocorrelation of a time series :math:`\\l... | entailment |
def ratio_value_number_to_time_series_length(self, x):
"""
As in tsfresh `ratio_value_number_to_time_series_length <https://github.com/blue-yonder/tsfresh/blob/master\
/tsfresh/feature_extraction/feature_calculators.py#L830>`_
Returns a factor which is 1 if all values in the... | As in tsfresh `ratio_value_number_to_time_series_length <https://github.com/blue-yonder/tsfresh/blob/master\
/tsfresh/feature_extraction/feature_calculators.py#L830>`_
Returns a factor which is 1 if all values in the time series occur only once,
and below one if this is not the case... | entailment |
def change_quantiles(self, x, ql=None, qh=None, isabs=None, f_agg=None):
"""
As in tsfresh `change_quantiles <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/\
feature_extraction/feature_calculators.py#L1248>`_
First fixes a corridor given by the quantiles ql and ... | As in tsfresh `change_quantiles <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/\
feature_extraction/feature_calculators.py#L1248>`_
First fixes a corridor given by the quantiles ql and qh of the distribution of x. Then calculates the \
average, absolute value of consecu... | entailment |
def number_peaks(self, x, n=None):
"""
As in tsfresh `number_peaks <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/feature_extraction/\
feature_calculators.py#L1003>`_
Calculates the number of peaks of at least support n in the time series x. A peak o... | As in tsfresh `number_peaks <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/feature_extraction/\
feature_calculators.py#L1003>`_
Calculates the number of peaks of at least support n in the time series x. A peak of support n is defined \
as a subsequence of x ... | entailment |
def agg_linear_trend(self, x, param=None):
"""
As in tsfresh `agg_inear_trend <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/\
feature_extraction/feature_calculators.py#L1727>`_
Calculates a linear least-squares regression for values of the time seri... | As in tsfresh `agg_inear_trend <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/\
feature_extraction/feature_calculators.py#L1727>`_
Calculates a linear least-squares regression for values of the time series that were aggregated over chunks\
versus the sequenc... | entailment |
def spkt_welch_density(self, x, param=None):
"""
As in tsfresh `spkt_welch_density <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/\
feature_extraction/feature_calculators.py#L1162>`_ . This feature calculator estimates the cross power \
spectral density of the ti... | As in tsfresh `spkt_welch_density <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/\
feature_extraction/feature_calculators.py#L1162>`_ . This feature calculator estimates the cross power \
spectral density of the time series x at different frequencies. To do so, the time series is fi... | entailment |
def percentage_of_reoccurring_datapoints_to_all_datapoints(self, x):
"""
As in tsfresh `percentage_of_reoccurring_datapoints_to_all_datapoints <https://github.com/blue-yonder/tsfresh/\
blob/master/tsfresh/feature_extraction/feature_calculators.py#L739>`_ \
Returns the percentage of uniq... | As in tsfresh `percentage_of_reoccurring_datapoints_to_all_datapoints <https://github.com/blue-yonder/tsfresh/\
blob/master/tsfresh/feature_extraction/feature_calculators.py#L739>`_ \
Returns the percentage of unique values, that are present in the time series more than once.\
len(different val... | entailment |
def abs_energy(self, x):
"""
As in tsfresh `abs_energy <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/feature_extraction/\
feature_calculators.py#L390>`_ \
Returns the absolute energy of the time series which is the sum over the squared values\
.. math::
... | As in tsfresh `abs_energy <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/feature_extraction/\
feature_calculators.py#L390>`_ \
Returns the absolute energy of the time series which is the sum over the squared values\
.. math::
E=\\sum_{i=1,\ldots, n}x_... | entailment |
def fft_aggregated(self, x, param=None):
"""
As in tsfresh `fft_aggregated <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/feature_extraction/\
feature_calculators.py#L896>`_
Returns the spectral centroid (mean), variance, skew, and kurtosis of the absolute fourier transform... | As in tsfresh `fft_aggregated <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/feature_extraction/\
feature_calculators.py#L896>`_
Returns the spectral centroid (mean), variance, skew, and kurtosis of the absolute fourier transform spectrum.
:param x: the time series to calc... | entailment |
def fft_coefficient(self, x, param=None):
"""
As in tsfresh `fft_coefficient <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/feature_extraction/\
feature_calculators.py#L852>`_ \
Calculates the fourier coefficients of the one-dimensional discrete Fourier Transform for real in... | As in tsfresh `fft_coefficient <https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/feature_extraction/\
feature_calculators.py#L852>`_ \
Calculates the fourier coefficients of the one-dimensional discrete Fourier Transform for real input by fast \
fourier transformation algorithm
... | entailment |
def dc_remove_signal(self, data_frame):
"""
Removes the dc component of the signal as per :cite:`Kassavetis2015`
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return: the data frame with dc remove signal field
:rtype: pandas.Da... | Removes the dc component of the signal as per :cite:`Kassavetis2015`
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return: the data frame with dc remove signal field
:rtype: pandas.DataFrame | entailment |
def bradykinesia(self, data_frame, method='fft'):
"""
This method calculates the bradykinesia amplitude of the data frame. It accepts two different methods, \
'fft' and 'welch'. First the signal gets re-sampled, dc removed and then high pass filtered.
:param data_frame: the ... | This method calculates the bradykinesia amplitude of the data frame. It accepts two different methods, \
'fft' and 'welch'. First the signal gets re-sampled, dc removed and then high pass filtered.
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:par... | entailment |
def extract_features(self, data_frame, pre=''):
"""
This method extracts all the features available to the Tremor Processor class.
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return: amplitude_by_fft, frequency_by_fft, amplitude_by_welch... | This method extracts all the features available to the Tremor Processor class.
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return: amplitude_by_fft, frequency_by_fft, amplitude_by_welch, frequency_by_fft, bradykinesia_amplitude_by_fft, \
... | entailment |
def main(argv, reactor=None):
"""Run the client GUI.
Typical use:
>>> sys.exit(main(sys.argv))
@param argv: The arguments to run it with, e.g. sys.argv.
@param reactor: The reactor to use. Must be compatible with gtk as this
module uses gtk API"s.
@return exitcode: The exit code it ret... | Run the client GUI.
Typical use:
>>> sys.exit(main(sys.argv))
@param argv: The arguments to run it with, e.g. sys.argv.
@param reactor: The reactor to use. Must be compatible with gtk as this
module uses gtk API"s.
@return exitcode: The exit code it returned, as per sys.exit. | entailment |
def parse_options(arguments):
"""Parse command line arguments.
The parsing logic is fairly simple. It can only parse long-style
parameters of the form::
--key value
Several parameters can be defined in the environment and will be used
unless explicitly overridden with command-line argument... | Parse command line arguments.
The parsing logic is fairly simple. It can only parse long-style
parameters of the form::
--key value
Several parameters can be defined in the environment and will be used
unless explicitly overridden with command-line arguments. The access key,
secret and en... | entailment |
def get_command(arguments, output=None):
"""Parse C{arguments} and configure a L{Command} instance.
An access key, secret key, endpoint and action are required. Additional
parameters included with the request are passed as parameters to the
method call. For example, the following command will create ... | Parse C{arguments} and configure a L{Command} instance.
An access key, secret key, endpoint and action are required. Additional
parameters included with the request are passed as parameters to the
method call. For example, the following command will create a L{Command}
object that can invoke the C{De... | entailment |
def main(arguments, output=None, testing_mode=None):
"""
Entry point parses command-line arguments, runs the specified EC2 API
method and prints the response to the screen.
@param arguments: Command-line arguments, typically retrieved from
C{sys.argv}.
@param output: Optionally, a stream to... | Entry point parses command-line arguments, runs the specified EC2 API
method and prints the response to the screen.
@param arguments: Command-line arguments, typically retrieved from
C{sys.argv}.
@param output: Optionally, a stream to write output to.
@param testing_mode: Optionally, a conditio... | entailment |
def execute(self, timeSeries):
"""Creates a new TimeSeries containing the smoothed and forcasted values.
:return: TimeSeries object containing the smoothed TimeSeries,
including the forecasted values.
:rtype: TimeSeries
:note: The first normalized value is chosen a... | Creates a new TimeSeries containing the smoothed and forcasted values.
:return: TimeSeries object containing the smoothed TimeSeries,
including the forecasted values.
:rtype: TimeSeries
:note: The first normalized value is chosen as the starting point. | entailment |
def _get_parameter_intervals(self):
"""Returns the intervals for the methods parameter.
Only parameters with defined intervals can be used for optimization!
:return: Returns a dictionary containing the parameter intervals, using the parameter
name as key, while the value hast th... | Returns the intervals for the methods parameter.
Only parameters with defined intervals can be used for optimization!
:return: Returns a dictionary containing the parameter intervals, using the parameter
name as key, while the value hast the following format:
[minValue, maxV... | entailment |
def execute(self, timeSeries):
"""Creates a new TimeSeries containing the smoothed values.
:return: TimeSeries object containing the smoothed TimeSeries,
including the forecasted values.
:rtype: TimeSeries
:note: The first normalized value is chosen as the starting p... | Creates a new TimeSeries containing the smoothed values.
:return: TimeSeries object containing the smoothed TimeSeries,
including the forecasted values.
:rtype: TimeSeries
:note: The first normalized value is chosen as the starting point. | entailment |
def execute(self, timeSeries):
"""Creates a new TimeSeries containing the smoothed values.
:param TimeSeries timeSeries: TimeSeries containing hte data.
:return: TimeSeries object containing the exponentially smoothed TimeSeries,
including the forecasted values.
:rtype: ... | Creates a new TimeSeries containing the smoothed values.
:param TimeSeries timeSeries: TimeSeries containing hte data.
:return: TimeSeries object containing the exponentially smoothed TimeSeries,
including the forecasted values.
:rtype: TimeSeries
:note: Currently t... | entailment |
def _calculate_forecast(self, originalTimeSeries, smoothedData, seasonValues, lastSmoothingParams):
"""Calculates the actual forecasted based on the input data.
:param TimeSeries timeSeries: TimeSeries containing hte data.
:param list smoothedData: Contains the smoothed time series data.
... | Calculates the actual forecasted based on the input data.
:param TimeSeries timeSeries: TimeSeries containing hte data.
:param list smoothedData: Contains the smoothed time series data.
:param list seasonValues: Contains the seasonal values for the forecast.
:param list lastSmoothingPar... | entailment |
def initSeasonFactors(self, timeSeries):
""" Computes the initial season smoothing factors.
:return: Returns a list of season vectors of length "seasonLength".
:rtype: list
"""
seasonLength = self.get_parameter("seasonLength")
try:
seasonValues = self.get... | Computes the initial season smoothing factors.
:return: Returns a list of season vectors of length "seasonLength".
:rtype: list | entailment |
def initialTrendSmoothingFactors(self, timeSeries):
""" Calculate the initial Trend smoothing Factor b0.
Explanation:
http://en.wikipedia.org/wiki/Exponential_smoothing#Triple_exponential_smoothing
:return: Returns the initial trend smoothing factor b0
"""
result... | Calculate the initial Trend smoothing Factor b0.
Explanation:
http://en.wikipedia.org/wiki/Exponential_smoothing#Triple_exponential_smoothing
:return: Returns the initial trend smoothing factor b0 | entailment |
def computeA(self, j, timeSeries):
""" Calculates A_j. Aj is the average value of x in the jth cycle of your data
:return: A_j
:rtype: numeric
"""
seasonLength = self.get_parameter("seasonLength")
A_j = 0
for i in range(seasonLength):
A_j += ti... | Calculates A_j. Aj is the average value of x in the jth cycle of your data
:return: A_j
:rtype: numeric | entailment |
def _split_quoted(text):
"""
Split a unicode string on *SPACE* characters.
Splitting is not done at *SPACE* characters occurring within matched
*QUOTATION MARK*s. *REVERSE SOLIDUS* can be used to remove all
interpretation from the following character.
:param unicode text: The string to split.... | Split a unicode string on *SPACE* characters.
Splitting is not done at *SPACE* characters occurring within matched
*QUOTATION MARK*s. *REVERSE SOLIDUS* can be used to remove all
interpretation from the following character.
:param unicode text: The string to split.
:return: A two-tuple of unicode... | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.