This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
__all__ = ['from_tfrecords'] | |
def from_tfrecords(file_paths, compression_type=None, features=None, feature_lists=None): | |
dataset = tf.data.TFRecordDataset(file_paths, compression_type=compression_type) | |
if not features and not feature_lists: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import numpy as np | |
import uuid | |
__all__ = ['to_tfrecords'] | |
def to_tfrecords(dataframe, dir): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const path = require("path"); | |
const rewire = require("rewire"); | |
const CALLS_DEPTH = 2; // NOTE: Important to keep it actual | |
const getCallerPath = () => { | |
const _ = Error.prepareStackTrace; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const myModule = rehire("./myModule", { | |
"fs": { existsSync: () => true }, | |
}); | |
suite("myModule", () => { | |
afterChunk(() => { | |
myModule.__reset__(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const fs = require("fs"); | |
const _summarize = (a, b) => a + b; | |
exports.summarize = (a, b) => _summarize(a, b); | |
exports.isPathExists = _path => fs.existsSync(_path); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psutil | |
def _proc_children(): # added by me | |
for child in psutil.Process(os.getpid()).children(recursive=True): | |
yield child | |
def _exit(exit_code): # added by me | |
for child in _proc_children(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
from pebble import ProcessPool | |
from subprocess import Popen | |
def task(): | |
Popen(['sleep', '30']) | |
print('task done') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
from pebble import ProcessPool | |
def task(): | |
pid = os.fork() | |
if pid == 0: # child process | |
time.sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
from pebble import ProcessPool | |
def task(): | |
pid = os.fork() | |
if pid == 0: # child process | |
time.sleep(1) | |
os._exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from multiprocessing import Process | |
def target(): | |
raise Exception('BOOM!') | |
def main(): | |
proc = Process(target=target) |
NewerOlder