_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q15100
FakedHbaManager.add
train
def add(self, properties): """ Add a faked HBA resource. Parameters: properties (dict): Resource properties. Special handling and requirements for certain properties: * 'element-id' will be auto-generated with a unique value across ...
python
{ "resource": "" }
q15101
FakedHbaManager.remove
train
def remove(self, oid): """ Remove a faked HBA resource. This method also updates the 'hba-uris' property in the parent Partition resource, by removing the URI for the faked HBA resource. Parameters: oid (string): The object ID of the faked HBA resource. ...
python
{ "resource": "" }
q15102
FakedNicManager.add
train
def add(self, properties): """ Add a faked NIC resource. Parameters: properties (dict): Resource properties. Special handling and requirements for certain properties: * 'element-id' will be auto-generated with a unique value across ...
python
{ "resource": "" }
q15103
FakedNicManager.remove
train
def remove(self, oid): """ Remove a faked NIC resource. This method also updates the 'nic-uris' property in the parent Partition resource, by removing the URI for the faked NIC resource. Parameters: oid (string): The object ID of the faked NIC resource. ...
python
{ "resource": "" }
q15104
FakedPartition.devno_alloc
train
def devno_alloc(self): """ Allocates a device number unique to this partition, in the range of 0x8000 to 0xFFFF. Returns: string: The device number as four hexadecimal digits in upper case. Raises: ValueError: No more device numbers available in that range. ...
python
{ "resource": "" }
q15105
FakedPartition.wwpn_alloc
train
def wwpn_alloc(self): """ Allocates a WWPN unique to this partition, in the range of 0xAFFEAFFE00008000 to 0xAFFEAFFE0000FFFF. Returns: string: The WWPN as 16 hexadecimal digits in upper case. Raises: ValueError: No more WWPNs available in that range. ...
python
{ "resource": "" }
q15106
FakedPortManager.add
train
def add(self, properties): """ Add a faked Port resource. Parameters: properties (dict): Resource properties. Special handling and requirements for certain properties: * 'element-id' will be auto-generated with a unique value across ...
python
{ "resource": "" }
q15107
FakedPortManager.remove
train
def remove(self, oid): """ Remove a faked Port resource. This method also updates the 'network-port-uris' or 'storage-port-uris' property in the parent Adapter resource, by removing the URI for the faked Port resource. Parameters: oid (string): Th...
python
{ "resource": "" }
q15108
FakedVirtualFunctionManager.add
train
def add(self, properties): """ Add a faked Virtual Function resource. Parameters: properties (dict): Resource properties. Special handling and requirements for certain properties: * 'element-id' will be auto-generated with a unique value across ...
python
{ "resource": "" }
q15109
FakedVirtualFunctionManager.remove
train
def remove(self, oid): """ Remove a faked Virtual Function resource. This method also updates the 'virtual-function-uris' property in the parent Partition resource, by removing the URI for the faked Virtual Function resource. Parameters: oid (string): ...
python
{ "resource": "" }
q15110
FakedMetricsContextManager.add_metric_group_definition
train
def add_metric_group_definition(self, definition): """ Add a faked metric group definition. The definition will be used: * For later addition of faked metrics responses. * For returning the metric-group-info objects in the response of the Create Metrics Context operat...
python
{ "resource": "" }
q15111
FakedMetricsContextManager.get_metric_group_definition
train
def get_metric_group_definition(self, group_name): """ Get a faked metric group definition by its group name. Parameters: group_name (:term:`string`): Name of the metric group. Returns: :class:~zhmcclient.FakedMetricGroupDefinition`: Definition of the ...
python
{ "resource": "" }
q15112
FakedMetricsContextManager.add_metric_values
train
def add_metric_values(self, values): """ Add one set of faked metric values for a particular resource to the metrics response for a particular metric group, for later retrieval. For defined metric groups, see chapter "Metric groups" in the :term:`HMC API` book. Paramete...
python
{ "resource": "" }
q15113
FakedMetricsContextManager.get_metric_values
train
def get_metric_values(self, group_name): """ Get the faked metric values for a metric group, by its metric group name. The result includes all metric object values added earlier for that metric group name, using :meth:`~zhmcclient.FakedMetricsContextManager.add_metric_ob...
python
{ "resource": "" }
q15114
FakedMetricsContext.get_metric_group_definitions
train
def get_metric_group_definitions(self): """ Get the faked metric group definitions for this context object that are to be returned from its create operation. If a 'metric-groups' property had been specified for this context, only those faked metric group definitions of its manag...
python
{ "resource": "" }
q15115
FakedMetricsContext.get_metric_group_infos
train
def get_metric_group_infos(self): """ Get the faked metric group definitions for this context object that are to be returned from its create operation, in the format needed for the "Create Metrics Context" operation response. Returns: "metric-group-infos" JSON object ...
python
{ "resource": "" }
q15116
FakedMetricsContext.get_metric_values
train
def get_metric_values(self): """ Get the faked metrics, for all metric groups and all resources that have been prepared on the manager object of this context object. Returns: iterable of tuple (group_name, iterable of values): The faked metrics, in the order they ...
python
{ "resource": "" }
q15117
FakedMetricsContext.get_metric_values_response
train
def get_metric_values_response(self): """ Get the faked metrics, for all metric groups and all resources that have been prepared on the manager object of this context object, as a string in the format needed for the "Get Metrics" operation response. Returns: "MetricsR...
python
{ "resource": "" }
q15118
StorageVolume.update_properties
train
def update_properties(self, properties, email_to_addresses=None, email_cc_addresses=None, email_insert=None): """ Update writeable properties of this storage volume on the HMC, and optionally send emails to storage administrators requesting modification of the s...
python
{ "resource": "" }
q15119
VirtualFunctionManager.list
train
def list(self, full_properties=False, filter_args=None): """ List the Virtual Functions of this Partition. Authorization requirements: * Object-access permission to this Partition. Parameters: full_properties (bool): Controls whether the full set of reso...
python
{ "resource": "" }
q15120
PortManager.list
train
def list(self, full_properties=False, filter_args=None): """ List the Ports of this Adapter. If the adapter does not have any ports, an empty list is returned. Authorization requirements: * Object-access permission to this Adapter. Parameters: full_properti...
python
{ "resource": "" }
q15121
User.add_user_role
train
def add_user_role(self, user_role): """ Add the specified User Role to this User. This User must not be a system-defined or pattern-based user. Authorization requirements: * Task permission to the "Manage Users" task to modify a standard user or the "Manage User Temp...
python
{ "resource": "" }
q15122
User.remove_user_role
train
def remove_user_role(self, user_role): """ Remove the specified User Role from this User. This User must not be a system-defined or pattern-based user. Authorization requirements: * Task permission to the "Manage Users" task to modify a standard user or the "Manage U...
python
{ "resource": "" }
q15123
FakedSession.get
train
def get(self, uri, logon_required=True): """ Perform the HTTP GET method against the resource identified by a URI, on the faked HMC. Parameters: uri (:term:`string`): Relative URI path of the resource, e.g. "/api/session". This URI is relative to the b...
python
{ "resource": "" }
q15124
FakedSession.post
train
def post(self, uri, body=None, logon_required=True, wait_for_completion=True, operation_timeout=None): """ Perform the HTTP POST method against the resource identified by a URI, using a provided request body, on the faked HMC. HMC operations using HTTP POST are either synch...
python
{ "resource": "" }
q15125
_NotificationListener.on_disconnected
train
def on_disconnected(self): """ Event method that gets called when the JMS session has been disconnected. It hands over a termination notification (headers and message are None). """ with self._handover_cond: # Wait until receiver has processed the p...
python
{ "resource": "" }
q15126
Console.restart
train
def restart(self, force=False, wait_for_available=True, operation_timeout=None): """ Restart the HMC represented by this Console object. Once the HMC is online again, this Console object, as well as any other resource objects accessed through this HMC, can continue to be...
python
{ "resource": "" }
q15127
Console.shutdown
train
def shutdown(self, force=False): """ Shut down and power off the HMC represented by this Console object. While the HMC is powered off, any Python resource objects retrieved from this HMC may raise exceptions upon further use. In order to continue using Python resource objects r...
python
{ "resource": "" }
q15128
Console._time_query_parms
train
def _time_query_parms(begin_time, end_time): """Return the URI query paramterer string for the specified begin time and end time.""" query_parms = [] if begin_time is not None: begin_ts = timestamp_from_datetime(begin_time) qp = 'begin-time={}'.format(begin_ts) ...
python
{ "resource": "" }
q15129
Console.get_audit_log
train
def get_audit_log(self, begin_time=None, end_time=None): """ Return the console audit log entries, optionally filtered by their creation time. Authorization requirements: * Task permission to the "Audit and Log Management" task. Parameters: begin_time (:clas...
python
{ "resource": "" }
q15130
Console.list_unmanaged_cpcs
train
def list_unmanaged_cpcs(self, name=None): """ List the unmanaged CPCs of this HMC. For details, see :meth:`~zhmcclient.UnmanagedCpc.list`. Authorization requirements: * None Parameters: name (:term:`string`): Regular expression pattern for the C...
python
{ "resource": "" }
q15131
Cpc.feature_info
train
def feature_info(self): """ Returns information about the features available for this CPC. Authorization requirements: * Object-access permission to this CPC. Returns: :term:`iterable`: An iterable where each item represents one feature that is ...
python
{ "resource": "" }
q15132
Cpc.start
train
def start(self, wait_for_completion=True, operation_timeout=None): """ Start this CPC, using the HMC operation "Start CPC". Authorization requirements: * Object-access permission to this CPC. * Task permission for the "Start (start a single DPM system)" task. Parameter...
python
{ "resource": "" }
q15133
Cpc.get_free_crypto_domains
train
def get_free_crypto_domains(self, crypto_adapters=None): """ Return a list of crypto domains that are free for usage on a list of crypto adapters in this CPC. A crypto domain is considered free for usage if it is not assigned to any defined partition of this CPC in access mode '...
python
{ "resource": "" }
q15134
Cpc.set_power_save
train
def set_power_save(self, power_saving, wait_for_completion=True, operation_timeout=None): """ Set the power save setting of this CPC. The current power save setting in effect for a CPC is described in the "cpc-power-saving" property of the CPC. This metho...
python
{ "resource": "" }
q15135
Cpc.set_power_capping
train
def set_power_capping(self, power_capping_state, power_cap=None, wait_for_completion=True, operation_timeout=None): """ Set the power capping settings of this CPC. The power capping settings of a CPC define whether or not the power consumption of the CPC is limi...
python
{ "resource": "" }
q15136
Cpc.get_energy_management_properties
train
def get_energy_management_properties(self): """ Return the energy management properties of the CPC. The returned energy management properties are a subset of the properties of the CPC resource, and are also available as normal properties of the CPC resource. In so far, there is ...
python
{ "resource": "" }
q15137
Cpc.validate_lun_path
train
def validate_lun_path(self, host_wwpn, host_port, wwpn, lun): """ Validate if an FCP storage volume on an actual storage subsystem is reachable from this CPC, through a specified host port and using a specified host WWPN. This method performs the "Validate LUN Path" HMC operatio...
python
{ "resource": "" }
q15138
UserPatternManager.reorder
train
def reorder(self, user_patterns): """ Reorder the User Patterns of the HMC as specified. The order of User Patterns determines the search order during logon processing. Authorization requirements: * Task permission to the "Manage User Patterns" task. Parameter...
python
{ "resource": "" }
q15139
TimeStats.reset
train
def reset(self): """ Reset the time statistics data for the operation. """ self._count = 0 self._sum = float(0) self._min = float('inf') self._max = float(0)
python
{ "resource": "" }
q15140
TimeStatsKeeper.get_stats
train
def get_stats(self, name): """ Get the time statistics for a name. If a time statistics for that name does not exist yet, create one. Parameters: name (string): Name of the time statistics. Returns: TimeStats: The time statistics for the specif...
python
{ "resource": "" }
q15141
UnmanagedCpcManager.list
train
def list(self, full_properties=False, filter_args=None): """ List the unmanaged CPCs exposed by the HMC this client is connected to. Because the CPCs are unmanaged, the returned :class:`~zhmcclient.UnmanagedCpc` objects cannot perform any operations and will have only the follow...
python
{ "resource": "" }
q15142
parse_query_parms
train
def parse_query_parms(method, uri, query_str): """ Parse the specified query parms string and return a dictionary of query parameters. The key of each dict item is the query parameter name, and the value of each dict item is the query parameter value. If a query parameter shows up more than once, th...
python
{ "resource": "" }
q15143
check_required_fields
train
def check_required_fields(method, uri, body, field_names): """ Check required fields in the request body. Raises: BadRequestError with reason 3: Missing request body BadRequestError with reason 5: Missing required field in request body """ # Check presence of request body if body i...
python
{ "resource": "" }
q15144
check_valid_cpc_status
train
def check_valid_cpc_status(method, uri, cpc): """ Check that the CPC is in a valid status, as indicated by its 'status' property. If the Cpc object does not have a 'status' property set, this function does nothing (in order to make the mock support easy to use). Raises: ConflictError wit...
python
{ "resource": "" }
q15145
ensure_crypto_config
train
def ensure_crypto_config(partition): """ Ensure that the 'crypto-configuration' property on the faked partition is initialized. """ if 'crypto-configuration' not in partition.properties or \ partition.properties['crypto-configuration'] is None: partition.properties['crypto-confi...
python
{ "resource": "" }
q15146
PartitionManager.create
train
def create(self, properties): """ Create and configure a Partition in this CPC. Authorization requirements: * Object-access permission to this CPC. * Task permission to the "New Partition" task. Parameters: properties (dict): Initial property values. ...
python
{ "resource": "" }
q15147
Partition.feature_enabled
train
def feature_enabled(self, feature_name): """ Indicates whether the specified feature is enabled for the CPC of this partition. The HMC must generally support features, and the specified feature must be available for the CPC. For a list of available features, see section...
python
{ "resource": "" }
q15148
Partition.feature_info
train
def feature_info(self): """ Returns information about the features available for the CPC of this partition. Authorization requirements: * Object-access permission to this partition. Returns: :term:`iterable`: An iterable where each item represent...
python
{ "resource": "" }
q15149
Partition.dump_partition
train
def dump_partition(self, parameters, wait_for_completion=True, operation_timeout=None): """ Dump this Partition, by loading a standalone dump program from a SCSI device and starting its execution, using the HMC operation 'Dump Partition'. Authorization req...
python
{ "resource": "" }
q15150
Partition.mount_iso_image
train
def mount_iso_image(self, image, image_name, ins_file_name): """ Upload an ISO image and associate it to this Partition using the HMC operation 'Mount ISO Image'. When the partition already has an ISO image associated, the newly uploaded image replaces the current one. ...
python
{ "resource": "" }
q15151
Partition.open_os_message_channel
train
def open_os_message_channel(self, include_refresh_messages=True): """ Open a JMS message channel to this partition's operating system, returning the string "topic" representing the message channel. Parameters: include_refresh_messages (bool): Boolean controlling w...
python
{ "resource": "" }
q15152
Partition.send_os_command
train
def send_os_command(self, os_command_text, is_priority=False): """ Send a command to the operating system running in this partition. Parameters: os_command_text (string): The text of the operating system command. is_priority (bool): Boolean controlling whether ...
python
{ "resource": "" }
q15153
Partition.wait_for_status
train
def wait_for_status(self, status, status_timeout=None): """ Wait until the status of this partition has a desired value. Parameters: status (:term:`string` or iterable of :term:`string`): Desired partition status or set of status values to reach; one or more o...
python
{ "resource": "" }
q15154
Partition.change_crypto_domain_config
train
def change_crypto_domain_config(self, crypto_domain_index, access_mode): """ Change the access mode for a crypto domain that is currently included in the crypto configuration of this partition. The access mode will be changed for the specified crypto domain on all crypto adapter...
python
{ "resource": "" }
q15155
Partition.zeroize_crypto_domain
train
def zeroize_crypto_domain(self, crypto_adapter, crypto_domain_index): """ Zeroize a single crypto domain on a crypto adapter. Zeroizing a crypto domain clears the cryptographic keys and non-compliance mode settings in the crypto domain. The crypto domain must be attached to thi...
python
{ "resource": "" }
q15156
Partition.list_attached_storage_groups
train
def list_attached_storage_groups(self, full_properties=False): """ Return the storage groups that are attached to this partition. The CPC must have the "dpm-storage-management" feature enabled. Authorization requirements: * Object-access permission to this partition. *...
python
{ "resource": "" }
q15157
PasswordRule.update_properties
train
def update_properties(self, properties): """ Update writeable properties of this PasswordRule. The Password Rule must be user-defined. System-defined Password Rules cannot be updated. Authorization requirements: * Task permission to the "Manage Password Rules" task. ...
python
{ "resource": "" }
q15158
Client.version_info
train
def version_info(self): """ Returns API version information for the HMC. This operation does not require authentication. Returns: :term:`HMC API version`: The HMC API version supported by the HMC. Raises: :exc:`~zhmcclient.HTTPError` :exc:`~zhmc...
python
{ "resource": "" }
q15159
Client.query_api_version
train
def query_api_version(self): """ The Query API Version operation returns information about the level of Web Services API supported by the HMC. This operation does not require authentication. Returns: :term:`json object`: A JSON object with members ``api-m...
python
{ "resource": "" }
q15160
Client.get_inventory
train
def get_inventory(self, resources): """ Returns a JSON object with the requested resources and their properties, that are managed by the HMC. This method performs the 'Get Inventory' HMC operation. Parameters: resources (:term:`iterable` of :term:`string`): ...
python
{ "resource": "" }
q15161
BaseResource.pull_full_properties
train
def pull_full_properties(self): """ Retrieve the full set of resource properties and cache them in this object. Authorization requirements: * Object-access permission to this resource. Raises: :exc:`~zhmcclient.HTTPError` :exc:`~zhmcclient.ParseErr...
python
{ "resource": "" }
q15162
BaseResource.get_property
train
def get_property(self, name): """ Return the value of a resource property. If the resource property is not cached in this object yet, the full set of resource properties is retrieved and cached in this object, and the resource property is again attempted to be returned. ...
python
{ "resource": "" }
q15163
make_client
train
def make_client(zhmc, userid=None, password=None): """ Create a `Session` object for the specified HMC and log that on. Create a `Client` object using that `Session` object, and return it. If no userid and password are specified, and if no previous call to this method was made, userid and password ...
python
{ "resource": "" }
q15164
repr_list
train
def repr_list(_list, indent): """Return a debug representation of a list or tuple.""" # pprint represents lists and tuples in one row if possible. We want one # per row, so we iterate ourselves. if _list is None: return 'None' if isinstance(_list, MutableSequence): bm = '[' e...
python
{ "resource": "" }
q15165
repr_dict
train
def repr_dict(_dict, indent): """Return a debug representation of a dict or OrderedDict.""" # pprint represents OrderedDict objects using the tuple init syntax, # which is not very readable. Therefore, dictionaries are iterated over. if _dict is None: return 'None' if not isinstance(_dict, M...
python
{ "resource": "" }
q15166
repr_timestamp
train
def repr_timestamp(timestamp): """Return a debug representation of an HMC timestamp number.""" if timestamp is None: return 'None' dt = datetime_from_timestamp(timestamp) ret = "%d (%s)" % (timestamp, dt.strftime('%Y-%m-%d %H:%M:%S.%f %Z')) return ret
python
{ "resource": "" }
q15167
StorageGroupManager.create
train
def create(self, properties): """ Create and configure a storage group. The new storage group will be associated with the CPC identified by the `cpc-uri` input property. Authorization requirements: * Object-access permission to the CPC that will be associated with ...
python
{ "resource": "" }
q15168
StorageGroup.list_attached_partitions
train
def list_attached_partitions(self, name=None, status=None): """ Return the partitions to which this storage group is currently attached, optionally filtered by partition name and status. Authorization requirements: * Object-access permission to this storage group. * Tas...
python
{ "resource": "" }
q15169
StorageGroup.add_candidate_adapter_ports
train
def add_candidate_adapter_ports(self, ports): """ Add a list of storage adapter ports to this storage group's candidate adapter ports list. This operation only applies to storage groups of type "fcp". These adapter ports become candidates for use as backing adapters when ...
python
{ "resource": "" }
q15170
StorageGroup.list_candidate_adapter_ports
train
def list_candidate_adapter_ports(self, full_properties=False): """ Return the current candidate storage adapter port list of this storage group. The result reflects the actual list of ports used by the CPC, including any changes that have been made during discovery. The source f...
python
{ "resource": "" }
q15171
AdapterManager.create_hipersocket
train
def create_hipersocket(self, properties): """ Create and configure a HiperSockets Adapter in this CPC. Authorization requirements: * Object-access permission to the scoping CPC. * Task permission to the "Create HiperSockets Adapter" task. Parameters: propert...
python
{ "resource": "" }
q15172
Adapter.change_crypto_type
train
def change_crypto_type(self, crypto_type, zeroize=None): """ Reconfigures a cryptographic adapter to a different crypto type. This operation is only supported for cryptographic adapters. The cryptographic adapter must be varied offline before its crypto type can be reconfigured....
python
{ "resource": "" }
q15173
Lpar.stop
train
def stop(self, wait_for_completion=True, operation_timeout=None, status_timeout=None, allow_status_exceptions=False): """ Stop this LPAR, using the HMC operation "Stop Logical Partition". The stop operation stops the processors from processing instructions. This HMC...
python
{ "resource": "" }
q15174
_result_object
train
def _result_object(result): """ Return the JSON payload in the HTTP response as a Python dict. Parameters: result (requests.Response): HTTP response object. Raises: zhmcclient.ParseError: Error parsing the returned JSON. """ content_type = result.headers.get('content-type', Non...
python
{ "resource": "" }
q15175
RetryTimeoutConfig.override_with
train
def override_with(self, override_config): """ Return a new configuration object that represents the configuration from this configuration object acting as a default, and the specified configuration object overriding that default. Parameters: override_config (:class:`~...
python
{ "resource": "" }
q15176
Session.is_logon
train
def is_logon(self, verify=False): """ Return a boolean indicating whether the session is currently logged on to the HMC. By default, this method checks whether there is a session-id set and considers that sufficient for determining that the session is logged on. The `ver...
python
{ "resource": "" }
q15177
Session._do_logon
train
def _do_logon(self): """ Log on, unconditionally. This can be used to re-logon. This requires credentials to be provided. Raises: :exc:`~zhmcclient.ClientAuthError` :exc:`~zhmcclient.ServerAuthError` :exc:`~zhmcclient.ConnectionError` :exc:`~zhmc...
python
{ "resource": "" }
q15178
Session._new_session
train
def _new_session(retry_timeout_config): """ Return a new `requests.Session` object. """ retry = requests.packages.urllib3.Retry( total=None, connect=retry_timeout_config.connect_retries, read=retry_timeout_config.read_retries, method_whitel...
python
{ "resource": "" }
q15179
Session._do_logoff
train
def _do_logoff(self): """ Log off, unconditionally. Raises: :exc:`~zhmcclient.ServerAuthError` :exc:`~zhmcclient.ConnectionError` :exc:`~zhmcclient.ParseError` :exc:`~zhmcclient.HTTPError` """ session_uri = '/api/sessions/this-session' ...
python
{ "resource": "" }
q15180
Session._log_http_request
train
def _log_http_request(method, url, headers=None, content=None): """ Log the HTTP request of an HMC REST API call, at the debug level. Parameters: method (:term:`string`): HTTP method name in upper case, e.g. 'GET' url (:term:`string`): HTTP URL (base URL and operation URI)...
python
{ "resource": "" }
q15181
Session._log_http_response
train
def _log_http_response(method, url, status, headers=None, content=None): """ Log the HTTP response of an HMC REST API call, at the debug level. Parameters: method (:term:`string`): HTTP method name in upper case, e.g. 'GET' url (:term:`string`): HTTP URL (base URL and oper...
python
{ "resource": "" }
q15182
Session.delete
train
def delete(self, uri, logon_required=True): """ Perform the HTTP DELETE method against the resource identified by a URI. A set of standard HTTP headers is automatically part of the request. If the HMC session token is expired, this method re-logs on and retries the oper...
python
{ "resource": "" }
q15183
Job.check_for_completion
train
def check_for_completion(self): """ Check once for completion of the job and return completion status and result if it has completed. If the job completed in error, an :exc:`~zhmcclient.HTTPError` exception is raised. Returns: : A tuple (status, result) with:...
python
{ "resource": "" }
q15184
Job.wait_for_completion
train
def wait_for_completion(self, operation_timeout=None): """ Wait for completion of the job, then delete the job on the HMC and return the result of the original asynchronous HMC operation, if it completed successfully. If the job completed in error, an :exc:`~zhmcclient.HTTPError...
python
{ "resource": "" }
q15185
logged_api_call
train
def logged_api_call(func): """ Function decorator that causes the decorated API function or method to log calls to itself to a logger. The logger's name is the dotted module name of the module defining the decorated function (e.g. 'zhmcclient._cpc'). Parameters: func (function object): ...
python
{ "resource": "" }
q15186
generic_div
train
def generic_div(a, b): """Simple function to divide two numbers""" logger.debug('Called generic_div({}, {})'.format(a, b)) return a / b
python
{ "resource": "" }
q15187
buggy_div
train
def buggy_div(request): """ A buggy endpoint to perform division between query parameters a and b. It will fail if b is equal to 0 or either a or b are not float. :param request: request object :return: """ a = float(request.GET.get('a', '0')) b = float(request.GET.get('b', '0')) re...
python
{ "resource": "" }
q15188
ascii
train
def ascii(graph): """Format graph as an ASCII art.""" from .._ascii import DAG from .._echo import echo_via_pager echo_via_pager(str(DAG(graph)))
python
{ "resource": "" }
q15189
_jsonld
train
def _jsonld(graph, format, *args, **kwargs): """Return formatted graph in JSON-LD ``format`` function.""" import json from pyld import jsonld from renku.models._jsonld import asjsonld output = getattr(jsonld, format)([ asjsonld(action) for action in graph.activities.values() ]) ret...
python
{ "resource": "" }
q15190
dot
train
def dot(graph, simple=True, debug=False, landscape=False): """Format graph as a dot file.""" import sys from rdflib import ConjunctiveGraph from rdflib.plugin import register, Parser from rdflib.tools.rdf2dot import rdf2dot register('json-ld', Parser, 'rdflib_jsonld.parser', 'JsonLDParser') ...
python
{ "resource": "" }
q15191
_rdf2dot_simple
train
def _rdf2dot_simple(g, stream): """Create a simple graph of processes and artifacts.""" from itertools import chain import re path_re = re.compile( r'file:///(?P<type>[a-zA-Z]+)/' r'(?P<commit>\w+)' r'(?P<path>.+)?' ) inputs = g.query( """ SELECT ?input...
python
{ "resource": "" }
q15192
makefile
train
def makefile(graph): """Format graph as Makefile.""" from renku.models.provenance.activities import ProcessRun, WorkflowRun for activity in graph.activities.values(): if not isinstance(activity, ProcessRun): continue elif isinstance(activity, WorkflowRun): steps = ac...
python
{ "resource": "" }
q15193
nt
train
def nt(graph): """Format graph as n-tuples.""" from rdflib import ConjunctiveGraph from rdflib.plugin import register, Parser register('json-ld', Parser, 'rdflib_jsonld.parser', 'JsonLDParser') click.echo( ConjunctiveGraph().parse( data=_jsonld(graph, 'expand'), for...
python
{ "resource": "" }
q15194
install
train
def install(client, force): """Install Git hooks.""" import pkg_resources from git.index.fun import hook_path as get_hook_path for hook in HOOKS: hook_path = Path(get_hook_path(hook, client.repo.git_dir)) if hook_path.exists(): if not force: click.echo( ...
python
{ "resource": "" }
q15195
uninstall
train
def uninstall(client): """Uninstall Git hooks.""" from git.index.fun import hook_path as get_hook_path for hook in HOOKS: hook_path = Path(get_hook_path(hook, client.repo.git_dir)) if hook_path.exists(): hook_path.unlink()
python
{ "resource": "" }
q15196
format_cell
train
def format_cell(cell, datetime_fmt=None): """Format a cell.""" if datetime_fmt and isinstance(cell, datetime): return cell.strftime(datetime_fmt) return cell
python
{ "resource": "" }
q15197
tabulate
train
def tabulate(collection, headers, datetime_fmt='%Y-%m-%d %H:%M:%S', **kwargs): """Pretty-print a collection.""" if isinstance(headers, dict): attrs = headers.keys() # if mapping is not specified keep original names = [ key if value is None else value for key, value in headers...
python
{ "resource": "" }
q15198
_convert_dataset_files
train
def _convert_dataset_files(value): """Convert dataset files.""" output = {} for k, v in value.items(): inst = DatasetFile.from_jsonld(v) output[inst.path] = inst return output
python
{ "resource": "" }
q15199
remove
train
def remove(ctx, client, sources): """Remove files and check repository for potential problems.""" from renku.api._git import _expand_directories def fmt_path(path): """Format path as relative to the client path.""" return str(Path(path).absolute().relative_to(client.path)) files = { ...
python
{ "resource": "" }