INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Check the token and raise an oauth. Error exception if invalid.
def validate_token(self, request, consumer, token): """ Check the token and raise an `oauth.Error` exception if invalid. """ oauth_server, oauth_request = oauth_provider.utils.initialize_server_request(request) oauth_server.verify_request(oauth_request, consumer, token)
Checks nonce of request and return True if valid.
def check_nonce(self, request, oauth_request): """ Checks nonce of request, and return True if valid. """ oauth_nonce = oauth_request['oauth_nonce'] oauth_timestamp = oauth_request['oauth_timestamp'] return check_nonce(request, oauth_request, oauth_nonce, oauth_timestamp)
Returns two - tuple of ( user token ) if authentication succeeds or None otherwise.
def authenticate(self, request): """ Returns two-tuple of (user, token) if authentication succeeds, or None otherwise. """ auth = get_authorization_header(request).split() if len(auth) == 1: msg = 'Invalid bearer header. No credentials provided.' ...
用SHA1算法生成安全签名
def getSHA1(self, token, timestamp, nonce, encrypt): """用SHA1算法生成安全签名 @param token: 票据 @param timestamp: 时间戳 @param encrypt: 密文 @param nonce: 随机字符串 @return: 安全签名 """ try: sortlist = [token, timestamp, nonce, encrypt] sortlist.sort(...
提取出xml数据包中的加密消息
def extract(self, xmltext): """提取出xml数据包中的加密消息 @param xmltext: 待提取的xml字符串 @return: 提取出的加密消息字符串 """ try: xml_tree = ET.fromstring(xmltext) encrypt = xml_tree.find("Encrypt") touser_name = xml_tree.find("ToUserName") if touser_name !=...
生成xml消息
def generate(self, encrypt, signature, timestamp, nonce): """生成xml消息 @param encrypt: 加密后的消息密文 @param signature: 安全签名 @param timestamp: 时间戳 @param nonce: 随机字符串 @return: 生成的xml字符串 """ resp_dict = { 'msg_encrypt': encrypt, 'msg_signatu...
对需要加密的明文进行填充补位
def encode(self, text): """ 对需要加密的明文进行填充补位 @param text: 需要进行填充补位操作的明文 @return: 补齐明文字符串 """ text_length = len(text) # 计算需要填充的位数 amount_to_pad = self.block_size - (text_length % self.block_size) if amount_to_pad == 0: amount_to_pad = self.block_s...
删除解密后明文的补位字符
def decode(self, decrypted): """删除解密后明文的补位字符 @param decrypted: 解密后的明文 @return: 删除补位字符后的明文 """ pad = ord(decrypted[-1]) if pad < 1 or pad > 32: pad = 0 return decrypted[:-pad]
对明文进行加密
def encrypt(self, text, appid): """对明文进行加密 @param text: 需要加密的明文 @return: 加密得到的字符串 """ # 16位随机字符串添加到明文开头 text = self.get_random_str() + struct.pack( "I", socket.htonl(len(text))) + text + appid # 使用自定义的填充方式对明文进行补位填充 pkcs7 = PKCS7Encoder() ...
对解密后的明文进行补位删除
def decrypt(self, text, appid): """对解密后的明文进行补位删除 @param text: 密文 @return: 删除填充补位后的明文 """ try: cryptor = AES.new(self.key, self.mode, self.key[:16]) # 使用BASE64对密文进行解码,然后AES-CBC解密 plain_text = cryptor.decrypt(base64.b64decode(text)) excep...
随机生成16位字符串
def get_random_str(self): """ 随机生成16位字符串 @return: 16位字符串 """ rule = string.letters + string.digits str = random.sample(rule, 16) return "".join(str)
Get delivery log from Redis
def deliveries(self): """ Get delivery log from Redis""" key = make_key( event=self.object.event, owner_name=self.object.owner.username, identifier=self.object.identifier ) return redis.lrange(key, 0, 20)
Get the possible events from settings
def event_choices(events): """ Get the possible events from settings """ if events is None: msg = "Please add some events in settings.WEBHOOK_EVENTS." raise ImproperlyConfigured(msg) try: choices = [(x, x) for x in events] except TypeError: """ Not a valid iterator, so we...
This is an asynchronous sender callable that uses the Django ORM to store webhooks. Redis is used to handle the message queue.
def worker(wrapped, dkwargs, hash_value=None, *args, **kwargs): """ This is an asynchronous sender callable that uses the Django ORM to store webhooks. Redis is used to handle the message queue. dkwargs argument requires the following key/values: :event: A string representi...
TODO: Add code to lpush to redis stack rpop when stack hits size X
def notify(self, message): """ TODO: Add code to lpush to redis stack rpop when stack hits size 'X' """ data = dict( payload=self.payload, attempt=self.attempt, success=self.success, response_message=...
Encodes data to slip protocol and then sends over serial port
def send(self, msg): """Encodes data to slip protocol and then sends over serial port Uses the SlipLib module to convert the message data into SLIP format. The message is then sent over the serial port opened with the instance of the Faraday class used when invoking send(). Arg...
Reads in data from a serial port ( length bytes ) decodes SLIP packets
def receive(self, length): """Reads in data from a serial port (length bytes), decodes SLIP packets A function which reads from the serial port and then uses the SlipLib module to decode the SLIP protocol packets. Each message received is added to a receive buffer in SlipLib which is th...
Checks the TUN adapter for data and returns any that is found.
def checkTUN(self): """ Checks the TUN adapter for data and returns any that is found. Returns: packet: Data read from the TUN adapter """ packet = self._TUN._tun.read(self._TUN._tun.mtu) return(packet)
Monitors the TUN adapter and sends data over serial port.
def monitorTUN(self): """ Monitors the TUN adapter and sends data over serial port. Returns: ret: Number of bytes sent over serial port """ packet = self.checkTUN() if packet: try: # TODO Do I need to strip off [4:] before sending...
Check the serial port for data to write to the TUN adapter.
def checkSerial(self): """ Check the serial port for data to write to the TUN adapter. """ for item in self.rxSerial(self._TUN._tun.mtu): # print("about to send: {0}".format(item)) try: self._TUN._tun.write(item) except pytun.Error as e...
Wrapper function for TUN and serial port monitoring
def run(self): """ Wrapper function for TUN and serial port monitoring Wraps the necessary functions to loop over until self._isRunning threading.Event() is set(). This checks for data on the TUN/serial interfaces and then sends data over the appropriate interface. This ...
Helper function to generate formsets for add/ change_view.
def _create_formsets(self, request, obj, change, index, is_template): "Helper function to generate formsets for add/change_view." formsets = [] inline_instances = [] prefixes = defaultdict(int) get_formsets_args = [request] if change: get_formsets_args.append(...
Get the field settings if the configured setting is a string try to get a profile from the global config.
def get_field_settings(self): """ Get the field settings, if the configured setting is a string try to get a 'profile' from the global config. """ field_settings = None if self.field_settings: if isinstance(self.field_settings, six.string_types): ...
Pass the submitted value through the sanitizer before returning it.
def value_from_datadict(self, *args, **kwargs): """ Pass the submitted value through the sanitizer before returning it. """ value = super(RichTextWidget, self).value_from_datadict( *args, **kwargs) if value is not None: value = self.get_sanitizer()(value) ...
Get the field sanitizer.
def get_sanitizer(self): """ Get the field sanitizer. The priority is the first defined in the following order: - A sanitizer provided to the widget. - Profile (field settings) specific sanitizer, if defined in settings. - Global sanitizer defined in settings. - ...
Maxheap version of a heappop.
def heappop_max(heap): """Maxheap version of a heappop.""" lastelt = heap.pop() # raises appropriate IndexError if heap is empty if heap: returnitem = heap[0] heap[0] = lastelt _siftup_max(heap, 0) return returnitem return lastelt
Maxheap version of a heappop followed by a heappush.
def heapreplace_max(heap, item): """Maxheap version of a heappop followed by a heappush.""" returnitem = heap[0] # raises appropriate IndexError if heap is empty heap[0] = item _siftup_max(heap, 0) return returnitem
Push item onto heap maintaining the heap invariant.
def heappush_max(heap, item): """Push item onto heap, maintaining the heap invariant.""" heap.append(item) _siftdown_max(heap, 0, len(heap) - 1)
Fast version of a heappush followed by a heappop.
def heappushpop_max(heap, item): """Fast version of a heappush followed by a heappop.""" if heap and heap[0] > item: # if item >= heap[0], it will be popped immediately after pushed item, heap[0] = heap[0], item _siftup_max(heap, 0) return item
Decorator to validate responses from QTM
def validate_response(expected_responses): """ Decorator to validate responses from QTM """ def internal_decorator(function): @wraps(function) async def wrapper(*args, **kwargs): response = await function(*args, **kwargs) for expected_response in expected_responses: ...
Async function to connect to QTM
async def connect( host, port=22223, version="1.19", on_event=None, on_disconnect=None, timeout=5, loop=None, ) -> QRTConnection: """Async function to connect to QTM :param host: Address of the computer running QTM. :param port: Port number to connect to, should be the port conf...
Get the QTM version.
async def qtm_version(self): """Get the QTM version. """ return await asyncio.wait_for( self._protocol.send_command("qtmversion"), timeout=self._timeout )
Get the byte order used when communicating ( should only ever be little endian using this library ).
async def byte_order(self): """Get the byte order used when communicating (should only ever be little endian using this library). """ return await asyncio.wait_for( self._protocol.send_command("byteorder"), timeout=self._timeout )
Get the latest state change of QTM. If the: func: ~qtm. connect on_event callback was set the callback will be called as well.
async def get_state(self): """Get the latest state change of QTM. If the :func:`~qtm.connect` on_event callback was set the callback will be called as well. :rtype: A :class:`qtm.QRTEvent` """ await self._protocol.send_command("getstate", callback=False) return await sel...
Wait for an event from QTM.
async def await_event(self, event=None, timeout=30): """Wait for an event from QTM. :param event: A :class:`qtm.QRTEvent` to wait for a specific event. Otherwise wait for any event. :param timeout: Max time to wait for event. :rtype: A :class:`qtm.QRTEvent` """ ...
Get the settings for the requested component ( s ) of QTM in XML format.
async def get_parameters(self, parameters=None): """Get the settings for the requested component(s) of QTM in XML format. :param parameters: A list of parameters to request. Could be 'all' or any combination of 'general', '3d', '6d', 'analog', 'force', 'gazevector', 'image'. ...
Get measured values from QTM for a single frame.
async def get_current_frame(self, components=None) -> QRTPacket: """Get measured values from QTM for a single frame. :param components: A list of components to receive, could be 'all' or any combination of '2d', '2dlin', '3d', '3dres', '3dnolabels', '3dnolabelsres', 'for...
Stream measured frames from QTM until: func: ~qtm. QRTConnection. stream_frames_stop is called.
async def stream_frames(self, frames="allframes", components=None, on_packet=None): """Stream measured frames from QTM until :func:`~qtm.QRTConnection.stream_frames_stop` is called. :param frames: Which frames to receive, possible values are 'allframes', 'frequency:n' or 'freque...
Stop streaming frames.
async def stream_frames_stop(self): """Stop streaming frames.""" self._protocol.set_on_packet(None) cmd = "streamframes stop" await self._protocol.send_command(cmd, callback=False)
Take control of QTM.
async def take_control(self, password): """Take control of QTM. :param password: Password as entered in QTM. """ cmd = "takecontrol %s" % password return await asyncio.wait_for( self._protocol.send_command(cmd), timeout=self._timeout )
Release control of QTM.
async def release_control(self): """Release control of QTM. """ cmd = "releasecontrol" return await asyncio.wait_for( self._protocol.send_command(cmd), timeout=self._timeout )
Start RT from file. You need to be in control of QTM to be able to do this.
async def start(self, rtfromfile=False): """Start RT from file. You need to be in control of QTM to be able to do this. """ cmd = "start" + (" rtfromfile" if rtfromfile else "") return await asyncio.wait_for( self._protocol.send_command(cmd), timeout=self._timeout )
Load a measurement.
async def load(self, filename): """Load a measurement. :param filename: Path to measurement you want to load. """ cmd = "load %s" % filename return await asyncio.wait_for( self._protocol.send_command(cmd), timeout=self._timeout )
Save a measurement.
async def save(self, filename, overwrite=False): """Save a measurement. :param filename: Filename you wish to save as. :param overwrite: If QTM should overwrite existing measurement. """ cmd = "save %s%s" % (filename, " overwrite" if overwrite else "") return await async...
Load a project.
async def load_project(self, project_path): """Load a project. :param project_path: Path to project you want to load. """ cmd = "loadproject %s" % project_path return await asyncio.wait_for( self._protocol.send_command(cmd), timeout=self._timeout )
Set event in QTM.
async def set_qtm_event(self, event=None): """Set event in QTM.""" cmd = "event%s" % ("" if event is None else " " + event) return await asyncio.wait_for( self._protocol.send_command(cmd), timeout=self._timeout )
Used to update QTM settings see QTM RT protocol for more information.
async def send_xml(self, xml): """Used to update QTM settings, see QTM RT protocol for more information. :param xml: XML document as a str. See QTM RT Documentation for details. """ return await asyncio.wait_for( self._protocol.send_command(xml, command_type=QRTPacketType.Pa...
Received from QTM and route accordingly
def data_received(self, data): """ Received from QTM and route accordingly """ self._received_data += data h_size = RTheader.size data = self._received_data size, type_ = RTheader.unpack_from(data, 0) while len(data) >= size: self._parse_received(data[h_size...
Get analog data.
def get_analog(self, component_info=None, data=None, component_position=None): """Get analog data.""" components = [] append_components = components.append for _ in range(component_info.device_count): component_position, device = QRTPacket._get_exact( RTAnalog...
Get a single analog data channel.
def get_analog_single( self, component_info=None, data=None, component_position=None ): """Get a single analog data channel.""" components = [] append_components = components.append for _ in range(component_info.device_count): component_position, device = QRTPacke...
Get force data.
def get_force(self, component_info=None, data=None, component_position=None): """Get force data.""" components = [] append_components = components.append for _ in range(component_info.plate_count): component_position, plate = QRTPacket._get_exact( RTForcePlate...
Get a single force data channel.
def get_force_single(self, component_info=None, data=None, component_position=None): """Get a single force data channel.""" components = [] append_components = components.append for _ in range(component_info.plate_count): component_position, plate = QRTPacket._get_exact( ...
Get 6D data.
def get_6d(self, component_info=None, data=None, component_position=None): """Get 6D data.""" components = [] append_components = components.append for _ in range(component_info.body_count): component_position, position = QRTPacket._get_exact( RT6DBodyPosition...
Get 6D data with euler rotations.
def get_6d_euler(self, component_info=None, data=None, component_position=None): """Get 6D data with euler rotations.""" components = [] append_components = components.append for _ in range(component_info.body_count): component_position, position = QRTPacket._get_exact( ...
Get image.
def get_image(self, component_info=None, data=None, component_position=None): """Get image.""" components = [] append_components = components.append for _ in range(component_info.image_count): component_position, image_info = QRTPacket._get_exact( RTImage, dat...
Get 3D markers.
def get_3d_markers(self, component_info=None, data=None, component_position=None): """Get 3D markers.""" return self._get_3d_markers( RT3DMarkerPosition, component_info, data, component_position )
Get 3D markers with residual.
def get_3d_markers_residual( self, component_info=None, data=None, component_position=None ): """Get 3D markers with residual.""" return self._get_3d_markers( RT3DMarkerPositionResidual, component_info, data, component_position )
Get 3D markers without label.
def get_3d_markers_no_label( self, component_info=None, data=None, component_position=None ): """Get 3D markers without label.""" return self._get_3d_markers( RT3DMarkerPositionNoLabel, component_info, data, component_position )
Get 3D markers without label with residual.
def get_3d_markers_no_label_residual( self, component_info=None, data=None, component_position=None ): """Get 3D markers without label with residual.""" return self._get_3d_markers( RT3DMarkerPositionNoLabelResidual, component_info, data, component_position )
Get 2D markers.
def get_2d_markers( self, component_info=None, data=None, component_position=None, index=None ): """Get 2D markers. :param index: Specify which camera to get 2D from, will be returned as first entry in the returned array. """ return self._get_2d_markers...
Get 2D linearized markers.
def get_2d_markers_linearized( self, component_info=None, data=None, component_position=None, index=None ): """Get 2D linearized markers. :param index: Specify which camera to get 2D from, will be returned as first entry in the returned array. """ retu...
Get skeletons
def get_skeletons(self, component_info=None, data=None, component_position=None): """Get skeletons """ components = [] append_components = components.append for _ in range(component_info.skeleton_count): component_position, info = QRTPacket._get_exact( ...
Wait for any or specified event
async def await_event(self, event=None, timeout=None): """ Wait for any or specified event """ if self.event_future is not None: raise Exception("Can't wait on multiple events!") result = await asyncio.wait_for(self._wait_loop(event), timeout) return result
Sends commands to QTM
def send_command( self, command, callback=True, command_type=QRTPacketType.PacketCommand ): """ Sends commands to QTM """ if self.transport is not None: cmd_length = len(command) LOG.debug("S: %s", command) self.transport.write( struct.pack...
async function to reboot QTM cameras
async def reboot(ip_address): """ async function to reboot QTM cameras """ _, protocol = await asyncio.get_event_loop().create_datagram_endpoint( QRebootProtocol, local_addr=(ip_address, 0), allow_broadcast=True, reuse_address=True, ) LOG.info("Sending reboot on %s", ip_...
Callback function that is called everytime a data packet arrives from QTM
def on_packet(packet): """ Callback function that is called everytime a data packet arrives from QTM """ print("Framenumber: {}".format(packet.framenumber)) header, markers = packet.get_3d_markers() print("Component info: {}".format(header)) for marker in markers: print("\t", marker)
Main function
async def setup(): """ Main function """ connection = await qtm.connect("127.0.0.1") if connection is None: return await connection.stream_frames(components=["3d"], on_packet=on_packet)
On socket creation
def connection_made(self, transport): """ On socket creation """ self.transport = transport sock = transport.get_extra_info("socket") self.port = sock.getsockname()[1]
Parse response from QTM instances
def datagram_received(self, datagram, address): """ Parse response from QTM instances """ size, _ = RTheader.unpack_from(datagram, 0) info, = struct.unpack_from("{0}s".format(size - 3 - 8), datagram, RTheader.size) base_port, = QRTDiscoveryBasePort.unpack_from(datagram, size - 2) ...
Send discovery packet for QTM to respond to
def send_discovery_packet(self): """ Send discovery packet for QTM to respond to """ if self.port is None: return self.transport.sendto( QRTDiscoveryP1.pack( QRTDiscoveryPacketSize, QRTPacketType.PacketDiscover.value ) + QRTDiscove...
Asynchronous function that processes queue until None is posted in queue
async def packet_receiver(queue): """ Asynchronous function that processes queue until None is posted in queue """ LOG.info("Entering packet_receiver") while True: packet = await queue.get() if packet is None: break LOG.info("Framenumber %s", packet.framenumber) LOG....
List running QTM instances asks for input and return chosen QTM
async def choose_qtm_instance(interface): """ List running QTM instances, asks for input and return chosen QTM """ instances = {} print("Available QTM instances:") async for i, qtm_instance in AsyncEnumerate(qtm.Discover(interface), start=1): instances[i] = qtm_instance print("{} - {}".f...
Main function
async def main(interface=None): """ Main function """ qtm_ip = await choose_qtm_instance(interface) if qtm_ip is None: return while True: connection = await qtm.connect(qtm_ip, 22223, version="1.18") if connection is None: return await connection.get_stat...
Asynchronous function that processes queue until None is posted in queue
async def package_receiver(queue): """ Asynchronous function that processes queue until None is posted in queue """ LOG.info("Entering package_receiver") while True: packet = await queue.get() if packet is None: break LOG.info("Framenumber %s", packet.framenumber) ...
main function
async def setup(): """ main function """ connection = await qtm.connect("127.0.0.1") if connection is None: return -1 async with qtm.TakeControl(connection, "password"): state = await connection.get_state() if state != qtm.QRTEvent.EventConnected: await connection...
Extract a name to index dictionary from 6dof settings xml
def create_body_index(xml_string): """ Extract a name to index dictionary from 6dof settings xml """ xml = ET.fromstring(xml_string) body_to_index = {} for index, body in enumerate(xml.findall("*/Body/Name")): body_to_index[body.text.strip()] = index return body_to_index
Try to find executable in the directories listed in path ( a string listing directories separated by os. pathsep ; defaults to os. environ [ PATH ] ).
def find_executable(executable, path=None): '''Try to find 'executable' in the directories listed in 'path' (a string listing directories separated by 'os.pathsep'; defaults to os.environ['PATH']).''' if path is None: path = os.environ['PATH'] paths = path.split(os.pathsep) extlist = [''...
Return true if substring is in string for files in specified path
def find_x(path1): '''Return true if substring is in string for files in specified path''' libs = os.listdir(path1) for lib_dir in libs: if "doublefann" in lib_dir: return True
Find doublefann library
def find_fann(): '''Find doublefann library''' # FANN possible libs directories (as $LD_LIBRARY_PATH), also includes # pkgsrc framework support. if sys.platform == "win32": dirs = sys.path for ver in dirs: if os.path.isdir(ver): if find_x(ver): ...
Run SWIG with specified parameters
def build_swig(): '''Run SWIG with specified parameters''' print("Looking for FANN libs...") find_fann() print("running SWIG...") swig_bin = find_swig() swig_cmd = [swig_bin, '-c++', '-python', 'fann2/fann2.i'] subprocess.Popen(swig_cmd).wait()
Commands for experiments.
def experiment(ctx, project, experiment): # pylint:disable=redefined-outer-name """Commands for experiments.""" ctx.obj = ctx.obj or {} ctx.obj['project'] = project ctx.obj['experiment'] = experiment
Get experiment or experiment job.
def get(ctx, job): """Get experiment or experiment job. Uses [Caching](/references/polyaxon-cli/#caching) Examples for getting an experiment: \b ```bash $ polyaxon experiment get # if experiment is cached ``` \b ```bash $ polyaxon experiment --experiment=1 get ``` \...
Delete experiment.
def delete(ctx): """Delete experiment. Uses [Caching](/references/polyaxon-cli/#caching) Example: \b ```bash $ polyaxon experiment delete ``` """ user, project_name, _experiment = get_project_experiment_or_local(ctx.obj.get('project'), ...
Update experiment.
def update(ctx, name, description, tags): """Update experiment. Uses [Caching](/references/polyaxon-cli/#caching) Examples: \b ```bash $ polyaxon experiment -xp 2 update --description="new description for my experiments" ``` \b ```bash $ polyaxon experiment -xp 2 update --tag...
Stop experiment.
def stop(ctx, yes): """Stop experiment. Uses [Caching](/references/polyaxon-cli/#caching) Examples: \b ```bash $ polyaxon experiment stop ``` \b ```bash $ polyaxon experiment -xp 2 stop ``` """ user, project_name, _experiment = get_project_experiment_or_local(ctx....
Restart experiment.
def restart(ctx, copy, file, u): # pylint:disable=redefined-builtin """Restart experiment. Uses [Caching](/references/polyaxon-cli/#caching) Examples: \b ```bash $ polyaxon experiment --experiment=1 restart ``` """ config = None update_code = None if file: config ...
Get experiment or experiment job statuses.
def statuses(ctx, job, page): """Get experiment or experiment job statuses. Uses [Caching](/references/polyaxon-cli/#caching) Examples getting experiment statuses: \b ```bash $ polyaxon experiment statuses ``` \b ```bash $ polyaxon experiment -xp 1 statuses ``` Examp...
Get experiment or experiment job resources.
def resources(ctx, job, gpu): """Get experiment or experiment job resources. Uses [Caching](/references/polyaxon-cli/#caching) Examples for getting experiment resources: \b ```bash $ polyaxon experiment -xp 19 resources ``` For GPU resources \b ```bash $ polyaxon experim...
Get experiment or experiment job logs.
def logs(ctx, job, past, follow, hide_time): """Get experiment or experiment job logs. Uses [Caching](/references/polyaxon-cli/#caching) Examples for getting experiment logs: \b ```bash $ polyaxon experiment logs ``` \b ```bash $ polyaxon experiment -xp 10 -p mnist logs `...
Unbookmark experiment.
def unbookmark(ctx): """Unbookmark experiment. Uses [Caching](/references/polyaxon-cli/#caching) Examples: \b ```bash $ polyaxon experiment unbookmark ``` \b ```bash $ polyaxon experiment -xp 2 unbookmark ``` """ user, project_name, _experiment = get_project_exper...
Upload code of the current directory while respecting the. polyaxonignore file.
def upload(sync=True): # pylint:disable=assign-to-new-keyword """Upload code of the current directory while respecting the .polyaxonignore file.""" project = ProjectManager.get_config_or_raise() files = IgnoreManager.get_unignored_file_paths() try: with create_tarfile(files, project.name) as fi...
Get cluster and nodes info.
def cluster(node): """Get cluster and nodes info.""" cluster_client = PolyaxonClient().cluster if node: try: node_config = cluster_client.get_node(node) except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e: Printer.print_error('Could not l...
Check a polyaxonfile.
def check(file, # pylint:disable=redefined-builtin version, definition): """Check a polyaxonfile.""" file = file or 'polyaxonfile.yaml' specification = check_polyaxonfile(file).specification if version: Printer.decorate_format_value('The version is: {}', ...
Decorator for CLI with Sentry client handling.
def clean_outputs(fn): """Decorator for CLI with Sentry client handling. see https://github.com/getsentry/raven-python/issues/904 for more details. """ @wraps(fn) def clean_outputs_wrapper(*args, **kwargs): try: return fn(*args, **kwargs) except SystemExit as e: ...
Commands for jobs.
def job(ctx, project, job): # pylint:disable=redefined-outer-name """Commands for jobs.""" ctx.obj = ctx.obj or {} ctx.obj['project'] = project ctx.obj['job'] = job
Get job.
def get(ctx): """Get job. Uses [Caching](/references/polyaxon-cli/#caching) Examples: \b ```bash $ polyaxon job --job=1 get ``` \b ```bash $ polyaxon job --job=1 --project=project_name get ``` """ user, project_name, _job = get_job_or_local(ctx.obj.get('project'),...
Delete job.
def delete(ctx): """Delete job. Uses [Caching](/references/polyaxon-cli/#caching) Example: \b ```bash $ polyaxon job delete ``` """ user, project_name, _job = get_job_or_local(ctx.obj.get('project'), ctx.obj.get('job')) if not click.confirm("Are sure you want to delete job `{}...
Update job.
def update(ctx, name, description, tags): """Update job. Uses [Caching](/references/polyaxon-cli/#caching) Example: \b ```bash $ polyaxon job -j 2 update --description="new description for my job" ``` """ user, project_name, _job = get_job_or_local(ctx.obj.get('project'), ctx.obj....
Stop job.
def stop(ctx, yes): """Stop job. Uses [Caching](/references/polyaxon-cli/#caching) Examples: \b ```bash $ polyaxon job stop ``` \b ```bash $ polyaxon job -xp 2 stop ``` """ user, project_name, _job = get_job_or_local(ctx.obj.get('project'), ctx.obj.get('job')) ...
Restart job.
def restart(ctx, copy, file, u): # pylint:disable=redefined-builtin """Restart job. Uses [Caching](/references/polyaxon-cli/#caching) Examples: \b ```bash $ polyaxon job --job=1 restart ``` """ config = None update_code = None if file: config = rhea.read(file) ...