This file contains hidden or 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 subprocess | |
# simply running a command and getting the output | |
cmd = ['ps', '-ax'] | |
s = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
(stdoutdata, stderrdata) = s.communicate() | |
#print(stdoutdata) | |
# you can chain commands | |
# the following runs 'ls /etc | grep ntp' by sending the 'ls etc' output to the input of the 'grep ntp' |
This file contains hidden or 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
val names = df.columns.toList | |
println(names) | |
df.foreachPartition(rows => { | |
var cols = scala.collection.mutable.Map[String, List[Any]]() | |
names.foreach(col => cols(col) = List()) | |
rows.foreach(row => names.zip(row.toSeq).map(x => { | |
cols(x._1) = cols(x._1) :+ x._2 | |
})) | |
println(cols) | |
}) |
This file contains hidden or 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
def predictResponse_into_nparray(response, output_tensor_name): | |
dims = response.outputs[output_tensor_name].tensor_shape.dim | |
shape = tuple(d.size for d in dims) | |
print(shape) | |
return np.reshape(response.outputs[output_tensor_name].float_val, shape) |
This file contains hidden or 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 org.apache.spark.ml.Pipeline | |
import org.apache.spark.ml.classification.RandomForestClassifier | |
import org.apache.spark.ml.evaluation.{BinaryClassificationEvaluator, MulticlassClassificationEvaluator} | |
import org.apache.spark.ml.feature._ | |
import org.apache.spark.sql.{Column, DataFrame, Row, SparkSession} | |
import org.apache.spark.sql.functions._ | |
import org.apache.spark.ml.tuning.{CrossValidator, ParamGridBuilder} | |
/** |
This file contains hidden or 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
def a_friendly_professor(): | |
return "".join( | |
[chr (int (x**i+i*0.01 ))for i, x in enumerate( | |
[0, 68, 10+ 0.677 ,4.8058 ,3.2+ | |
0.06+ 0.0075 ,2, 2.0348 ,1.7279 ,1.54 | |
,1.6032 ,1.5864 ,1.527 ,1.486 ,1.4261 ,1.3 | |
+0.0971,1.372, 1.3422 ,1.318505429 ])]) |
This file contains hidden or 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 pickle | |
import numpy as np | |
import time | |
import requests | |
import subprocess | |
import re | |
from grpc.beta import implementations | |
import tensorflow as tf | |
from tensorflow_serving.apis import predict_pb2 | |
from tensorflow_serving.apis import prediction_service_pb2 |
This file contains hidden or 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 pickle | |
import numpy as np | |
import requests | |
host = 'localhost' | |
port = '8501' | |
batch_size = 1 | |
image_path = "./mnist_image.pkl" | |
model_name = 'mnist' | |
signature_name = 'predict_images' |
This file contains hidden or 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
FROM ubuntu:16.04 | |
MAINTAINER Eran Avidan | |
# Install general packages | |
RUN apt-get update && apt-get install -y \ | |
curl \ | |
libcurl3-dev \ | |
unzip \ | |
wget \ |
This file contains hidden or 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 | |
from tensorflow_serving.apis import predict_pb2 | |
import time | |
import base64 | |
import requests | |
import pickle | |
import numpy as np | |
import random | |
This file contains hidden or 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 ray | |
import pandas as pd | |
import numpy as np | |
ray.init(local_mode=True) | |
def ge(a, b, by): | |
gt = a > b | |
eq = a == b |