function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def test_xavier_uniform(self):
self._test_xavier(initializers.xavier_initializer, [100, 40],
2. / (100. + 40.), True) | google-research/tf-slim | [
334,
98,
334,
11,
1561681288
] |
def test_xavier_scalar(self):
self._test_xavier(initializers.xavier_initializer, [], 0.0, True) | google-research/tf-slim | [
334,
98,
334,
11,
1561681288
] |
def test_xavier_conv2d_normal(self):
self._test_xavier(tf_slim.xavier_initializer_conv2d, [100, 40, 5, 7],
2. / (100. * 40 * (5 + 7)), False) | google-research/tf-slim | [
334,
98,
334,
11,
1561681288
] |
def test_wrong_dtype(self):
with self.assertRaisesRegexp(
TypeError, 'Cannot create initializer for non-floating point type.'):
initializers.variance_scaling_initializer(dtype=dtypes.int32)
initializer = initializers.variance_scaling_initializer()
with self.assertRaisesRegexp(
TypeError, 'Cannot create initializer for non-floating point type.'):
initializer([], dtype=dtypes.int32) | google-research/tf-slim | [
334,
98,
334,
11,
1561681288
] |
def test_fan_in(self):
for uniform in [False, True]:
self._test_variance(
initializers.variance_scaling_initializer,
shape=[100, 40],
variance=2. / 100.,
factor=2.0,
mode='FAN_IN',
uniform=uniform) | google-research/tf-slim | [
334,
98,
334,
11,
1561681288
] |
def test_fan_avg(self):
for uniform in [False, True]:
self._test_variance(
initializers.variance_scaling_initializer,
shape=[100, 40],
variance=4. / (100. + 40.),
factor=2.0,
mode='FAN_AVG',
uniform=uniform) | google-research/tf-slim | [
334,
98,
334,
11,
1561681288
] |
def test_conv2d_fan_out(self):
for uniform in [False, True]:
self._test_variance(
initializers.variance_scaling_initializer,
shape=[100, 40, 5, 7],
variance=2. / (100. * 40. * 7.),
factor=2.0,
mode='FAN_OUT',
uniform=uniform) | google-research/tf-slim | [
334,
98,
334,
11,
1561681288
] |
def test_xavier_uniform(self):
self._test_variance(
initializers.variance_scaling_initializer,
shape=[100, 40],
variance=2. / (100. + 40.),
factor=1.0,
mode='FAN_AVG',
uniform=True) | google-research/tf-slim | [
334,
98,
334,
11,
1561681288
] |
def test_xavier_scalar(self):
self._test_variance(
initializers.variance_scaling_initializer,
shape=[],
variance=0.0,
factor=1.0,
mode='FAN_AVG',
uniform=False) | google-research/tf-slim | [
334,
98,
334,
11,
1561681288
] |
def test_xavier_conv2d_normal(self):
self._test_variance(
initializers.variance_scaling_initializer,
shape=[100, 40, 5, 7],
variance=2. / (100. * 40. * (5. + 7.)),
factor=1.0,
mode='FAN_AVG',
uniform=True) | google-research/tf-slim | [
334,
98,
334,
11,
1561681288
] |
def test_1d_shape_fan_out(self):
for uniform in [False, True]:
self._test_variance(
initializers.variance_scaling_initializer,
shape=[100],
variance=2. / 100.,
factor=2.0,
mode='FAN_OUT',
uniform=uniform) | google-research/tf-slim | [
334,
98,
334,
11,
1561681288
] |
def __init__(self, config=None):
bce_base_client.BceBaseClient.__init__(self, config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def _send_request(self, http_method, path,
body=None, headers=None, params=None,
config=None, body_parser=None):
config = self._merge_config(config)
if body_parser is None:
body_parser = handler.parse_json
if headers is None:
headers = {b'Accept': b'*/*',
b'Content-Type': b'application/json;charset=utf-8'}
return bce_http_client.send_request(
config, bce_v1_signer.sign, [handler.parse_error, body_parser],
http_method, path, body, headers, params) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def create_app_loadbalancer(self, vpc_id, subnet_id, name=None,
desc=None, client_token=None, config=None):
"""
Create a app LoadBalancer with the specified options.
:param name:
the name of LoadBalancer to create
:type name: string
:param desc:
The description of LoadBalancer
:type desc: string
:param vpc_id:
id of vpc which the LoadBalancer belong to
:type vpc_id: string
:param subnet_id:
id of subnet which the LoadBalancer belong to
:type subnet_id: string
:param client_token:
If the clientToken is not specified by the user, a random String
generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {}
if name is not None:
body['name'] = compat.convert_to_string(name)
if desc is not None:
body['desc'] = compat.convert_to_string(desc)
body['vpcId'] = compat.convert_to_string(vpc_id)
body['subnetId'] = compat.convert_to_string(subnet_id)
return self._send_request(http_methods.POST, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def update_app_loadbalancer(self, blb_id, name=None, desc=None,
client_token=None, config=None):
"""
Modify the special attribute to new value of the LoadBalancer
owned by the user.
:param name:
name of LoadBalancer to describe
:type name: string
:param blb_id:
id of LoadBalancer to describe
:type blb_id: string
:param desc:
The description of LoadBalancer
:type desc: string
:param client_token:
If the clientToken is not specified by the user,
a random String generated by default algorithm
will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id)
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {}
if name is not None:
body['name'] = compat.convert_to_string(name)
if desc is not None:
body['desc'] = compat.convert_to_string(desc)
return self._send_request(http_methods.PUT, path, json.dumps(body),
params=params, config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def describe_app_loadbalancer_detail(self, blb_id, config=None):
"""
Return detail imformation of specific LoadBalancer
:param blb_id:
id of LoadBalancer to describe
:type blb_id: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id)
return self._send_request(http_methods.GET, path,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def delete_app_loadbalancer(self, blb_id, client_token=None, config=None):
"""
delete the LoadBalancer owned by the user.
:param blb_id:
id of LoadBalancer to describe
:type blb_id: string
:param client_token:
If the clientToken is not specified by the user,
a random String generated by default algorithm
will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id)
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
return self._send_request(http_methods.DELETE, path,
params=params, config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def create_app_tcp_listener(self, blb_id, listener_port,
scheduler, client_token=None,
config=None):
"""
Create a app tcp listener rule with the specified options.
:param blb_id:
the id of blb which the listener work on
:type blb_id: string
:param listener_port:
port to be linstened owned by listener
:value 1-65535
:type listener_port: int
:param scheduler
balancing algorithm
:value 'RoundRobin' or 'LeastConnection' or 'Hash'
:type scheduler: string
:param client_token:
If the clientToken is not specified by the user, a random String
generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'TCPlistener')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {
'listenerPort': listener_port,
'scheduler': compat.convert_to_string(scheduler)
}
return self._send_request(http_methods.POST, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def create_app_udp_listener(self, blb_id, listener_port,
scheduler, client_token=None,
config=None):
"""
Create a app udp listener rule with the specified options.
:param blb_id:
the id of blb which the listener work on
:type blb_id: string
:param listener_port:
port to be linstened owned by listener
:value 1-65535
:type listener_port: int
:param scheduler
balancing algorithm
:value 'RoundRobin' or 'LeastConnection' or 'Hash'
:type scheduler: string
:param client_token:
If the clientToken is not specified by the user, a random String
generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'UDPlistener')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {
'listenerPort': listener_port,
'scheduler': compat.convert_to_string(scheduler)
}
return self._send_request(http_methods.POST, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def create_app_http_listener(self, blb_id, listener_port,
scheduler, keep_session=None,
keep_session_type=None,
keep_session_timeout=None,
keep_session_cookie_name=None,
x_forward_for=None,
server_timeout=None,
redirect_port=None,
client_token=None,
config=None):
"""
Create a app http listener rule with the specified options.
:param blb_id:
the id of blb which the listener work on
:type blb_id: string
:param listener_port:
port to be linstened owned by listener
:value 1-65535
:type listener_port: int
:param scheduler:
balancing algorithm
:value 'RoundRobin' or 'LeastConnection'
:type scheduler: string
:param keep_session:
Whether to enable the session hold function,
that is,the request sent by the same client will
reach the same backend server
:value true or false default:false
:type keep_session: bool
:param keep_session_type:
The cookie handling method maintained by the session,
valid only if the session is held open
:value 'insert' or 'rewrite' default:insert
:type keep_session_type: string
:param keep_session_timeout:
The time the cookie is kept in session (in seconds),
valid only if the session is held open
:value 1-15552000 default:3600
:type keep_session_timeout: int
:param keep_session_cookie_name:
The session keeps the name of the cookie that needs to be
overridden if and only if session persistence is enabled
and keep_session_type="rewrite"
:type keep_session_cookie_name: int
:param x_forward_for:
Whether to enable the real IP address of the client,
the backend server can obtain the real address of the client
through the X-Forwarded-For HTTP header.
:value true or false, default: False
:type x_forward_for: bool
:param server_timeout:
Backend server maximum timeout (unit: second)
:value 1-3600, default: 30
:type server_timeout:int
:param redirect_port:
Forward the request received by this listener to the
HTTPS listener, which is specified by the HTTPS listener.
:type redirect_port:int
:param client_token:
If the clientToken is not specified by the user,
a random String generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'HTTPlistener')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {
'listenerPort': listener_port,
'scheduler': compat.convert_to_string(scheduler)}
if keep_session is not None:
body['keepSession'] = keep_session
if keep_session_type is not None:
body['keepSessionType'] = \
compat.convert_to_string(keep_session_type)
if keep_session_timeout is not None:
body['keepSessionTimeout'] = keep_session_timeout
if keep_session_cookie_name is not None:
body['keepSessionCookieName'] = keep_session_cookie_name
if x_forward_for is not None:
body['xForwardFor'] = x_forward_for
if server_timeout is not None:
body['serverTimeout'] = server_timeout
if redirect_port is not None:
body['redirectPort'] = redirect_port
return self._send_request(http_methods.POST, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def create_app_https_listener(self, blb_id, listener_port,
scheduler, cert_ids,
keep_session=None,
keep_session_type=None,
keep_session_timeout=None,
keep_session_cookie_name=None,
x_forward_for=None, server_timeout=None,
ie6_compatible=None, encryption_type=None,
encryption_protocols=None,
dual_auth=None, client_certIds=None,
client_token=None, config=None):
"""
Create a app https listener rule with the specified options.
:param blb_id:
The id of blb which the listener work on
:type blb_id: string
:param listener_port:
port to be linstened owned by listener
:value 1-65535
:type listener_port: int
:param scheduler:
balancing algorithm
:value 'RoundRobin' or 'LeastConnection'
:type scheduler: string
:param cert_ids:
The certificate to be loaded by the listener.
:type cert_ids: List<String>
:param keep_session:
Whether to enable the session hold function,
that is, the request sent by the same client will reach the
same backend server
:value true or false, default: false
:type keep_session: bool
:param keep_session_type:
The cookie handling method maintained by the session,
valid only if the session is held open
:value 'insert' or 'rewrite', default:insert
:type keep_session_type: string
:param keep_session_timeout:
The time the cookie is kept in session (in seconds),
valid only if the session is held open
:value 1-15552000, default:3600
:type keep_session_timeout: int
:param keep_session_cookie_name:
The session keeps the name of the cookie that needs
to be overridden if and only if session persistence
is enabled and keep_session_type="rewrite"
:type keep_session_cookie_name: int
:param x_forward_for:
Whether to enable the real IP address of the client,
the backend server can obtain the real address of the client
through the X-Forwarded-For HTTP header.
:value true or false, default: flase
:type x_forward_for: bool
:param server_timeout:
Backend server maximum timeout (unit: second)
:value 1-3600, default: 30
:type server_timeout: int
:param ie6_compatible:
compatible with IE6 HTTPS request
(the protocol format is earlier SSL3.0, the security is poor)
:value true or false, default: true
:type ie6_compatible: bool
:param encryption_type:
Encryption options, support three types:
compatibleIE/incompatibleIE/userDefind,
corresponding to:
IE-compatible encryption/disabled unsecure encryption/custom encryption,
when encryptionType is valid and legitimate,
ie6Compatible field transfer value will not take effect
type: encryption_type:string
:param encryption_protocols:
When the encryptionType value is userDefind,
the list of protocol types is a string list composed of four protocols:
"sslv3", "tlsv10", "tlsv11", "tlsv12".
type: encryption_protocols:list
:param dual_auth:
Whether to Open Two-way Authentication,
default:false
:type dual_auth: boolean
:param client_certIds:
When dualAuth is true, the loaded client certificate chain
:type client_certIds: list
:param client_token:
If the clientToken is not specified by the user,
a random String generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'HTTPSlistener')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {
'listenerPort': listener_port,
'scheduler': compat.convert_to_string(scheduler),
'certIds': cert_ids}
if keep_session is not None:
body['keepSession'] = keep_session
if keep_session_type is not None:
body['keepSessionType'] = \
compat.convert_to_string(keep_session_type)
if keep_session_timeout is not None:
body['keepSessionTimeout'] = keep_session_timeout
if keep_session_cookie_name is not None:
body['keepSessionCookieName'] = keep_session_cookie_name
if x_forward_for is not None:
body['xForwardFor'] = x_forward_for
if server_timeout is not None:
body['serverTimeout'] = server_timeout
if ie6_compatible is not None:
body['ie6Compatible'] = ie6_compatible
if encryption_type is not None:
body['encryptionType'] = \
compat.convert_to_string(encryption_type)
if encryption_protocols is not None:
body['encryptionProtocols'] = encryption_protocols
if dual_auth is not None:
body['dualAuth'] = dual_auth
if client_certIds is not None:
body['clientCertIds'] = client_certIds
return self._send_request(http_methods.POST, path,
body=json.dumps(body),
params=params, config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def create_app_ssl_listener(self, blb_id, listener_port,
scheduler, cert_ids,
ie6_compatible=None,
encryption_type=None,
encryption_protocols=None,
dual_auth=None, client_certIds=None,
client_token=None, config=None):
"""
Create a app ssl listener rule with the specified options.
:param blb_id:
The id of blb which the listener work on
:type blb_id: string
:param listener_port:
port to be linstened owned by listener
:value 1-65535
:type listener_port: int
:param scheduler:
balancing algorithm
:value 'RoundRobin' or 'LeastConnection'
:type scheduler: string
:param cert_ids:
The SSL certificate to be loaded by the listener.
Currently HTTPS listeners can only bind one SSL certificate.
:type cert_ids: List<String>
:param ie6_compatible:
compatible with IE6 HTTPS request
(the protocol format is earlier SSL3.0, the security is poor)
:value true or false, default: true
:type ie6_compatible: bool
:param encryption_type:
Encryption options, support three types:
compatibleIE/incompatibleIE/userDefind,
corresponding to:
IE-compatible encryption/disabled unsecure encryption/custom encryption,
when encryptionType is valid and legitimate,
ie6Compatible field transfer value will not take effect
type: encryption_type:string
:param encryption_protocols:
When the encryptionType value is userDefind,
the list of protocol types is a string list composed of four protocols:
"sslv3", "tlsv10", "tlsv11", "tlsv12".
type: encryption_protocols:list
:param dual_auth:
Whether to Open Two-way Authentication,
default:false
:type dual_auth: boolean
:param client_certIds:
When dualAuth is true, the loaded client certificate chain
:type client_certIds: list
:param client_token:
If the clientToken is not specified by the user,
a random String generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'SSLlistener')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {
'listenerPort': listener_port,
'scheduler': compat.convert_to_string(scheduler),
'certIds': cert_ids}
if ie6_compatible is not None:
body['ie6Compatible'] = ie6_compatible
if encryption_type is not None:
body['encryptionType'] = \
compat.convert_to_string(encryption_type)
if encryption_protocols is not None:
body['encryptionProtocols'] = encryption_protocols
if dual_auth is not None:
body['dualAuth'] = dual_auth
if client_certIds is not None:
body['clientCertIds'] = client_certIds
return self._send_request(http_methods.POST, path,
body=json.dumps(body),
params=params, config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def update_app_tcp_listener(self, blb_id, listener_port,
scheduler=None,
client_token=None,
config=None):
"""
update a app tcp listener rule with the specified options.
:param blb_id:
the id of blb which the listener work on
:type blb_id:string
:param listener_port:
port to be linstened owned by listener
:value 1-65535
:type listener_port:int
:param scheduler
balancing algorithm
:value 'RoundRobin'or'LeastConnection'or'Hash'
:type scheduler:string
:param client_token:
If the clientToken is not specified by the user,
a random String generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'TCPlistener')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
params[b'listenerPort'] = listener_port
body = {}
if scheduler is not None:
body['scheduler'] = compat.convert_to_string(scheduler)
return self._send_request(http_methods.PUT, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def update_app_udp_listener(self, blb_id, listener_port,
scheduler=None, client_token=None,
config=None):
"""
update a app udp listener rule with the specified options.
:param blb_id:
the id of blb which the listener work on
:type blb_id:string
:param listener_port:
port to be linstened owned by listener
:value 1-65535
:type listener_port:int
:param scheduler
balancing algorithm
:value 'RoundRobin'or'LeastConnection'or'Hash'
:type scheduler:string
:param client_token:
If the clientToken is not specified by the user,
a random String generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'UDPlistener')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
params[b'listenerPort'] = listener_port
body = {
'scheduler': compat.convert_to_string(scheduler)
}
return self._send_request(http_methods.PUT, path,
body=json.dumps(body),
params=params, config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def update_app_http_listener(self, blb_id, listener_port,
scheduler=None, keep_session=None,
keep_session_type=None,
keep_session_timeout=None,
keep_session_cookie_name=None,
x_forward_for=None,
server_timeout=None,
redirect_port=None,
client_token=None,
config=None):
"""
update a app http listener rule with the specified options.
:param blb_id:
The id of blb which the listener work on
:type blb_id: string
:param listener_port:
Port to be linstened owned by listener
:value 1-65535
:type listener_port: int
:param scheduler:
Balancing algorithm
:value 'RoundRobin' or 'LeastConnection' or 'Hash'
:type scheduler: string
:param keep_session:
Whether to enable the session hold function, that is,
the request sent by the same client will reach the
same backend server
:value true or false, default:false
:type keep_session: bool
:param keep_session_type:
The cookie handling method maintained by the session,
valid only if the session is held open
:value 'insert' or 'rewrite', default:insert
:type keep_session_type: string
:param keep_session_timeout:
The time the cookie is kept in session (in seconds),
valid only if the session is held open
:value 1-15552000, default:3600
:type keep_session_timeout: int
:param keep_session_cookie_name:
The session keeps the name of the cookie that needs
to be overridden,if and only if session persistence is
enabled and keep_session_type="rewrite"
:type keep_session_cookie_name: int
:param x_forward_for:
Whether to enable the real IP address of the client,
the backend server can obtain the real address of the
client through the X-Forwarded-For HTTP header.
:value true or false, default: flase
:type x_forward_for: bool
:param server_timeout:
Backend server maximum timeout (unit: second)
:value 1-3600, default: 30
:type server_timeout: int
:param redirect_port:
Forward the request received by this listener to the HTTPS
listener, which is specified by the HTTPS listener.
:type redirect_port: int
:param client_token:
If the clientToken is not specified by the user,
a random String generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'HTTPlistener')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
params[b'listenerPort'] = listener_port
body = {}
if scheduler is not None:
body['scheduler'] = compat.convert_to_string(scheduler)
if keep_session is not None:
body['keepSession'] = keep_session
if keep_session_type is not None:
body['keepSessionType'] = \
compat.convert_to_string(keep_session_type)
if keep_session_timeout is not None:
body['keepSessionTimeout'] = keep_session_timeout
if keep_session_cookie_name is not None:
body['keepSessionCookieName'] = keep_session_cookie_name
if x_forward_for is not None:
body['xForwardFor'] = x_forward_for
if server_timeout is not None:
body['serverTimeout'] = server_timeout
if redirect_port is not None:
body['redirectPort'] = redirect_port
return self._send_request(http_methods.PUT, path,
body=json.dumps(body),
params=params, config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def update_app_https_listener(self, blb_id, listener_port,
scheduler=None,
keep_session=None,
keep_session_type=None,
keep_session_timeout=None,
keep_session_cookie_name=None,
x_forward_for=None,
server_timeout=None,
cert_ids=None,
ie6_compatible=None,
encryption_type=None,
encryption_protocols=None,
dual_auth=None,
client_certIds=None,
client_token=None,
config=None):
"""
update a app https listener rule with the specified options.
:param blb_id:
The id of blb which the listener work on
:type blb_id: string
:param listener_port:
Port to be linstened owned by listener
:value 1-65535
:type listener_port: int
:param scheduler:
Balancing algorithm
:value 'RoundRobin' or 'LeastConnection' or 'Hash'
:type scheduler: string
:param keep_session:
Whether to enable the session hold function, that is, the request
sent by the same client will reach the same backend server
:value true or false, default: false
:type keep_session: bool
:param keep_session_type:
The cookie handling method maintained by the session,
valid only if the session is held open
:value 'insert' or 'rewrite', default: insert
:type keep_session_type: string
:param keep_session_timeout:
The time the cookie is kept in session (in seconds),
valid only if the session is held open
:value 1-15552000, default:3600
:type keep_session_timeout: int
:param keep_session_cookie_name:
The session keeps the name of the cookie that needs to be
overridden,if and only if session persistence is enabled and
keep_session_type="rewrite"
:type keep_session_cookie_name: int
:param x_forward_for:
Whether to enable the real IP address of the client,
the backend server can obtain the real address of the client
through the X-Forwarded-For HTTP header.
:value true or false, default: False
:type x_forward_for: bool
:param server_timeout:
Backend server maximum timeout (unit: second)
:value 1-3600, default: 30
:type server_timeout: int
:param cert_ids:
The SSL certificate to be loaded by the listener.
Currently HTTPS listeners can only bind one SSL certificate.
:type cert_ids:List<String>
:param ie6_compatible:
Is it compatible with IE6 HTTPS request
(the protocol format is earlier SSL3.0, the security is poor)
:value true or false, default: true
:type ie6_compatible: bool
:param encryption_type:
Encryption options, support three types:
compatibleIE/incompatibleIE/userDefind,
corresponding to:
IE-compatible encryption/disabled unsecure encryption/custom encryption,
when encryptionType is valid and legitimate,
ie6Compatible field transfer value will not take effect
type: encryption_type:string
:param encryption_protocols:
When the encryptionType value is userDefind,
the list of protocol types is a string list composed of four protocols:
"sslv3", "tlsv10", "tlsv11", "tlsv12".
type: encryption_protocols:list
:param dual_auth:
Whether to Open Two-way Authentication,
default:false
:type dual_auth: boolean
:param client_certIds:
When dualAuth is true, the loaded client certificate chain
:type client_certIds: list
:param client_token:
If the clientToken is not specified by the user,
a random String generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'HTTPSlistener')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
params[b'listenerPort'] = listener_port
body = {}
if scheduler is not None:
body['scheduler'] = compat.convert_to_string(scheduler)
if keep_session is not None:
body['keepSession'] = keep_session
if keep_session_type is not None:
body['keepSessionType'] = \
compat.convert_to_string(keep_session_type)
if keep_session_timeout is not None:
body['keepSessionTimeout'] = keep_session_timeout
if keep_session_cookie_name is not None:
body['keepSessionCookieName'] = keep_session_cookie_name
if x_forward_for is not None:
body['xForwardFor'] = x_forward_for
if server_timeout is not None:
body['serverTimeout'] = server_timeout
if cert_ids is not None:
body['certIds'] = cert_ids
if ie6_compatible is not None:
body['compatibleIE'] = ie6_compatible
if encryption_type is not None:
body['encryptionType'] = \
compat.convert_to_string(encryption_type)
if encryption_protocols is not None:
body['encryptionProtocols'] = encryption_protocols
if dual_auth is not None:
body['dualAuth'] = dual_auth
if client_certIds is not None:
body['clientCertIds'] = client_certIds
return self._send_request(http_methods.PUT, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def update_app_ssl_listener(self, blb_id, listener_port,
scheduler=None,
cert_ids=None,
ie6_compatible=None,
encryption_type=None,
encryption_protocols=None,
dual_auth=None,
client_certIds=None,
client_token=None,
config=None):
"""
update a app ssl listener rule with the specified options.
:param blb_id:
The id of blb which the listener work on
:type blb_id: string
:param listener_port:
port to be linstened owned by listener
:value 1-65535
:type listener_port: int
:param scheduler:
balancing algorithm
:value 'RoundRobin' or 'LeastConnection'
:type scheduler: string
:param cert_ids:
The SSL certificate to be loaded by the listener.
Currently HTTPS listeners can only bind one SSL certificate.
:type cert_ids: List<String>
:param ie6_compatible:
compatible with IE6 HTTPS request
(the protocol format is earlier SSL3.0, the security is poor)
:value true or false, default: true
:type ie6_compatible: bool
:param encryption_type:
Encryption options, support three types:
compatibleIE/incompatibleIE/userDefind,
corresponding to:
IE-compatible encryption/disabled unsecure encryption/custom encryption,
when encryptionType is valid and legitimate,
ie6Compatible field transfer value will not take effect
type: encryption_type:string
:param encryption_protocols:
When the encryptionType value is userDefind,
the list of protocol types is a string list composed of four protocols:
"sslv3", "tlsv10", "tlsv11", "tlsv12".
type: encryption_protocols:list
:param dual_auth:
Whether to Open Two-way Authentication,
default:false
:type dual_auth: boolean
:param client_certIds:
When dualAuth is true, the loaded client certificate chain
:type client_certIds: list
:param client_token:
If the clientToken is not specified by the user,
a random String generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'SSLlistener')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
params[b'listenerPort'] = listener_port
body = {}
if scheduler is not None:
body['scheduler'] = compat.convert_to_string(scheduler)
if cert_ids is not None:
body['certIds'] = cert_ids
if ie6_compatible is not None:
body['compatibleIE'] = ie6_compatible
if encryption_type is not None:
body['encryptionType'] = \
compat.convert_to_string(encryption_type)
if encryption_protocols is not None:
body['encryptionProtocols'] = encryption_protocols
if dual_auth is not None:
body['dualAuth'] = dual_auth
if client_certIds is not None:
body['clientCertIds'] = client_certIds
return self._send_request(http_methods.PUT, path,
body=json.dumps(body),
params=params, config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def describe_app_tcp_listener(self, blb_id, listener_port=None,
marker=None, max_keys=None,
config=None):
"""
get app tcp listeners identified by bibID
:param blb_id
the id of blb which the listener work on
:type blb_id:string
:param listener_port
The listener port to query
:type listener_port:int
:param marker
The optional parameter marker specified in the
original request to specify
where in the results to begin listing.
Together with the marker, specifies the list result
which listing should begin.
If the marker is not specified, the list result will
listing from the first one.
:type marker: string
:param max_keys
The optional parameter to specifies the max number of
list result to return.
The default value is 1000.
:type max_keys: int
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'TCPlistener')
params = {}
if listener_port is not None:
params[b'listenerPort'] = listener_port
if marker is not None:
params[b'marker'] = marker
if max_keys is not None:
params[b'maxKeys'] = max_keys
return self._send_request(http_methods.GET, path,
params=params, config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def describe_app_udp_listener(self, blb_id, listener_port=None,
marker=None, max_keys=None,
config=None):
"""
get app udp listeners identified by bibID
:param blb_id
the id of blb which the listener work on
:type blb_id:string
:param listener_port
The listener port to query
:type listener_port:int
:param marker
The optional parameter marker specified in the original
request to specify where in the results to begin listing.
Together with the marker, specifies the list result which
listing should begin.
If the marker is not specified, the list result will
listing from the first one.
:type marker: string
:param max_keys
The optional parameter to specifies the max number of
list result to return.
The default value is 1000.
:type max_keys: int
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'UDPlistener')
params = {}
if listener_port is not None:
params[b'listenerPort'] = listener_port
if marker is not None:
params[b'marker'] = marker
if max_keys is not None:
params[b'maxKeys'] = max_keys
return self._send_request(http_methods.GET, path,
params=params, config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def describe_app_http_listener(self, blb_id, listener_port=None,
marker=None, max_keys=None,
config=None):
"""
get app http listeners identified by bibID
:param blb_id
the id of blb which the listener work on
:type blb_id:string
:param listener_port
The listener port to query
:type listener_port:int
:param marker
The optional parameter marker specified in the original
request to specify where in the results to begin listing.
Together with the marker, specifies the list result which
listing should begin.
If the marker is not specified, the list result will listing
from the first one.
:type marker: string
:param max_keys
The optional parameter to specifies the max number of list
result to return.
The default value is 1000.
:type max_keys: int
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'HTTPlistener')
params = {}
if listener_port is not None:
params[b'listenerPort'] = listener_port
if marker is not None:
params[b'marker'] = marker
if max_keys is not None:
params[b'maxKeys'] = max_keys
return self._send_request(http_methods.GET, path,
params=params, config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def describe_app_https_listener(self, blb_id, listener_port=None,
marker=None, max_keys=None,
config=None):
"""
get app https listeners identified by bibID
:param blb_id
the id of blb which the listener work on
:type blb_id:string
:param listener_port
The listener port to query
:type listener_port:int
:param marker
The optional parameter marker specified in the original
request to specify where in the results to begin listing.
Together with the marker, specifies the list result which
listing should begin.
If the marker is not specified, the list result will listing
from the first one.
:type marker: string
:param max_keys
The optional parameter to specifies the max number of list
result to return.
The default value is 1000.
:type max_keys: int
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'HTTPSlistener')
params = {}
if listener_port is not None:
params[b'listenerPort'] = listener_port
if marker is not None:
params[b'marker'] = marker
if max_keys is not None:
params[b'maxKeys'] = max_keys
return self._send_request(http_methods.GET, path,
params=params, config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def describe_app_ssl_listener(self, blb_id, listener_port=None,
marker=None, max_keys=None, config=None):
"""
get app ssl listeners identified by bibID
:param blb_id
the id of blb which the listener work on
:type blb_id:string
:param listener_port
The listener port to query
:type listener_port:int
:param marker
The optional parameter marker specified in the original
request to specify where in the results to begin listing.
Together with the marker, specifies the list result which
listing should begin.
If the marker is not specified, the list result will listing
from the first one.
:type marker: string
:param max_keys
The optional parameter to specifies the max number of list
result to return.
The default value is 1000.
:type max_keys: int
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'SSLlistener')
params = {}
if listener_port is not None:
params[b'listenerPort'] = listener_port
if marker is not None:
params[b'marker'] = marker
if max_keys is not None:
params[b'maxKeys'] = max_keys
return self._send_request(http_methods.GET, path,
params=params, config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def delete_app_listeners(self, blb_id, portList,
client_token=None,
config=None):
"""
Release app listener under the specified LoadBalancer,
the listener is specified by listening to the port.
:param blb_id:
id of LoadBalancer
:type blb_id:string
:param portList:
The ports of listeners to be released
:type portList:list<int>
:param client_token:
If the clientToken is not specified by the user, a random String
generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'listener')
params = {}
params[b'batchdelete'] = None
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {}
body['portList'] = portList
return self._send_request(http_methods.PUT, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def create_policys(self, blb_id, listener_port,
app_policy_vos, client_token=None,
config=None):
"""
Create policys.
:param blb_id:
the id of blb which the listener work on
:type blb_id: string
:param listener_port:
port to be linstened owned by listener
:value 1-65535
:type listener_port: int
:param app_policy_vos
policy list the listener binds.
If the listener type is TCP,
there is only one policy
and only the full match is supported.
https://cloud.baidu.com/doc/BLB/API.html#AppPolicy
:type app_policy_vos: list<AppPolicy>
:param client_token:
If the clientToken is not specified by the user, a random String
generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'policys')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {
'listenerPort': listener_port,
'appPolicyVos': app_policy_vos
}
return self._send_request(http_methods.POST, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def describe_policys(self, blb_id, listener_port,
marker=None, max_keys=None,
config=None):
"""
get policys
:param blb_id
the id of blb which the listener work on
:type blb_id:string
:param listener_port
The listener port used by listener
:type listener_port:int
:param marker
The optional parameter marker specified in the original
request to specify where in the results to begin listing.
Together with the marker, specifies the list result which
listing should begin.
If the marker is not specified, the list result will listing
from the first one.
:type marker: string
:param max_keys
The optional parameter to specifies the max number of list
result to return.
The default value is 1000.
:type max_keys: int
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'policys')
params = {}
params[b'port'] = listener_port
if marker is not None:
params[b'marker'] = marker
if max_keys is not None:
params[b'maxKeys'] = max_keys
return self._send_request(http_methods.GET, path,
params=params, config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def delete_policys(self, blb_id, listener_port,
policys_list,
client_token=None, config=None):
"""
Release the listener under the specified LoadBalancer,
the listener is specified by listening to the port.
:param blb_id:
id of LoadBalancer
:type blb_id:string
:param listener_port
The listener port used by listener
:type listener_port:int
:param policys_list
All policy identifiers to be released
:type policys_list:list<str>
:param client_token:
If the clientToken is not specified by the user, a random String
generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'policys')
params = {}
params[b'batchdelete'] = None
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {
'port': listener_port,
'policyIdList': policys_list
}
return self._send_request(http_methods.PUT, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def create_app_server_group(self, blb_id,
name=None,
desc=None,
backend_server_list=None,
client_token=None,
config=None):
"""
create server group for the specified LoadBalancer,
support batch add
:param blb_id:
id of LoadBalancer
:type blb_id:string
:param name:
name of server group
:type name:string
:param desc:
description of server group
:type desc:string
:param backend_server_list
List of backend servers to be added
https://cloud.baidu.com/doc/BLB/API.html#AppBackendServer
:type backend_server_list:List<AppBackendServer>
:param client_token:
If the clientToken is not specified by the user, a random String
generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'appservergroup')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {}
if name is not None:
body['name'] = compat.convert_to_string(name)
if desc is not None:
body['desc'] = compat.convert_to_string(desc)
if backend_server_list is not None:
body['backendServerList'] = backend_server_list
return self._send_request(http_methods.POST, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def update_app_server_group(self, blb_id, sg_id,
name=None,
desc=None,
client_token=None,
config=None):
"""
update the information of the app server group
of the specified LoadBalancer
:param blb_id:
id of LoadBalancer
:type blb_id:string
:param sg_id:
id of the server group to be updated
:type sg_id:string
:param name:
name of server group
:type name:string
:param desc:
description of server group
:type desc:string
:param client_token:
If the clientToken is not specified by the user, a random String
generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'appservergroup')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {}
body['sgId'] = compat.convert_to_string(sg_id)
if name is not None:
body['name'] = compat.convert_to_string(name)
if desc is not None:
body['desc'] = compat.convert_to_string(desc)
return self._send_request(http_methods.PUT, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def describe_app_server_group(self, blb_id,
name=None,
exactly_match=None,
marker=None,
max_keys=None, config=None):
"""
Query the imformation of app server group
of the specified LoadBalancer
:param blb_id:
Id of LoadBalancer
:type blb_id:string
:param name:
name of server group
:type name:string
:param exactly_match:
Set whether the name matches globally
:type exactly_match:boolean
:param marker:
The optional parameter marker specified in the original
request to specify where in the results to begin listing.
Together with the marker, specifies the list result which
listing should begin. If the marker is not specified,
the list result will listing from the first one.
:type marker: string
:param max_keys:
The optional parameter to specifies the max number of
list result to return.
The default value is 1000.
:type max_keys: int
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'appservergroup')
params = {}
if name is not None:
params[b'name'] = name
if exactly_match is not None:
params[b'exactlyMatch'] = exactly_match
if marker is not None:
params[b'marker'] = marker
if max_keys is not None:
params[b'maxKeys'] = max_keys
return self._send_request(http_methods.GET, path, params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def delete_app_server_group(self, blb_id, sg_id,
client_token=None,
config=None):
"""
delete the app server group of the specified LoadBalancer,
:param blb_id:
id of LoadBalancer
:type blb_id:string
:param sg_id:
id of the server group to be updated
:type sg_id:string
:param client_token:
If the clientToken is not specified by the user,
a random String generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'appservergroup')
params = {}
params[b'delete'] = None
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {}
body['sgId'] = compat.convert_to_string(sg_id)
return self._send_request(http_methods.PUT, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def create_app_server_group_port(self, blb_id, sg_id,
port, protocol_type,
health_check=None,
health_check_port=None,
health_check_urlpath=None,
health_check_timeout_insecond=None,
health_check_interval_insecond=None,
health_check_down_retry=None,
health_check_up_retry=None,
health_check_normal_status=None,
client_token=None,
config=None):
"""
create server group for the specified LoadBalancer,
support batch add
:param blb_id:
id of LoadBalancer
:type blb_id:string
:param sg_id:
id of the server group
:type sg_id:string
:param port:
Port number, integer between 1 and 65535
:type port:string
:param protocol_type:
Protocol type of listening port, "TCP"/"UDP"/"HTTP"
:type protocol_type:string
:param health_check:
Health check protocol
:value 'HTTP' or 'TCP',default:'HTTP'
:type health_check: string
:param health_check_port:
Health check port, the default is the same as port
:type health_check_port: int
:param health_check_urlpath:
Health check URI, default '/'.
Effective when the health check protocol is "HTTP"
:type health_check_urlpath: string
:param health_check_timeout_insecond:
Health check timeout (unit: second)
:value 1-60, default: 3
:type health_check_timeout_insecond: int
:param health_check_interval_insecond:
Health check interval (unit: second)
:value 1-10, default: 3
:type health_check_interval_insecond: int
:param health_check_down_retry:
The unhealthy down retry, that is, how many consecutive health
check failures, shields the backend server.
:value 2-5, default: 3
:type health_check_down_retry: int
:param health_check_up_retry:
Health up retry, that is, how many consecutive health checks
are successful, then re-use the back-end server
:value:2-5, default: 3
:type health_check_up_retry: int
:param health_check_normal_status:
The HTTP status code when the health check is normal supports
a combination of five types of status codes,
such as "http_1xx|http_2xx", Effective when the health check
protocol is "HTTP"
:value default: http_2xx|http_3xx
:type health_check_normal_status: string
:param client_token:
If the clientToken is not specified by the user, a random String
generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'appservergroupport')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {
'sgId': compat.convert_to_string(sg_id),
'port': port,
'type': compat.convert_to_string(protocol_type)
}
if health_check is not None:
body['healthCheck'] = compat.convert_to_string(health_check)
if health_check_port is not None:
body['healthCheckPort'] = health_check_port
if health_check_urlpath is not None:
body['healthCheckUrlPath'] = \
compat.convert_to_string(health_check_urlpath)
if health_check_timeout_insecond is not None:
body['healthCheckTimeoutInSecond'] = health_check_timeout_insecond
if health_check_interval_insecond is not None:
body['healthCheckIntervalInSecond'] = health_check_interval_insecond
if health_check_down_retry is not None:
body['healthCheckDownRetry'] = health_check_down_retry
if health_check_up_retry is not None:
body['healthCheckUpRetry'] = health_check_up_retry
if health_check_normal_status is not None:
body['healthCheckNormalStatus'] = \
compat.convert_to_string(health_check_normal_status)
return self._send_request(http_methods.POST, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def update_app_server_group_port(self, blb_id, sg_id, port_id,
health_check=None,
health_check_port=None,
health_check_urlpath=None,
health_check_timeout_insecond=None,
health_check_interval_insecond=None,
health_check_down_retry=None,
health_check_up_retry=None,
health_check_normal_status=None,
client_token=None,
config=None):
"""
update server group for the specified LoadBalancer,
support batch add
:param blb_id:
id of LoadBalancer
:type blb_id:string
:param sg_id:
id of the server group
:type sg_id:string
:param port_id:
The id of the server group port to be updated
:type port_id:string
:param health_check:
Health check protocol
:value 'HTTP' or 'TCP',default:'HTTP'
:type health_check: string
:param health_check_port:
Health check port, the default is the same as port
:type health_check_port: int
:param health_check_urlpath:
Health check URI, default '/'.
Effective when the health check protocol is "HTTP"
:type health_check_urlpath: string
:param health_check_timeout_insecond:
Health check timeout (unit: second)
:value 1-60, default: 3
:type health_check_timeout_insecond: int
:param health_check_interval_insecond:
Health check interval (unit: second)
:value 1-10, default: 3
:type health_check_interval_insecond: int
:param health_check_down_retry:
The unhealthy down retry, that is, how many consecutive health
check failures, shields the backend server.
:value 2-5, default: 3
:type health_check_down_retry: int
:param health_check_up_retry:
Health up retry, that is, how many consecutive health checks
are successful, then re-use the back-end server
:value:2-5, default: 3
:type health_check_up_retry: int
:param health_check_normal_status:
The HTTP status code when the health check is normal supports
a combination of five types of status codes,
such as "http_1xx|http_2xx", Effective when the health check
protocol is "HTTP"
:value default: http_2xx|http_3xx
:type health_check_normal_status: string
:param client_token:
If the clientToken is not specified by the user, a random String
generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'appservergroupport')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {
'sgId': compat.convert_to_string(sg_id),
'portId': compat.convert_to_string(port_id)
}
if health_check is not None:
body['healthCheck'] = compat.convert_to_string(health_check)
if health_check_port is not None:
body['healthCheckPort'] = health_check_port
if health_check_urlpath is not None:
body['healthCheckUrlPath'] = \
compat.convert_to_string(health_check_urlpath)
if health_check_timeout_insecond is not None:
body['healthCheckTimeoutInSecond'] = health_check_timeout_insecond
if health_check_interval_insecond is not None:
body['healthCheckIntervalInSecond'] = health_check_interval_insecond
if health_check_down_retry is not None:
body['healthCheckDownRetry'] = health_check_down_retry
if health_check_up_retry is not None:
body['healthCheckUpRetry'] = health_check_up_retry
if health_check_normal_status is not None:
body['healthCheckNormalStatus'] = \
compat.convert_to_string(health_check_normal_status)
return self._send_request(http_methods.PUT, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def delete_app_server_group_port(self, blb_id, sg_id,
port_list,
client_token=None, config=None):
"""
delete server group of the specified LoadBalancer,
:param blb_id:
id of LoadBalancer
:type blb_id:string
:param sg_id:
id of the server group
:type sg_id:string
:param port_list:
The ports of listeners to be released
:type port_list:list<string>
:param client_token:
If the clientToken is not specified by the user, a random String
generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'appservergroupport')
params = {}
params[b'batchdelete'] = None
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {
'sgId': compat.convert_to_string(sg_id),
'portIdList': port_list
}
return self._send_request(http_methods.PUT, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def create_app_blb_rs(self, blb_id, sg_id,
backend_server_list,
client_token=None,
config=None):
"""
Add backend server for the specified LoadBalancer and server group,
support batch add
:param blb_id:
id of LoadBalancer
:type blb_id:string
:param sg_id:
id of the server group
:type sg_id:string
:param backend_server_list
List of backend servers to be added
https://cloud.baidu.com/doc/BLB/API.html#AppBackendServer
:type backend_server_list:List<AppBackendServer>
:param client_token:
If the clientToken is not specified by the user, a random String
generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'blbrs')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {
'sgId': compat.convert_to_string(sg_id),
'backendServerList': backend_server_list
}
return self._send_request(http_methods.POST, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def update_app_blb_rs(self, blb_id, sg_id,
backend_server_list,
client_token=None,
config=None):
"""
update backend server for the specified LoadBalancer and server group,
support batch update
:param blb_id:
id of LoadBalancer
:type blb_id:string
:param sg_id:
id of the server group
:type sg_id:string
:param backend_server_list
List of backend servers to be added
https://cloud.baidu.com/doc/BLB/API.html#AppBackendServer
:type backend_server_list:List<AppBackendServer>
:param client_token:
If the clientToken is not specified by the user, a random String
generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'blbrs')
params = {}
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {
'sgId': compat.convert_to_string(sg_id),
'backendServerList': backend_server_list
}
return self._send_request(http_methods.PUT, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def describe_app_blb_rs(self, blb_id, sg_id,
marker=None, max_keys=None,
config=None):
"""
Query the list of backend servers under the specified LoadBalancer
and server group
:param blb_id:
Id of LoadBalancer
:type blb_id:string
:param sg_id:
id of the server group
:type sg_id:string
:param marker:
The optional parameter marker specified in the original
request to specify where in the results to begin listing.
Together with the marker, specifies the list result which
listing should begin. If the marker is not specified,
the list result will listing from the first one.
:type marker: string
:param max_keys:
The optional parameter to specifies the max number of
list result to return.
The default value is 1000.
:type max_keys: int
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'blbrs')
params = {}
params[b'sgId'] = compat.convert_to_string(sg_id)
if marker is not None:
params[b'marker'] = marker
if max_keys is not None:
params[b'maxKeys'] = max_keys
return self._send_request(http_methods.GET, path, params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def delete_app_blb_rs(self, blb_id, sg_id,
backend_server_list,
client_token=None,
config=None):
"""
delete backend server for the specified LoadBalancer and server group,
support batch delete
:param blb_id:
id of LoadBalancer
:type blb_id:string
:param sg_id:
id of the server group
:type sg_id:string
:param backend_server_list
List of backend servers to be deleted
:type backend_server_list:List<string>
:param client_token:
If the clientToken is not specified by the user, a random String
generated by default algorithm will be used.
:type client_token: string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'blbrs')
params = {}
params[b'batchdelete'] = None
if client_token is None:
params[b'clientToken'] = generate_client_token()
else:
params[b'clientToken'] = client_token
body = {
'sgId': compat.convert_to_string(sg_id),
'backendServerIdList': backend_server_list
}
return self._send_request(http_methods.PUT, path,
body=json.dumps(body), params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def describe_rs_mount(self, blb_id, sg_id, config=None):
"""
describe servers of specific server group
:param blb_id:
id of LoadBalancer
:type blb_id:string
:param sg_id:
id of the server group
:type sg_id:string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'blbrsmount')
params = {
'sgId': compat.convert_to_string(sg_id)
}
return self._send_request(http_methods.GET, path, params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def describe_rs_unmount(self, blb_id, sg_id, config=None):
"""
describe servers of specific server group
:param blb_id:
id of LoadBalancer
:type blb_id:string
:param sg_id:
id of the server group
:type sg_id:string
:param config:
:type config: baidubce.BceClientConfiguration
:return:
:rtype baidubce.bce_response.BceResponse
"""
path = utils.append_uri(self.version, 'appblb', blb_id, 'blbrsunmount')
params = {
'sgId': compat.convert_to_string(sg_id)
}
return self._send_request(http_methods.GET, path, params=params,
config=config) | baidubce/bce-sdk-python | [
21,
10,
21,
4,
1429591184
] |
def get_current_namespace():
"""Returns current namespace if available, else kubeflow"""
try:
current_namespace = open(
"/var/run/secrets/kubernetes.io/serviceaccount/namespace"
).read()
except:
current_namespace = "kubeflow"
return current_namespace | kubeflow/pipelines | [
3125,
1400,
3125,
892,
1526085107
] |
def mnist_train(
namespace: str = get_current_namespace(),
worker_replicas: int = 1,
ttl_seconds_after_finished: int = -1,
job_timeout_minutes: int = 600,
delete_after_done: bool = False, | kubeflow/pipelines | [
3125,
1400,
3125,
892,
1526085107
] |
def __init__(self):
super(MainProgram, self).__init__() | StratusLab/client | [
2,
1,
2,
1,
1335119615
] |
def checkOptions(self):
super(MainProgram, self).checkOptions()
if not self.uuids:
printError('Please provide at least one persistent disk UUID to detach')
if self.options.instance < 0:
printError('Please provide a VM ID on which to detach disk')
try:
self._retrieveVmNode()
except OneException, e:
printError(e) | StratusLab/client | [
2,
1,
2,
1,
1335119615
] |
def doWork(self):
configHolder = ConfigHolder(self.options.__dict__, self.config or {})
configHolder.pdiskProtocol = "https"
pdisk = VolumeManagerFactory.create(configHolder)
for uuid in self.uuids:
try:
target = pdisk.hotDetach(self.options.instance, uuid)
print 'DETACHED %s from VM %s on /dev/%s' % (uuid, self.options.instance, target)
except Exception, e:
printError('DISK %s: %s' % (uuid, e), exit=False) | StratusLab/client | [
2,
1,
2,
1,
1335119615
] |
def parse_output(lines):
results = {}
results['succeeded'] = True
seen_header = False
streams = {}
dest_ip = None
dest_port = None
src_ip = None
src_port = None
for line in lines:
# ignore bogus sessions
if re.match('\(nan%\)', line):
results["succeeded"] = False
results["error"] = "Found NaN result";
break;
if re.match('read failed: Connection refused', line):
results["succeeded"] = False
results["error"] = "Connection refused"
break
test = re.match('local ([^ ]+) port (\d+) connected with ([^ ]+) port (\d+)', line)
if test:
dest_ip = test.group(1)
dest_port = test.group(2)
src_ip = test.group(3)
src_port = test.group(4)
# Example lines
# TCP window size: 244 KByte (WARNING: requested 64.0 MByte)
# TCP window size: 19800 Byte (default)
test = re.match('TCP window size:\s+(\d+(\.\d+)?) (\S)?Byte(.*\(WARNING:\s+requested\s+(\d+(\.\d+)?) (\S)?Byte)?', line)
if test:
window_size = test.group(1)
window_si = test.group(3)
request_size = test.group(5)
request_si = test.group(7)
if window_si:
window_size = pscheduler.si_as_number("%s%s" % (window_size, window_si))
if request_size:
if request_si:
request_size = pscheduler.si_as_number("%s%s" % (request_size, request_si))
results["requested-tcp-window-size"] = int(request_size)
results["tcp-window-size"] = int(window_size)
# Example line
# [ 3] MSS size 1448 bytes (MTU 1500 bytes, ethernet)
test = re.match('.*MSS size (\d+) bytes \(MTU (\d+) bytes', line)
if test:
results['mss'] = int(test.group(1))
results['mtu'] = int(test.group(2))
stream_id = None
interval_start = None
throughput_bytes = None
si_bytes = None
throughput_bits = None
si_bits = None
jitter = None
lost = None
sent = None
# Example line
# [ 3] 16.0-17.0 sec 37355520 Bytes 298844160 bits/sec
test = re.match('\[\s*(\d+|SUM)\s*\]\s+([0-9\.]+)\s*\-\s*([0-9\.]+)\s+sec\s+(\d+(\.\d+)?)\s+(P|T|G|M|K)?Bytes\s+(\d+(\.\d+)?)\s+(P|T|G|M|K)?bits\/sec(\s+([0-9\.]+)\s+ms\s+(\d+)\/\s*(\d+)\s+)?', line)
if test:
stream_id = test.group(1)
interval_start = float(test.group(2))
interval_end = float(test.group(3))
throughput_bytes = float(test.group(4))
si_bytes = test.group(6)
throughput_bits = float(test.group(7))
si_bits = test.group(9) | perfsonar/pscheduler | [
45,
31,
45,
115,
1452259533
] |
def logpmf(k, p, loc=0):
k, p, loc = jnp._promote_args_inexact("geom.logpmf", k, p, loc)
zero = _lax_const(k, 0)
one = _lax_const(k, 1)
x = lax.sub(k, loc)
log_probs = xlog1py(lax.sub(x, one), -p) + lax.log(p)
return jnp.where(lax.le(x, zero), -jnp.inf, log_probs) | google/jax | [
22193,
2080,
22193,
1296,
1540502702
] |
def silence_tf_error_messages(func):
"""Decorator that temporarily changes the TF logging levels."""
def wrapper(*args, **kwargs):
cur_verbosity = tf.compat.v1.logging.get_verbosity()
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.FATAL)
func(*args, **kwargs)
tf.compat.v1.logging.set_verbosity(cur_verbosity) # Reset verbosity.
return wrapper | google-research/federated | [
505,
161,
505,
11,
1600124947
] |
def test_sum_no_noise(self):
with self.cached_session() as sess:
record1 = tf.constant([2, 0], dtype=tf.int32)
record2 = tf.constant([-1, 1], dtype=tf.int32)
query = ddg_sum_query(l2_norm_bound=10, local_scale=0.0)
query_result, _ = test_utils.run_query(query, [record1, record2])
result = sess.run(query_result)
expected = [1, 1]
self.assertAllEqual(result, expected) | google-research/federated | [
505,
161,
505,
11,
1600124947
] |
def test_sum_multiple_shapes(self, sample_size):
with self.cached_session() as sess:
t1 = tf.constant([2, 0], dtype=tf.int32)
t2 = tf.constant([-1, 1, 3], dtype=tf.int32)
t3 = tf.constant([-2], dtype=tf.int32)
record = [t1, t2, t3]
sample = [record] * sample_size
query = ddg_sum_query(l2_norm_bound=10, local_scale=0.0)
query_result, _ = test_utils.run_query(query, sample)
expected = [sample_size * t1, sample_size * t2, sample_size * t3]
result, expected = sess.run([query_result, expected])
# Use `assertAllClose` for nested structures equality (with tolerance=0).
self.assertAllClose(result, expected, atol=0) | google-research/federated | [
505,
161,
505,
11,
1600124947
] |
def test_sum_nested_record_structure(self, sample_size):
with self.cached_session() as sess:
t1 = tf.constant([1, 0], dtype=tf.int32)
t2 = tf.constant([1, 1, 1], dtype=tf.int32)
t3 = tf.constant([1], dtype=tf.int32)
t4 = tf.constant([[1, 1], [1, 1]], dtype=tf.int32)
record = [t1, dict(a=t2, b=[t3, (t4, t1)])]
sample = [record] * sample_size
query = ddg_sum_query(l2_norm_bound=10, local_scale=0.0)
query_result, _ = test_utils.run_query(query, sample)
result = sess.run(query_result)
s = sample_size
expected = [t1 * s, dict(a=t2 * s, b=[t3 * s, (t4 * s, t1 * s)])]
# Use `assertAllClose` for nested structures equality (with tolerance=0)
self.assertAllClose(result, expected, atol=0) | google-research/federated | [
505,
161,
505,
11,
1600124947
] |
def test_sum_raise_on_l2_norm_excess(self, l2_norm_bound):
with self.cached_session() as sess:
record = tf.constant([10, 10], dtype=tf.int32)
query = ddg_sum_query(l2_norm_bound=l2_norm_bound, local_scale=0.0)
with self.assertRaises(tf.errors.InvalidArgumentError):
query_result, _ = test_utils.run_query(query, [record])
sess.run(query_result) | google-research/federated | [
505,
161,
505,
11,
1600124947
] |
def test_sum_local_noise_shares(self, local_scale, num_records):
"""Test the noise level of the sum of discrete Gaussians applied locally.
The sum of discrete Gaussians is not a discrete Gaussian, but it will be
extremely close for sigma >= 2. We will thus compare the aggregated noise
to a central discrete Gaussian noise with appropriately scaled stddev with
some reasonable tolerance.
Args:
local_scale: The stddev of the local discrete Gaussian noise.
num_records: The number of records to be aggregated.
"""
# Aggregated local noises.
num_trials = 1000
record = tf.zeros([num_trials], dtype=tf.int32)
sample = [record] * num_records
query = ddg_sum_query(l2_norm_bound=10.0, local_scale=local_scale)
query_result, _ = test_utils.run_query(query, sample)
# Central discrete Gaussian noise.
central_scale = np.sqrt(num_records) * local_scale
central_noise = discrete_gaussian_utils.sample_discrete_gaussian(
scale=tf.cast(tf.round(central_scale), record.dtype),
shape=tf.shape(record),
dtype=record.dtype)
agg_noise, central_noise = self.evaluate([query_result, central_noise])
mean_stddev = central_scale * np.sqrt(num_trials) / num_trials
atol = 3.5 * mean_stddev
# Use the atol for mean as a rough default atol for stddev/percentile.
self.assertAllClose(np.mean(agg_noise), np.mean(central_noise), atol=atol)
self.assertAllClose(np.std(agg_noise), np.std(central_noise), atol=atol)
self.assertAllClose(
np.percentile(agg_noise, [25, 50, 75]),
np.percentile(central_noise, [25, 50, 75]),
atol=atol) | google-research/federated | [
505,
161,
505,
11,
1600124947
] |
def test_ascii(self):
self.assertEqual("abc".encode("ascii", errors="surrogatepass"), b"abc")
self.assertEqual(b"abc".decode("ascii", errors="surrogatepass"), "abc") | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def test_utf_8(self):
self.assertEqual("abc\ud810xyz".encode("utf_8", errors="surrogatepass"), b"abc\xed\xa0\x90xyz")
self.assertEqual(b"abc\xed\xa0\x90xyz".decode("utf_8", errors="surrogatepass"), "abc\ud810xyz") | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def test_utf_16_be(self):
# lone high surrogate
self.assertEqual("\ud810".encode("utf_16_be", errors="surrogatepass"), b"\xd8\x10")
self.assertEqual(b"\xd8\x10".decode("utf_16_be", errors="surrogatepass"), "\ud810")
#lone low surrogate
self.assertEqual("\udc0a".encode("utf_16_be", errors="surrogatepass"), b"\xdc\n")
self.assertEqual(b"\xdc\n".decode("utf_16_be", errors="surrogatepass"), "\udc0a") | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def test_utf_32_le(self):
# lone high surrogate
self.assertEqual("\ud810".encode("utf_32_le", errors="surrogatepass"), b"\x10\xd8\x00\x00")
self.assertEqual(b"\x10\xd8\x00\x00".decode("utf_32_le", errors="surrogatepass"), "\ud810")
#lone low surrogate
self.assertEqual("\udc0a".encode("utf_32_le", errors="surrogatepass"), b"\n\xdc\x00\x00")
self.assertEqual(b"\n\xdc\x00\x00".decode("utf_32_le", errors="surrogatepass"), "\udc0a") | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def test_utf_32_be(self):
# lone high surrogate
self.assertEqual("\ud810".encode("utf_32_be", errors="surrogatepass"), b"\x00\x00\xd8\x10")
self.assertEqual(b"\x00\x00\xd8\x10".decode("utf_32_be", errors="surrogatepass"), "\ud810")
#lone low surrogate
self.assertEqual("\udc0a".encode("utf_32_be", errors="surrogatepass"), b"\x00\x00\xdc\n")
self.assertEqual(b"\x00\x00\xdc\n".decode("utf_32_be", errors="surrogatepass"), "\udc0a") | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def setUp(self):
self.set_filename('unicode_shift_jis.xlsx')
self.set_text_file('unicode_shift_jis.txt') | jmcnamara/XlsxWriter | [
3172,
594,
3172,
18,
1357261626
] |
def index_to_dict(instance):
keys = ('identifier', 'referenced_type', 'referenced_id', 'relationship')
return {k: str(getattr(instance, k)) for k in keys} | dimagi/commcare-hq | [
465,
201,
465,
202,
1247158807
] |
def setUp(self):
super(CaseClaimTests, self).setUp()
self.domain = create_domain(DOMAIN)
self.user = CommCareUser.create(DOMAIN, USERNAME, PASSWORD, None, None)
self.restore_user = get_restore_user(DOMAIN, self.user, None)
self.host_case_id = uuid4().hex
self.host_case_name = 'Dmitri Bashkirov'
self.host_case_type = 'person'
self.create_case() | dimagi/commcare-hq | [
465,
201,
465,
202,
1247158807
] |
def create_case(self):
case_block = CaseBlock.deprecated_init(
create=True,
case_id=self.host_case_id,
case_name=self.host_case_name,
case_type=self.host_case_type,
owner_id='in_soviet_russia_the_case_owns_you',
).as_xml()
post_case_blocks([case_block], {'domain': DOMAIN}) | dimagi/commcare-hq | [
465,
201,
465,
202,
1247158807
] |
def test_claim_case(self):
"""
claim_case should create an extension case
"""
claim_id = claim_case(DOMAIN, self.restore_user, self.host_case_id,
host_type=self.host_case_type, host_name=self.host_case_name)
self.assert_claim(claim_id=claim_id) | dimagi/commcare-hq | [
465,
201,
465,
202,
1247158807
] |
def test_first_claim_one(self):
"""
get_first_claim should return one claim
"""
claim_id = claim_case(DOMAIN, self.restore_user, self.host_case_id,
host_type=self.host_case_type, host_name=self.host_case_name)
claim = get_first_claim(DOMAIN, self.user.user_id, self.host_case_id)
self.assert_claim(claim, claim_id) | dimagi/commcare-hq | [
465,
201,
465,
202,
1247158807
] |
def test_closed_claim(self):
"""
get_first_claim should return None if claim case is closed
"""
claim_id = claim_case(DOMAIN, self.restore_user, self.host_case_id,
host_type=self.host_case_type, host_name=self.host_case_name)
self._close_case(claim_id)
first_claim = get_first_claim(DOMAIN, self.user.user_id, self.host_case_id)
self.assertIsNone(first_claim) | dimagi/commcare-hq | [
465,
201,
465,
202,
1247158807
] |
def test_call_agg():
primitive = Max()
# the assert is run twice on purpose
for _ in range(2):
assert 5 == primitive(range(6)) | Featuretools/featuretools | [
6538,
841,
6538,
165,
1504908917
] |
def test_uses_calc_time():
primitive = TimeSinceLast()
primitive_h = TimeSinceLast(unit="hours")
datetimes = pd.Series([datetime(2015, 6, 6), datetime(2015, 6, 7)])
answer = 86400.0
answer_h = 24.0
assert answer == primitive(datetimes, time=datetime(2015, 6, 8))
assert answer_h == primitive_h(datetimes, time=datetime(2015, 6, 8)) | Featuretools/featuretools | [
6538,
841,
6538,
165,
1504908917
] |
def test_get_function_called_once():
class TestPrimitive(TransformPrimitive):
def __init__(self):
self.get_function_call_count = 0
def get_function(self):
self.get_function_call_count += 1
def test(x):
return x
return test
primitive = TestPrimitive()
for _ in range(2):
primitive(range(6))
assert primitive.get_function_call_count == 1 | Featuretools/featuretools | [
6538,
841,
6538,
165,
1504908917
] |
def __init__(self, bool=True, int=0, float=None):
self.bool = bool
self.int = int
self.float = float | Featuretools/featuretools | [
6538,
841,
6538,
165,
1504908917
] |
def test_single_args_string():
assert IsIn([1, 2, 3]).get_args_string() == ', list_of_outputs=[1, 2, 3]' | Featuretools/featuretools | [
6538,
841,
6538,
165,
1504908917
] |
def test_args_string_mixed():
class Primitive(TransformPrimitive):
def __init__(self, bool=True, int=0, float=None):
self.bool = bool
self.int = int
self.float = float
primitive = Primitive(bool=False, int=0)
string = primitive.get_args_string()
assert string == ', bool=False' | Featuretools/featuretools | [
6538,
841,
6538,
165,
1504908917
] |
def testMapFileLine(self):
self.assertTrue(unpack_pak.ParseLine(' {"path.js", IDR_PATH}')) | endlessm/chromium-browser | [
21,
16,
21,
3,
1435959644
] |
def testGetFileAndDirName(self):
(f, d) = unpack_pak.GetFileAndDirName(
'out/build/gen/foo/foo.unpak', 'out/build/gen/foo', 'a/b.js')
self.assertEquals('b.js', f)
self.assertEquals('out/build/gen/foo/foo.unpak/a', d) | endlessm/chromium-browser | [
21,
16,
21,
3,
1435959644
] |
def create(kernel):
result = Tangible()
result.template = "object/tangible/wearables/armor/padded/shared_armor_padded_s01_gloves.iff"
result.attribute_template_id = 0
result.stfName("wearables_name","armor_padded_s01_gloves") | anhstudios/swganh | [
62,
37,
62,
37,
1297996365
] |
def color_name(self):
return self.random_element(self.all_colors.keys()) | deanishe/alfred-fakeum | [
283,
20,
283,
6,
1419863299
] |
def hex_color(self):
return "#{0}".format(
("%x" %
self.random_int(
1, 16777215)).ljust(
6, '0')) | deanishe/alfred-fakeum | [
283,
20,
283,
6,
1419863299
] |
def rgb_color(self):
return ','.join(map(str, (self.random_int(0, 255) for _ in range(3)))) | deanishe/alfred-fakeum | [
283,
20,
283,
6,
1419863299
] |
def create(kernel):
result = Building()
result.template = "object/building/player/shared_player_house_naboo_medium_style_01.iff"
result.attribute_template_id = -1
result.stfName("building_name","housing_naboo_medium") | anhstudios/swganh | [
62,
37,
62,
37,
1297996365
] |
def create(kernel):
result = Creature()
result.template = "object/mobile/shared_dressed_doak_sif.iff"
result.attribute_template_id = 9
result.stfName("npc_name","human_base_male") | anhstudios/swganh | [
62,
37,
62,
37,
1297996365
] |
def create(kernel):
result = Tangible()
result.template = "object/tangible/component/droid/shared_binary_load_lifter_droid_chassis.iff"
result.attribute_template_id = -1
result.stfName("craft_droid_ingredients_n","binary_load_lifter_droid_chassis") | anhstudios/swganh | [
62,
37,
62,
37,
1297996365
] |
def main(log_file, test_suite):
worker_test_dict = {}
with open(log_file, 'r') as console_file:
for line in console_file:
regex_search = re.search(fr'\[gw(\d+)] (PASSED|FAILED|SKIPPED|ERROR) (\S+)', line)
if regex_search:
worker_num_string = regex_search.group(1)
if worker_num_string not in worker_test_dict:
worker_test_dict[worker_num_string] = []
test = regex_search.group(3)
if test_suite == "commonlib-unit":
if "pavelib" not in test and not test.startswith('scripts'):
test = f"common/lib/{test}"
worker_test_dict[worker_num_string].append(test)
output_folder_name = "worker_list_files"
if os.path.isdir(output_folder_name):
shutil.rmtree(output_folder_name)
os.mkdir(output_folder_name)
for worker_num in worker_test_dict:
output_file_name = f"{output_folder_name}/{test_suite}_gw{worker_num}_test_list.txt"
with open(output_file_name, 'w') as output_file:
for line in worker_test_dict[worker_num]:
output_file.write(line + "\n") | eduNEXT/edunext-platform | [
28,
7,
28,
10,
1414072000
] |
def upgrade():
with op.batch_alter_table("slices") as batch_op:
batch_op.add_column(sa.Column("certified_by", sa.Text(), nullable=True))
batch_op.add_column(
sa.Column("certification_details", sa.Text(), nullable=True)
) | apache/incubator-superset | [
50904,
10257,
50904,
1280,
1437504934
] |
def setUp(self):
super().setUp()
for record in (1, 2, 3):
# This will store into CSMHE via the post_save signal
csm = StudentModuleFactory.create(
module_state_key=LOCATION('usage_id'),
course_id=COURSE_KEY,
state=json.dumps({'type': 'csmhe', 'order': record}),
)
# This manually gets us a CSMH record to compare
csmh = StudentModuleHistory(student_module=csm,
version=None,
created=csm.modified,
state=json.dumps({'type': 'csmh', 'order': record}),
grade=csm.grade,
max_grade=csm.max_grade)
csmh.save() | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def test_get_history_true_true(self):
student_module = StudentModule.objects.all()
history = BaseStudentModuleHistory.get_history(student_module)
assert len(history) == 6
assert {'type': 'csmhe', 'order': 3} == json.loads(history[0].state)
assert {'type': 'csmhe', 'order': 2} == json.loads(history[1].state)
assert {'type': 'csmhe', 'order': 1} == json.loads(history[2].state)
assert {'type': 'csmh', 'order': 3} == json.loads(history[3].state)
assert {'type': 'csmh', 'order': 2} == json.loads(history[4].state)
assert {'type': 'csmh', 'order': 1} == json.loads(history[5].state) | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def test_get_history_true_false(self):
student_module = StudentModule.objects.all()
history = BaseStudentModuleHistory.get_history(student_module)
assert len(history) == 3
assert {'type': 'csmhe', 'order': 3} == json.loads(history[0].state)
assert {'type': 'csmhe', 'order': 2} == json.loads(history[1].state)
assert {'type': 'csmhe', 'order': 1} == json.loads(history[2].state) | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def test_get_history_false_true(self):
student_module = StudentModule.objects.all()
history = BaseStudentModuleHistory.get_history(student_module)
assert len(history) == 3
assert {'type': 'csmh', 'order': 3} == json.loads(history[0].state)
assert {'type': 'csmh', 'order': 2} == json.loads(history[1].state)
assert {'type': 'csmh', 'order': 1} == json.loads(history[2].state) | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def pytest_configure(config):
# register the capabilities marker
config.addinivalue_line(
"markers",
"capabilities: mark test to use capabilities"
) | nwjs/chromium.src | [
136,
133,
136,
45,
1453904223
] |
def capabilities():
"""Default capabilities to use for a new WebDriver session."""
return {} | nwjs/chromium.src | [
136,
133,
136,
45,
1453904223
] |
def event_loop():
"""Change event_loop fixture to global."""
global _event_loop
if _event_loop is None:
_event_loop = asyncio.get_event_loop_policy().new_event_loop()
return _event_loop | nwjs/chromium.src | [
136,
133,
136,
45,
1453904223
] |
def http(configuration):
return HTTPRequest(configuration["host"], configuration["port"]) | nwjs/chromium.src | [
136,
133,
136,
45,
1453904223
] |
def server_config():
with open(os.environ.get("WD_SERVER_CONFIG_FILE"), "r") as f:
return json.load(f) | nwjs/chromium.src | [
136,
133,
136,
45,
1453904223
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.