Skip to content

Instantly share code, notes, and snippets.

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:
import tensorflow as tf
import numpy as np
import uuid
__all__ = ['to_tfrecords']
def to_tfrecords(dataframe, dir):
"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;
"use strict";
const myModule = rehire("./myModule", {
"fs": { existsSync: () => true },
});
suite("myModule", () => {
afterChunk(() => {
myModule.__reset__();
"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);
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():
import os
import time
from pebble import ProcessPool
from subprocess import Popen
def task():
Popen(['sleep', '30'])
print('task done')
import os
import time
from pebble import ProcessPool
def task():
pid = os.fork()
if pid == 0: # child process
time.sleep(1)
import os
import time
from pebble import ProcessPool
def task():
pid = os.fork()
if pid == 0: # child process
time.sleep(1)
os._exit(0)
import time
from multiprocessing import Process
def target():
raise Exception('BOOM!')
def main():
proc = Process(target=target)