In [1]:
from blackfynn import Blackfynn
bf = Blackfynn('guidon')
print "email =", bf.profile.email
print "organization =", bf.context.name
print "my datatsets:"
for ds in bf.datasets():
print ds.name
In [2]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 10*np.pi, 500)
y1 = np.sin(x)
y2 = np.cos(x)
plt.plot(x, y1)
plt.plot(x, y2)
plt.title('A demo plot')
plt.show()
# Store to file
np.savetxt("demo.csv", zip(x, y1, y2), delimiter=',', header='x, y1, y2')
In [3]:
# Create a new dataset, delete existing documents first
simcore_dataset = None
try:
simcore_dataset = bf.get_dataset("simcore-dataset")
for item in simcore_dataset:
item.delete()
except:
print "Dataset not yet there"
simcore_dataset = bf.create_dataset("simcore-dataset")
# Upload file
simcore_dataset.upload("demo.csv")
Out[3]:
In [4]:
simcore_dataset.update()
for item in simcore_dataset:
print "Type:", item.type, "|", "Name:", item.name, "|" , "ID:", item.id
tb = bf.get(item.id)
# get all the data
data = tb.get_data()
# print rows and column information for the data
print("Data has {} rows and {} columns").format(len(data.index),len(data.columns))
print("First Index: {}").format(data.index[0])
print("Last Index: {}").format(data.index[len(data.index)-1])
print "\nColumns in the data:"
print " | ".join(data.columns)
In [5]:
x = data['# x']
y1 = data['y1']
plt.scatter(x, y1)
plt.show()
In [6]:
demo = simcore_dataset[0]
demo.set_property("docker-image-id", "42", category="simcore")
In [7]:
simcore_dataset.update()
In [ ]: