repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
Neurosim-lab/netpyne
doc/source/code/HHCellFile.py
Cell.createNetcon
def createNetcon(self, thresh=10): """ created netcon to record spikes """ nc = h.NetCon(self.soma(0.5)._ref_v, None, sec = self.soma) nc.threshold = thresh return nc
python
def createNetcon(self, thresh=10): """ created netcon to record spikes """ nc = h.NetCon(self.soma(0.5)._ref_v, None, sec = self.soma) nc.threshold = thresh return nc
[ "def", "createNetcon", "(", "self", ",", "thresh", "=", "10", ")", ":", "nc", "=", "h", ".", "NetCon", "(", "self", ".", "soma", "(", "0.5", ")", ".", "_ref_v", ",", "None", ",", "sec", "=", "self", ".", "soma", ")", "nc", ".", "threshold", "="...
created netcon to record spikes
[ "created", "netcon", "to", "record", "spikes" ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/doc/source/code/HHCellFile.py#L42-L46
train
Neurosim-lab/netpyne
doc/source/code/HHCellFile.py
HHCellClass.createSections
def createSections(self): """Create the sections of the cell.""" self.soma = h.Section(name='soma', cell=self) self.dend = h.Section(name='dend', cell=self)
python
def createSections(self): """Create the sections of the cell.""" self.soma = h.Section(name='soma', cell=self) self.dend = h.Section(name='dend', cell=self)
[ "def", "createSections", "(", "self", ")", ":", "self", ".", "soma", "=", "h", ".", "Section", "(", "name", "=", "'soma'", ",", "cell", "=", "self", ")", "self", ".", "dend", "=", "h", ".", "Section", "(", "name", "=", "'dend'", ",", "cell", "=",...
Create the sections of the cell.
[ "Create", "the", "sections", "of", "the", "cell", "." ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/doc/source/code/HHCellFile.py#L51-L54
train
Neurosim-lab/netpyne
doc/source/code/HHCellFile.py
HHCellClass.defineGeometry
def defineGeometry(self): """Set the 3D geometry of the cell.""" self.soma.L = 18.8 self.soma.diam = 18.8 self.soma.Ra = 123.0 self.dend.L = 200.0 self.dend.diam = 1.0 self.dend.Ra = 100.0
python
def defineGeometry(self): """Set the 3D geometry of the cell.""" self.soma.L = 18.8 self.soma.diam = 18.8 self.soma.Ra = 123.0 self.dend.L = 200.0 self.dend.diam = 1.0 self.dend.Ra = 100.0
[ "def", "defineGeometry", "(", "self", ")", ":", "self", ".", "soma", ".", "L", "=", "18.8", "self", ".", "soma", ".", "diam", "=", "18.8", "self", ".", "soma", ".", "Ra", "=", "123.0", "self", ".", "dend", ".", "L", "=", "200.0", "self", ".", "...
Set the 3D geometry of the cell.
[ "Set", "the", "3D", "geometry", "of", "the", "cell", "." ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/doc/source/code/HHCellFile.py#L56-L64
train
Neurosim-lab/netpyne
doc/source/code/HHCellFile.py
HHCellClass.defineBiophysics
def defineBiophysics(self): """Assign the membrane properties across the cell.""" # Insert active Hodgkin-Huxley current in the soma self.soma.insert('hh') self.soma.gnabar_hh = 0.12 # Sodium conductance in S/cm2 self.soma.gkbar_hh = 0.036 # Potassium conductance in S/cm2 ...
python
def defineBiophysics(self): """Assign the membrane properties across the cell.""" # Insert active Hodgkin-Huxley current in the soma self.soma.insert('hh') self.soma.gnabar_hh = 0.12 # Sodium conductance in S/cm2 self.soma.gkbar_hh = 0.036 # Potassium conductance in S/cm2 ...
[ "def", "defineBiophysics", "(", "self", ")", ":", "self", ".", "soma", ".", "insert", "(", "'hh'", ")", "self", ".", "soma", ".", "gnabar_hh", "=", "0.12", "self", ".", "soma", ".", "gkbar_hh", "=", "0.036", "self", ".", "soma", ".", "gl_hh", "=", ...
Assign the membrane properties across the cell.
[ "Assign", "the", "membrane", "properties", "across", "the", "cell", "." ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/doc/source/code/HHCellFile.py#L66-L78
train
Neurosim-lab/netpyne
netpyne/support/morphology.py
shapeplot
def shapeplot(h,ax,sections=None,order='pre',cvals=None,\ clim=None,cmap=cm.YlOrBr_r, legend=True, **kwargs): # meanLineWidth=1.0, maxLineWidth=10.0, """ Plots a 3D shapeplot Args: h = hocObject to interface with neuron ax = matplotlib axis for plotting sections = li...
python
def shapeplot(h,ax,sections=None,order='pre',cvals=None,\ clim=None,cmap=cm.YlOrBr_r, legend=True, **kwargs): # meanLineWidth=1.0, maxLineWidth=10.0, """ Plots a 3D shapeplot Args: h = hocObject to interface with neuron ax = matplotlib axis for plotting sections = li...
[ "def", "shapeplot", "(", "h", ",", "ax", ",", "sections", "=", "None", ",", "order", "=", "'pre'", ",", "cvals", "=", "None", ",", "clim", "=", "None", ",", "cmap", "=", "cm", ".", "YlOrBr_r", ",", "legend", "=", "True", ",", "**", "kwargs", ")",...
Plots a 3D shapeplot Args: h = hocObject to interface with neuron ax = matplotlib axis for plotting sections = list of h.Section() objects to be plotted order = { None= use h.allsec() to get sections 'pre'= pre-order traversal of morphology } cvals = list/a...
[ "Plots", "a", "3D", "shapeplot" ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/support/morphology.py#L279-L346
train
Neurosim-lab/netpyne
netpyne/support/morphology.py
shapeplot_animate
def shapeplot_animate(v,lines,nframes=None,tscale='linear',\ clim=[-80,50],cmap=cm.YlOrBr_r): """ Returns animate function which updates color of shapeplot """ if nframes is None: nframes = v.shape[0] if tscale == 'linear': def animate(i): i_t = int((i/nfram...
python
def shapeplot_animate(v,lines,nframes=None,tscale='linear',\ clim=[-80,50],cmap=cm.YlOrBr_r): """ Returns animate function which updates color of shapeplot """ if nframes is None: nframes = v.shape[0] if tscale == 'linear': def animate(i): i_t = int((i/nfram...
[ "def", "shapeplot_animate", "(", "v", ",", "lines", ",", "nframes", "=", "None", ",", "tscale", "=", "'linear'", ",", "clim", "=", "[", "-", "80", ",", "50", "]", ",", "cmap", "=", "cm", ".", "YlOrBr_r", ")", ":", "if", "nframes", "is", "None", "...
Returns animate function which updates color of shapeplot
[ "Returns", "animate", "function", "which", "updates", "color", "of", "shapeplot" ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/support/morphology.py#L348-L368
train
Neurosim-lab/netpyne
netpyne/support/morphology.py
mark_locations
def mark_locations(h,section,locs,markspec='or',**kwargs): """ Marks one or more locations on along a section. Could be used to mark the location of a recording or electrical stimulation. Args: h = hocObject to interface with neuron section = reference to section locs = float be...
python
def mark_locations(h,section,locs,markspec='or',**kwargs): """ Marks one or more locations on along a section. Could be used to mark the location of a recording or electrical stimulation. Args: h = hocObject to interface with neuron section = reference to section locs = float be...
[ "def", "mark_locations", "(", "h", ",", "section", ",", "locs", ",", "markspec", "=", "'or'", ",", "**", "kwargs", ")", ":", "xyz", "=", "get_section_path", "(", "h", ",", "section", ")", "(", "r", ",", "theta", ",", "phi", ")", "=", "sequential_sphe...
Marks one or more locations on along a section. Could be used to mark the location of a recording or electrical stimulation. Args: h = hocObject to interface with neuron section = reference to section locs = float between 0 and 1, or array of floats optional arguments specify de...
[ "Marks", "one", "or", "more", "locations", "on", "along", "a", "section", ".", "Could", "be", "used", "to", "mark", "the", "location", "of", "a", "recording", "or", "electrical", "stimulation", "." ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/support/morphology.py#L370-L406
train
Neurosim-lab/netpyne
netpyne/support/morphology.py
root_sections
def root_sections(h): """ Returns a list of all sections that have no parent. """ roots = [] for section in h.allsec(): sref = h.SectionRef(sec=section) # has_parent returns a float... cast to bool if sref.has_parent() < 0.9: roots.append(section) return roots
python
def root_sections(h): """ Returns a list of all sections that have no parent. """ roots = [] for section in h.allsec(): sref = h.SectionRef(sec=section) # has_parent returns a float... cast to bool if sref.has_parent() < 0.9: roots.append(section) return roots
[ "def", "root_sections", "(", "h", ")", ":", "roots", "=", "[", "]", "for", "section", "in", "h", ".", "allsec", "(", ")", ":", "sref", "=", "h", ".", "SectionRef", "(", "sec", "=", "section", ")", "if", "sref", ".", "has_parent", "(", ")", "<", ...
Returns a list of all sections that have no parent.
[ "Returns", "a", "list", "of", "all", "sections", "that", "have", "no", "parent", "." ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/support/morphology.py#L408-L418
train
Neurosim-lab/netpyne
netpyne/support/morphology.py
leaf_sections
def leaf_sections(h): """ Returns a list of all sections that have no children. """ leaves = [] for section in h.allsec(): sref = h.SectionRef(sec=section) # nchild returns a float... cast to bool if sref.nchild() < 0.9: leaves.append(section) return leaves
python
def leaf_sections(h): """ Returns a list of all sections that have no children. """ leaves = [] for section in h.allsec(): sref = h.SectionRef(sec=section) # nchild returns a float... cast to bool if sref.nchild() < 0.9: leaves.append(section) return leaves
[ "def", "leaf_sections", "(", "h", ")", ":", "leaves", "=", "[", "]", "for", "section", "in", "h", ".", "allsec", "(", ")", ":", "sref", "=", "h", ".", "SectionRef", "(", "sec", "=", "section", ")", "if", "sref", ".", "nchild", "(", ")", "<", "0...
Returns a list of all sections that have no children.
[ "Returns", "a", "list", "of", "all", "sections", "that", "have", "no", "children", "." ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/support/morphology.py#L420-L430
train
Neurosim-lab/netpyne
netpyne/support/morphology.py
root_indices
def root_indices(sec_list): """ Returns the index of all sections without a parent. """ roots = [] for i,section in enumerate(sec_list): sref = h.SectionRef(sec=section) # has_parent returns a float... cast to bool if sref.has_parent() < 0.9: roots.append(i) r...
python
def root_indices(sec_list): """ Returns the index of all sections without a parent. """ roots = [] for i,section in enumerate(sec_list): sref = h.SectionRef(sec=section) # has_parent returns a float... cast to bool if sref.has_parent() < 0.9: roots.append(i) r...
[ "def", "root_indices", "(", "sec_list", ")", ":", "roots", "=", "[", "]", "for", "i", ",", "section", "in", "enumerate", "(", "sec_list", ")", ":", "sref", "=", "h", ".", "SectionRef", "(", "sec", "=", "section", ")", "if", "sref", ".", "has_parent",...
Returns the index of all sections without a parent.
[ "Returns", "the", "index", "of", "all", "sections", "without", "a", "parent", "." ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/support/morphology.py#L432-L442
train
Neurosim-lab/netpyne
netpyne/support/morphology.py
branch_order
def branch_order(h,section, path=[]): """ Returns the branch order of a section """ path.append(section) sref = h.SectionRef(sec=section) # has_parent returns a float... cast to bool if sref.has_parent() < 0.9: return 0 # section is a root else: nchild = len(list(h.Sectio...
python
def branch_order(h,section, path=[]): """ Returns the branch order of a section """ path.append(section) sref = h.SectionRef(sec=section) # has_parent returns a float... cast to bool if sref.has_parent() < 0.9: return 0 # section is a root else: nchild = len(list(h.Sectio...
[ "def", "branch_order", "(", "h", ",", "section", ",", "path", "=", "[", "]", ")", ":", "path", ".", "append", "(", "section", ")", "sref", "=", "h", ".", "SectionRef", "(", "sec", "=", "section", ")", "if", "sref", ".", "has_parent", "(", ")", "<...
Returns the branch order of a section
[ "Returns", "the", "branch", "order", "of", "a", "section" ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/support/morphology.py#L504-L518
train
Neurosim-lab/netpyne
netpyne/network/pop.py
Pop.createCells
def createCells(self): '''Function to instantiate Cell objects based on the characteristics of this population''' # add individual cells if 'cellsList' in self.tags: cells = self.createCellsList() # create cells based on fixed number of cells elif 'numCells' in self....
python
def createCells(self): '''Function to instantiate Cell objects based on the characteristics of this population''' # add individual cells if 'cellsList' in self.tags: cells = self.createCellsList() # create cells based on fixed number of cells elif 'numCells' in self....
[ "def", "createCells", "(", "self", ")", ":", "if", "'cellsList'", "in", "self", ".", "tags", ":", "cells", "=", "self", ".", "createCellsList", "(", ")", "elif", "'numCells'", "in", "self", ".", "tags", ":", "cells", "=", "self", ".", "createCellsFixedNu...
Function to instantiate Cell objects based on the characteristics of this population
[ "Function", "to", "instantiate", "Cell", "objects", "based", "on", "the", "characteristics", "of", "this", "population" ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/network/pop.py#L64-L88
train
Neurosim-lab/netpyne
netpyne/network/pop.py
Pop.createCellsList
def createCellsList (self): ''' Create population cells based on list of individual cells''' from .. import sim cells = [] self.tags['numCells'] = len(self.tags['cellsList']) for i in self._distributeCells(len(self.tags['cellsList']))[sim.rank]: #if 'cellMode...
python
def createCellsList (self): ''' Create population cells based on list of individual cells''' from .. import sim cells = [] self.tags['numCells'] = len(self.tags['cellsList']) for i in self._distributeCells(len(self.tags['cellsList']))[sim.rank]: #if 'cellMode...
[ "def", "createCellsList", "(", "self", ")", ":", "from", ".", ".", "import", "sim", "cells", "=", "[", "]", "self", ".", "tags", "[", "'numCells'", "]", "=", "len", "(", "self", ".", "tags", "[", "'cellsList'", "]", ")", "for", "i", "in", "self", ...
Create population cells based on list of individual cells
[ "Create", "population", "cells", "based", "on", "list", "of", "individual", "cells" ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/network/pop.py#L275-L301
train
Neurosim-lab/netpyne
netpyne/sim/wrappers.py
create
def create (netParams=None, simConfig=None, output=False): ''' Sequence of commands to create network ''' from .. import sim import __main__ as top if not netParams: netParams = top.netParams if not simConfig: simConfig = top.simConfig sim.initialize(netParams, simConfig) # create network obje...
python
def create (netParams=None, simConfig=None, output=False): ''' Sequence of commands to create network ''' from .. import sim import __main__ as top if not netParams: netParams = top.netParams if not simConfig: simConfig = top.simConfig sim.initialize(netParams, simConfig) # create network obje...
[ "def", "create", "(", "netParams", "=", "None", ",", "simConfig", "=", "None", ",", "output", "=", "False", ")", ":", "from", ".", ".", "import", "sim", "import", "__main__", "as", "top", "if", "not", "netParams", ":", "netParams", "=", "top", ".", "...
Sequence of commands to create network
[ "Sequence", "of", "commands", "to", "create", "network" ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/sim/wrappers.py#L19-L34
train
Neurosim-lab/netpyne
netpyne/sim/wrappers.py
intervalSimulate
def intervalSimulate (interval): ''' Sequence of commands to simulate network ''' from .. import sim sim.runSimWithIntervalFunc(interval, sim.intervalSave) # run parallel Neuron simulation #this gather is justa merging of files sim.fileGather()
python
def intervalSimulate (interval): ''' Sequence of commands to simulate network ''' from .. import sim sim.runSimWithIntervalFunc(interval, sim.intervalSave) # run parallel Neuron simulation #this gather is justa merging of files sim.fileGather()
[ "def", "intervalSimulate", "(", "interval", ")", ":", "from", ".", ".", "import", "sim", "sim", ".", "runSimWithIntervalFunc", "(", "interval", ",", "sim", ".", "intervalSave", ")", "sim", ".", "fileGather", "(", ")" ]
Sequence of commands to simulate network
[ "Sequence", "of", "commands", "to", "simulate", "network" ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/sim/wrappers.py#L49-L54
train
Neurosim-lab/netpyne
netpyne/sim/wrappers.py
load
def load (filename, simConfig=None, output=False, instantiate=True, createNEURONObj=True): ''' Sequence of commands load, simulate and analyse network ''' from .. import sim sim.initialize() # create network object and set cfg and net params sim.cfg.createNEURONObj = createNEURONObj sim.loadAll(fil...
python
def load (filename, simConfig=None, output=False, instantiate=True, createNEURONObj=True): ''' Sequence of commands load, simulate and analyse network ''' from .. import sim sim.initialize() # create network object and set cfg and net params sim.cfg.createNEURONObj = createNEURONObj sim.loadAll(fil...
[ "def", "load", "(", "filename", ",", "simConfig", "=", "None", ",", "output", "=", "False", ",", "instantiate", "=", "True", ",", "createNEURONObj", "=", "True", ")", ":", "from", ".", ".", "import", "sim", "sim", ".", "initialize", "(", ")", "sim", ...
Sequence of commands load, simulate and analyse network
[ "Sequence", "of", "commands", "load", "simulate", "and", "analyse", "network" ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/sim/wrappers.py#L116-L136
train
Neurosim-lab/netpyne
netpyne/sim/wrappers.py
createExportNeuroML2
def createExportNeuroML2 (netParams=None, simConfig=None, reference=None, connections=True, stimulations=True, output=False, format='xml'): ''' Sequence of commands to create and export network to NeuroML2 ''' from .. import sim import __main__ as top if not netParams: netParams = top.netParams if n...
python
def createExportNeuroML2 (netParams=None, simConfig=None, reference=None, connections=True, stimulations=True, output=False, format='xml'): ''' Sequence of commands to create and export network to NeuroML2 ''' from .. import sim import __main__ as top if not netParams: netParams = top.netParams if n...
[ "def", "createExportNeuroML2", "(", "netParams", "=", "None", ",", "simConfig", "=", "None", ",", "reference", "=", "None", ",", "connections", "=", "True", ",", "stimulations", "=", "True", ",", "output", "=", "False", ",", "format", "=", "'xml'", ")", ...
Sequence of commands to create and export network to NeuroML2
[ "Sequence", "of", "commands", "to", "create", "and", "export", "network", "to", "NeuroML2" ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/sim/wrappers.py#L164-L180
train
Neurosim-lab/netpyne
netpyne/analysis/utils.py
exception
def exception(function): """ A decorator that wraps the passed in function and prints exception should one occur """ @functools.wraps(function) def wrapper(*args, **kwargs): try: return function(*args, **kwargs) except Exception as e: # print err ...
python
def exception(function): """ A decorator that wraps the passed in function and prints exception should one occur """ @functools.wraps(function) def wrapper(*args, **kwargs): try: return function(*args, **kwargs) except Exception as e: # print err ...
[ "def", "exception", "(", "function", ")", ":", "@", "functools", ".", "wraps", "(", "function", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "try", ":", "return", "function", "(", "*", "args", ",", "**", "kwargs", ")", "e...
A decorator that wraps the passed in function and prints exception should one occur
[ "A", "decorator", "that", "wraps", "the", "passed", "in", "function", "and", "prints", "exception", "should", "one", "occur" ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/analysis/utils.py#L54-L68
train
Neurosim-lab/netpyne
netpyne/analysis/utils.py
getSpktSpkid
def getSpktSpkid(cellGids=[], timeRange=None, allCells=False): '''return spike ids and times; with allCells=True just need to identify slice of time so can omit cellGids''' from .. import sim import pandas as pd try: # Pandas 0.24 and later from pandas import _lib as pandaslib except: #...
python
def getSpktSpkid(cellGids=[], timeRange=None, allCells=False): '''return spike ids and times; with allCells=True just need to identify slice of time so can omit cellGids''' from .. import sim import pandas as pd try: # Pandas 0.24 and later from pandas import _lib as pandaslib except: #...
[ "def", "getSpktSpkid", "(", "cellGids", "=", "[", "]", ",", "timeRange", "=", "None", ",", "allCells", "=", "False", ")", ":", "from", ".", ".", "import", "sim", "import", "pandas", "as", "pd", "try", ":", "from", "pandas", "import", "_lib", "as", "p...
return spike ids and times; with allCells=True just need to identify slice of time so can omit cellGids
[ "return", "spike", "ids", "and", "times", ";", "with", "allCells", "=", "True", "just", "need", "to", "identify", "slice", "of", "time", "so", "can", "omit", "cellGids" ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/analysis/utils.py#L321-L341
train
Neurosim-lab/netpyne
netpyne/support/recxelectrode.py
RecXElectrode.calcTransferResistance
def calcTransferResistance(self, gid, seg_coords): """Precompute mapping from segment to electrode locations""" sigma = 0.3 # mS/mm # Value used in NEURON extracellular recording example ("extracellular_stim_and_rec") # rho = 35.4 # ohm cm, squid axon cytoplasm = 2.8249e-2 S/cm = 0.0...
python
def calcTransferResistance(self, gid, seg_coords): """Precompute mapping from segment to electrode locations""" sigma = 0.3 # mS/mm # Value used in NEURON extracellular recording example ("extracellular_stim_and_rec") # rho = 35.4 # ohm cm, squid axon cytoplasm = 2.8249e-2 S/cm = 0.0...
[ "def", "calcTransferResistance", "(", "self", ",", "gid", ",", "seg_coords", ")", ":", "sigma", "=", "0.3", "r05", "=", "(", "seg_coords", "[", "'p0'", "]", "+", "seg_coords", "[", "'p1'", "]", ")", "/", "2", "dl", "=", "seg_coords", "[", "'p1'", "]"...
Precompute mapping from segment to electrode locations
[ "Precompute", "mapping", "from", "segment", "to", "electrode", "locations" ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/support/recxelectrode.py#L67-L105
train
Neurosim-lab/netpyne
netpyne/conversion/excel.py
importConnFromExcel
def importConnFromExcel (fileName, sheetName): ''' Import connectivity rules from Excel sheet''' import openpyxl as xl # set columns colPreTags = 0 # 'A' colPostTags = 1 # 'B' colConnFunc = 2 # 'C' colSyn = 3 # 'D' colProb = 5 # 'F' colWeight = 6 # 'G' colAnnot = 8 # 'I' o...
python
def importConnFromExcel (fileName, sheetName): ''' Import connectivity rules from Excel sheet''' import openpyxl as xl # set columns colPreTags = 0 # 'A' colPostTags = 1 # 'B' colConnFunc = 2 # 'C' colSyn = 3 # 'D' colProb = 5 # 'F' colWeight = 6 # 'G' colAnnot = 8 # 'I' o...
[ "def", "importConnFromExcel", "(", "fileName", ",", "sheetName", ")", ":", "import", "openpyxl", "as", "xl", "colPreTags", "=", "0", "colPostTags", "=", "1", "colConnFunc", "=", "2", "colSyn", "=", "3", "colProb", "=", "5", "colWeight", "=", "6", "colAnnot...
Import connectivity rules from Excel sheet
[ "Import", "connectivity", "rules", "from", "Excel", "sheet" ]
edb67b5098b2e7923d55010ded59ad1bf75c0f18
https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/conversion/excel.py#L19-L75
train
zerwes/hiyapyco
hiyapyco/odyldo.py
safe_dump
def safe_dump(data, stream=None, **kwds): """implementation of safe dumper using Ordered Dict Yaml Dumper""" return yaml.dump(data, stream=stream, Dumper=ODYD, **kwds)
python
def safe_dump(data, stream=None, **kwds): """implementation of safe dumper using Ordered Dict Yaml Dumper""" return yaml.dump(data, stream=stream, Dumper=ODYD, **kwds)
[ "def", "safe_dump", "(", "data", ",", "stream", "=", "None", ",", "**", "kwds", ")", ":", "return", "yaml", ".", "dump", "(", "data", ",", "stream", "=", "stream", ",", "Dumper", "=", "ODYD", ",", "**", "kwds", ")" ]
implementation of safe dumper using Ordered Dict Yaml Dumper
[ "implementation", "of", "safe", "dumper", "using", "Ordered", "Dict", "Yaml", "Dumper" ]
b0b42724cc13b1412f5bb5d92fd4c637d6615edb
https://github.com/zerwes/hiyapyco/blob/b0b42724cc13b1412f5bb5d92fd4c637d6615edb/hiyapyco/odyldo.py#L76-L78
train
zerwes/hiyapyco
hiyapyco/__init__.py
dump
def dump(data, **kwds): """dump the data as YAML""" if _usedefaultyamlloader: return yaml.safe_dump(data, **kwds) else: return odyldo.safe_dump(data, **kwds)
python
def dump(data, **kwds): """dump the data as YAML""" if _usedefaultyamlloader: return yaml.safe_dump(data, **kwds) else: return odyldo.safe_dump(data, **kwds)
[ "def", "dump", "(", "data", ",", "**", "kwds", ")", ":", "if", "_usedefaultyamlloader", ":", "return", "yaml", ".", "safe_dump", "(", "data", ",", "**", "kwds", ")", "else", ":", "return", "odyldo", ".", "safe_dump", "(", "data", ",", "**", "kwds", "...
dump the data as YAML
[ "dump", "the", "data", "as", "YAML" ]
b0b42724cc13b1412f5bb5d92fd4c637d6615edb
https://github.com/zerwes/hiyapyco/blob/b0b42724cc13b1412f5bb5d92fd4c637d6615edb/hiyapyco/__init__.py#L413-L418
train
andycasey/ads
ads/search.py
Article.bibtex
def bibtex(self): """Return a BiBTeX entry for the current article.""" warnings.warn("bibtex should be queried with ads.ExportQuery(); You will " "hit API ratelimits very quickly otherwise.", UserWarning) return ExportQuery(bibcodes=self.bibcode, format="bibtex").execute()
python
def bibtex(self): """Return a BiBTeX entry for the current article.""" warnings.warn("bibtex should be queried with ads.ExportQuery(); You will " "hit API ratelimits very quickly otherwise.", UserWarning) return ExportQuery(bibcodes=self.bibcode, format="bibtex").execute()
[ "def", "bibtex", "(", "self", ")", ":", "warnings", ".", "warn", "(", "\"bibtex should be queried with ads.ExportQuery(); You will \"", "\"hit API ratelimits very quickly otherwise.\"", ",", "UserWarning", ")", "return", "ExportQuery", "(", "bibcodes", "=", "self", ".", "...
Return a BiBTeX entry for the current article.
[ "Return", "a", "BiBTeX", "entry", "for", "the", "current", "article", "." ]
928415e202db80658cd8532fa4c3a00d0296b5c5
https://github.com/andycasey/ads/blob/928415e202db80658cd8532fa4c3a00d0296b5c5/ads/search.py#L292-L296
train
andycasey/ads
examples/monthly-institute-publications/stromlo.py
get_pdf
def get_pdf(article, debug=False): """ Download an article PDF from arXiv. :param article: The ADS article to retrieve. :type article: :class:`ads.search.Article` :returns: The binary content of the requested PDF. """ print('Retrieving {0}'.format(article)) i...
python
def get_pdf(article, debug=False): """ Download an article PDF from arXiv. :param article: The ADS article to retrieve. :type article: :class:`ads.search.Article` :returns: The binary content of the requested PDF. """ print('Retrieving {0}'.format(article)) i...
[ "def", "get_pdf", "(", "article", ",", "debug", "=", "False", ")", ":", "print", "(", "'Retrieving {0}'", ".", "format", "(", "article", ")", ")", "identifier", "=", "[", "_", "for", "_", "in", "article", ".", "identifier", "if", "'arXiv'", "in", "_", ...
Download an article PDF from arXiv. :param article: The ADS article to retrieve. :type article: :class:`ads.search.Article` :returns: The binary content of the requested PDF.
[ "Download", "an", "article", "PDF", "from", "arXiv", "." ]
928415e202db80658cd8532fa4c3a00d0296b5c5
https://github.com/andycasey/ads/blob/928415e202db80658cd8532fa4c3a00d0296b5c5/examples/monthly-institute-publications/stromlo.py#L22-L64
train
andycasey/ads
examples/monthly-institute-publications/stromlo.py
summarise_pdfs
def summarise_pdfs(pdfs): """ Collate the first page from each of the PDFs provided into a single PDF. :param pdfs: The contents of several PDF files. :type pdfs: list of str :returns: The contents of single PDF, which can be written directly to disk. """ # Ignore...
python
def summarise_pdfs(pdfs): """ Collate the first page from each of the PDFs provided into a single PDF. :param pdfs: The contents of several PDF files. :type pdfs: list of str :returns: The contents of single PDF, which can be written directly to disk. """ # Ignore...
[ "def", "summarise_pdfs", "(", "pdfs", ")", ":", "print", "(", "'Summarising {0} articles ({1} had errors)'", ".", "format", "(", "len", "(", "pdfs", ")", ",", "pdfs", ".", "count", "(", "None", ")", ")", ")", "pdfs", "=", "[", "_", "for", "_", "in", "p...
Collate the first page from each of the PDFs provided into a single PDF. :param pdfs: The contents of several PDF files. :type pdfs: list of str :returns: The contents of single PDF, which can be written directly to disk.
[ "Collate", "the", "first", "page", "from", "each", "of", "the", "PDFs", "provided", "into", "a", "single", "PDF", "." ]
928415e202db80658cd8532fa4c3a00d0296b5c5
https://github.com/andycasey/ads/blob/928415e202db80658cd8532fa4c3a00d0296b5c5/examples/monthly-institute-publications/stromlo.py#L67-L89
train
andycasey/ads
ads/metrics.py
MetricsQuery.execute
def execute(self): """ Execute the http request to the metrics service """ self.response = MetricsResponse.load_http_response( self.session.post(self.HTTP_ENDPOINT, data=self.json_payload) ) return self.response.metrics
python
def execute(self): """ Execute the http request to the metrics service """ self.response = MetricsResponse.load_http_response( self.session.post(self.HTTP_ENDPOINT, data=self.json_payload) ) return self.response.metrics
[ "def", "execute", "(", "self", ")", ":", "self", ".", "response", "=", "MetricsResponse", ".", "load_http_response", "(", "self", ".", "session", ".", "post", "(", "self", ".", "HTTP_ENDPOINT", ",", "data", "=", "self", ".", "json_payload", ")", ")", "re...
Execute the http request to the metrics service
[ "Execute", "the", "http", "request", "to", "the", "metrics", "service" ]
928415e202db80658cd8532fa4c3a00d0296b5c5
https://github.com/andycasey/ads/blob/928415e202db80658cd8532fa4c3a00d0296b5c5/ads/metrics.py#L47-L54
train
andycasey/ads
ads/base.py
_Singleton.get_info
def get_info(cls): """ Print all of the instantiated Singletons """ return '\n'.join( [str(cls._instances[key]) for key in cls._instances] )
python
def get_info(cls): """ Print all of the instantiated Singletons """ return '\n'.join( [str(cls._instances[key]) for key in cls._instances] )
[ "def", "get_info", "(", "cls", ")", ":", "return", "'\\n'", ".", "join", "(", "[", "str", "(", "cls", ".", "_instances", "[", "key", "]", ")", "for", "key", "in", "cls", ".", "_instances", "]", ")" ]
Print all of the instantiated Singletons
[ "Print", "all", "of", "the", "instantiated", "Singletons" ]
928415e202db80658cd8532fa4c3a00d0296b5c5
https://github.com/andycasey/ads/blob/928415e202db80658cd8532fa4c3a00d0296b5c5/ads/base.py#L25-L31
train
andycasey/ads
ads/base.py
APIResponse.load_http_response
def load_http_response(cls, http_response): """ This method should return an instantiated class and set its response to the requests.Response object. """ if not http_response.ok: raise APIResponseError(http_response.text) c = cls(http_response) c.respo...
python
def load_http_response(cls, http_response): """ This method should return an instantiated class and set its response to the requests.Response object. """ if not http_response.ok: raise APIResponseError(http_response.text) c = cls(http_response) c.respo...
[ "def", "load_http_response", "(", "cls", ",", "http_response", ")", ":", "if", "not", "http_response", ".", "ok", ":", "raise", "APIResponseError", "(", "http_response", ".", "text", ")", "c", "=", "cls", "(", "http_response", ")", "c", ".", "response", "=...
This method should return an instantiated class and set its response to the requests.Response object.
[ "This", "method", "should", "return", "an", "instantiated", "class", "and", "set", "its", "response", "to", "the", "requests", ".", "Response", "object", "." ]
928415e202db80658cd8532fa4c3a00d0296b5c5
https://github.com/andycasey/ads/blob/928415e202db80658cd8532fa4c3a00d0296b5c5/ads/base.py#L88-L100
train
andycasey/ads
ads/base.py
BaseQuery.token
def token(self): """ set the instance attribute `token` following the following logic, stopping whenever a token is found. Raises NoTokenFound is no token is found - environment variables TOKEN_ENVIRON_VARS - file containing plaintext as the contents in TOKEN_FILES ...
python
def token(self): """ set the instance attribute `token` following the following logic, stopping whenever a token is found. Raises NoTokenFound is no token is found - environment variables TOKEN_ENVIRON_VARS - file containing plaintext as the contents in TOKEN_FILES ...
[ "def", "token", "(", "self", ")", ":", "if", "self", ".", "_token", "is", "None", ":", "for", "v", "in", "map", "(", "os", ".", "environ", ".", "get", ",", "TOKEN_ENVIRON_VARS", ")", ":", "if", "v", "is", "not", "None", ":", "self", ".", "_token"...
set the instance attribute `token` following the following logic, stopping whenever a token is found. Raises NoTokenFound is no token is found - environment variables TOKEN_ENVIRON_VARS - file containing plaintext as the contents in TOKEN_FILES - ads.config.token
[ "set", "the", "instance", "attribute", "token", "following", "the", "following", "logic", "stopping", "whenever", "a", "token", "is", "found", ".", "Raises", "NoTokenFound", "is", "no", "token", "is", "found", "-", "environment", "variables", "TOKEN_ENVIRON_VARS",...
928415e202db80658cd8532fa4c3a00d0296b5c5
https://github.com/andycasey/ads/blob/928415e202db80658cd8532fa4c3a00d0296b5c5/ads/base.py#L111-L136
train
andycasey/ads
ads/base.py
BaseQuery.session
def session(self): """ http session interface, transparent proxy to requests.session """ if self._session is None: self._session = requests.session() self._session.headers.update( { "Authorization": "Bearer {}".format(self.token...
python
def session(self): """ http session interface, transparent proxy to requests.session """ if self._session is None: self._session = requests.session() self._session.headers.update( { "Authorization": "Bearer {}".format(self.token...
[ "def", "session", "(", "self", ")", ":", "if", "self", ".", "_session", "is", "None", ":", "self", ".", "_session", "=", "requests", ".", "session", "(", ")", "self", ".", "_session", ".", "headers", ".", "update", "(", "{", "\"Authorization\"", ":", ...
http session interface, transparent proxy to requests.session
[ "http", "session", "interface", "transparent", "proxy", "to", "requests", ".", "session" ]
928415e202db80658cd8532fa4c3a00d0296b5c5
https://github.com/andycasey/ads/blob/928415e202db80658cd8532fa4c3a00d0296b5c5/ads/base.py#L143-L156
train
googledatalab/pydatalab
google/datalab/ml/_metrics.py
Metrics.from_csv
def from_csv(input_csv_pattern, headers=None, schema_file=None): """Create a Metrics instance from csv file pattern. Args: input_csv_pattern: Path to Csv file pattern (with no header). Can be local or GCS path. headers: Csv headers. schema_file: Path to a JSON file containing BigQuery schema....
python
def from_csv(input_csv_pattern, headers=None, schema_file=None): """Create a Metrics instance from csv file pattern. Args: input_csv_pattern: Path to Csv file pattern (with no header). Can be local or GCS path. headers: Csv headers. schema_file: Path to a JSON file containing BigQuery schema....
[ "def", "from_csv", "(", "input_csv_pattern", ",", "headers", "=", "None", ",", "schema_file", "=", "None", ")", ":", "if", "headers", "is", "not", "None", ":", "names", "=", "headers", "elif", "schema_file", "is", "not", "None", ":", "with", "_util", "."...
Create a Metrics instance from csv file pattern. Args: input_csv_pattern: Path to Csv file pattern (with no header). Can be local or GCS path. headers: Csv headers. schema_file: Path to a JSON file containing BigQuery schema. Used if "headers" is None. Returns: a Metrics instance. ...
[ "Create", "a", "Metrics", "instance", "from", "csv", "file", "pattern", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_metrics.py#L56-L81
train
googledatalab/pydatalab
google/datalab/ml/_metrics.py
Metrics.from_bigquery
def from_bigquery(sql): """Create a Metrics instance from a bigquery query or table. Returns: a Metrics instance. Args: sql: A BigQuery table name or a query. """ if isinstance(sql, bq.Query): sql = sql._expanded_sql() parts = sql.split('.') if len(parts) == 1 or len(pa...
python
def from_bigquery(sql): """Create a Metrics instance from a bigquery query or table. Returns: a Metrics instance. Args: sql: A BigQuery table name or a query. """ if isinstance(sql, bq.Query): sql = sql._expanded_sql() parts = sql.split('.') if len(parts) == 1 or len(pa...
[ "def", "from_bigquery", "(", "sql", ")", ":", "if", "isinstance", "(", "sql", ",", "bq", ".", "Query", ")", ":", "sql", "=", "sql", ".", "_expanded_sql", "(", ")", "parts", "=", "sql", ".", "split", "(", "'.'", ")", "if", "len", "(", "parts", ")"...
Create a Metrics instance from a bigquery query or table. Returns: a Metrics instance. Args: sql: A BigQuery table name or a query.
[ "Create", "a", "Metrics", "instance", "from", "a", "bigquery", "query", "or", "table", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_metrics.py#L84-L104
train
googledatalab/pydatalab
google/datalab/ml/_metrics.py
Metrics._get_data_from_csv_files
def _get_data_from_csv_files(self): """Get data from input csv files.""" all_df = [] for file_name in self._input_csv_files: with _util.open_local_or_gcs(file_name, mode='r') as f: all_df.append(pd.read_csv(f, names=self._headers)) df = pd.concat(all_df, ignore_index=True) return df
python
def _get_data_from_csv_files(self): """Get data from input csv files.""" all_df = [] for file_name in self._input_csv_files: with _util.open_local_or_gcs(file_name, mode='r') as f: all_df.append(pd.read_csv(f, names=self._headers)) df = pd.concat(all_df, ignore_index=True) return df
[ "def", "_get_data_from_csv_files", "(", "self", ")", ":", "all_df", "=", "[", "]", "for", "file_name", "in", "self", ".", "_input_csv_files", ":", "with", "_util", ".", "open_local_or_gcs", "(", "file_name", ",", "mode", "=", "'r'", ")", "as", "f", ":", ...
Get data from input csv files.
[ "Get", "data", "from", "input", "csv", "files", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_metrics.py#L106-L114
train
googledatalab/pydatalab
google/datalab/ml/_metrics.py
Metrics._get_data_from_bigquery
def _get_data_from_bigquery(self, queries): """Get data from bigquery table or query.""" all_df = [] for query in queries: all_df.append(query.execute().result().to_dataframe()) df = pd.concat(all_df, ignore_index=True) return df
python
def _get_data_from_bigquery(self, queries): """Get data from bigquery table or query.""" all_df = [] for query in queries: all_df.append(query.execute().result().to_dataframe()) df = pd.concat(all_df, ignore_index=True) return df
[ "def", "_get_data_from_bigquery", "(", "self", ",", "queries", ")", ":", "all_df", "=", "[", "]", "for", "query", "in", "queries", ":", "all_df", ".", "append", "(", "query", ".", "execute", "(", ")", ".", "result", "(", ")", ".", "to_dataframe", "(", ...
Get data from bigquery table or query.
[ "Get", "data", "from", "bigquery", "table", "or", "query", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_metrics.py#L116-L123
train
googledatalab/pydatalab
google/datalab/bigquery/_udf.py
UDF._expanded_sql
def _expanded_sql(self): """Get the expanded BigQuery SQL string of this UDF Returns The expanded SQL string of this UDF """ if not self._sql: self._sql = UDF._build_udf(self._name, self._code, self._return_type, self._params, self._language, self._imports) ...
python
def _expanded_sql(self): """Get the expanded BigQuery SQL string of this UDF Returns The expanded SQL string of this UDF """ if not self._sql: self._sql = UDF._build_udf(self._name, self._code, self._return_type, self._params, self._language, self._imports) ...
[ "def", "_expanded_sql", "(", "self", ")", ":", "if", "not", "self", ".", "_sql", ":", "self", ".", "_sql", "=", "UDF", ".", "_build_udf", "(", "self", ".", "_name", ",", "self", ".", "_code", ",", "self", ".", "_return_type", ",", "self", ".", "_pa...
Get the expanded BigQuery SQL string of this UDF Returns The expanded SQL string of this UDF
[ "Get", "the", "expanded", "BigQuery", "SQL", "string", "of", "this", "UDF" ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_udf.py#L65-L74
train
googledatalab/pydatalab
google/datalab/bigquery/_udf.py
UDF._build_udf
def _build_udf(name, code, return_type, params, language, imports): """Creates the UDF part of a BigQuery query using its pieces Args: name: the name of the javascript function code: function body implementing the logic. return_type: BigQuery data type of the function return. See supported da...
python
def _build_udf(name, code, return_type, params, language, imports): """Creates the UDF part of a BigQuery query using its pieces Args: name: the name of the javascript function code: function body implementing the logic. return_type: BigQuery data type of the function return. See supported da...
[ "def", "_build_udf", "(", "name", ",", "code", ",", "return_type", ",", "params", ",", "language", ",", "imports", ")", ":", "params", "=", "','", ".", "join", "(", "[", "'%s %s'", "%", "named_param", "for", "named_param", "in", "params", "]", ")", "im...
Creates the UDF part of a BigQuery query using its pieces Args: name: the name of the javascript function code: function body implementing the logic. return_type: BigQuery data type of the function return. See supported data types in the BigQuery docs params: dictionary of parameter...
[ "Creates", "the", "UDF", "part", "of", "a", "BigQuery", "query", "using", "its", "pieces" ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_udf.py#L83-L116
train
googledatalab/pydatalab
google/datalab/storage/_bucket.py
BucketMetadata.created_on
def created_on(self): """The created timestamp of the bucket as a datetime.datetime.""" s = self._info.get('timeCreated', None) return dateutil.parser.parse(s) if s else None
python
def created_on(self): """The created timestamp of the bucket as a datetime.datetime.""" s = self._info.get('timeCreated', None) return dateutil.parser.parse(s) if s else None
[ "def", "created_on", "(", "self", ")", ":", "s", "=", "self", ".", "_info", ".", "get", "(", "'timeCreated'", ",", "None", ")", "return", "dateutil", ".", "parser", ".", "parse", "(", "s", ")", "if", "s", "else", "None" ]
The created timestamp of the bucket as a datetime.datetime.
[ "The", "created", "timestamp", "of", "the", "bucket", "as", "a", "datetime", ".", "datetime", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/_bucket.py#L71-L74
train
googledatalab/pydatalab
google/datalab/storage/_bucket.py
Bucket.metadata
def metadata(self): """Retrieves metadata about the bucket. Returns: A BucketMetadata instance with information about this bucket. Raises: Exception if there was an error requesting the bucket's metadata. """ if self._info is None: try: self._info = self._api.buckets_get(s...
python
def metadata(self): """Retrieves metadata about the bucket. Returns: A BucketMetadata instance with information about this bucket. Raises: Exception if there was an error requesting the bucket's metadata. """ if self._info is None: try: self._info = self._api.buckets_get(s...
[ "def", "metadata", "(", "self", ")", ":", "if", "self", ".", "_info", "is", "None", ":", "try", ":", "self", ".", "_info", "=", "self", ".", "_api", ".", "buckets_get", "(", "self", ".", "_name", ")", "except", "Exception", "as", "e", ":", "raise",...
Retrieves metadata about the bucket. Returns: A BucketMetadata instance with information about this bucket. Raises: Exception if there was an error requesting the bucket's metadata.
[ "Retrieves", "metadata", "about", "the", "bucket", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/_bucket.py#L118-L132
train
googledatalab/pydatalab
google/datalab/storage/_bucket.py
Bucket.object
def object(self, key): """Retrieves a Storage Object for the specified key in this bucket. The object need not exist. Args: key: the key of the object within the bucket. Returns: An Object instance representing the specified key. """ return _object.Object(self._name, key, context=s...
python
def object(self, key): """Retrieves a Storage Object for the specified key in this bucket. The object need not exist. Args: key: the key of the object within the bucket. Returns: An Object instance representing the specified key. """ return _object.Object(self._name, key, context=s...
[ "def", "object", "(", "self", ",", "key", ")", ":", "return", "_object", ".", "Object", "(", "self", ".", "_name", ",", "key", ",", "context", "=", "self", ".", "_context", ")" ]
Retrieves a Storage Object for the specified key in this bucket. The object need not exist. Args: key: the key of the object within the bucket. Returns: An Object instance representing the specified key.
[ "Retrieves", "a", "Storage", "Object", "for", "the", "specified", "key", "in", "this", "bucket", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/_bucket.py#L134-L144
train
googledatalab/pydatalab
google/datalab/storage/_bucket.py
Bucket.objects
def objects(self, prefix=None, delimiter=None): """Get an iterator for the objects within this bucket. Args: prefix: an optional prefix to match objects. delimiter: an optional string to simulate directory-like semantics. The returned objects will be those whose names do not contain the ...
python
def objects(self, prefix=None, delimiter=None): """Get an iterator for the objects within this bucket. Args: prefix: an optional prefix to match objects. delimiter: an optional string to simulate directory-like semantics. The returned objects will be those whose names do not contain the ...
[ "def", "objects", "(", "self", ",", "prefix", "=", "None", ",", "delimiter", "=", "None", ")", ":", "return", "_object", ".", "Objects", "(", "self", ".", "_name", ",", "prefix", ",", "delimiter", ",", "context", "=", "self", ".", "_context", ")" ]
Get an iterator for the objects within this bucket. Args: prefix: an optional prefix to match objects. delimiter: an optional string to simulate directory-like semantics. The returned objects will be those whose names do not contain the delimiter after the prefix. For the remainin...
[ "Get", "an", "iterator", "for", "the", "objects", "within", "this", "bucket", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/_bucket.py#L146-L158
train
googledatalab/pydatalab
google/datalab/storage/_bucket.py
Bucket.delete
def delete(self): """Deletes the bucket. Raises: Exception if there was an error deleting the bucket. """ if self.exists(): try: self._api.buckets_delete(self._name) except Exception as e: raise e
python
def delete(self): """Deletes the bucket. Raises: Exception if there was an error deleting the bucket. """ if self.exists(): try: self._api.buckets_delete(self._name) except Exception as e: raise e
[ "def", "delete", "(", "self", ")", ":", "if", "self", ".", "exists", "(", ")", ":", "try", ":", "self", ".", "_api", ".", "buckets_delete", "(", "self", ".", "_name", ")", "except", "Exception", "as", "e", ":", "raise", "e" ]
Deletes the bucket. Raises: Exception if there was an error deleting the bucket.
[ "Deletes", "the", "bucket", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/_bucket.py#L185-L195
train
googledatalab/pydatalab
google/datalab/storage/_bucket.py
Buckets.contains
def contains(self, name): """Checks if the specified bucket exists. Args: name: the name of the bucket to lookup. Returns: True if the bucket exists; False otherwise. Raises: Exception if there was an error requesting information about the bucket. """ try: self._api.buck...
python
def contains(self, name): """Checks if the specified bucket exists. Args: name: the name of the bucket to lookup. Returns: True if the bucket exists; False otherwise. Raises: Exception if there was an error requesting information about the bucket. """ try: self._api.buck...
[ "def", "contains", "(", "self", ",", "name", ")", ":", "try", ":", "self", ".", "_api", ".", "buckets_get", "(", "name", ")", "except", "google", ".", "datalab", ".", "utils", ".", "RequestException", "as", "e", ":", "if", "e", ".", "status", "==", ...
Checks if the specified bucket exists. Args: name: the name of the bucket to lookup. Returns: True if the bucket exists; False otherwise. Raises: Exception if there was an error requesting information about the bucket.
[ "Checks", "if", "the", "specified", "bucket", "exists", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/_bucket.py#L215-L233
train
googledatalab/pydatalab
datalab/storage/_bucket.py
Bucket.item
def item(self, key): """Retrieves an Item object for the specified key in this bucket. The item need not exist. Args: key: the key of the item within the bucket. Returns: An Item instance representing the specified key. """ return _item.Item(self._name, key, context=self._context)
python
def item(self, key): """Retrieves an Item object for the specified key in this bucket. The item need not exist. Args: key: the key of the item within the bucket. Returns: An Item instance representing the specified key. """ return _item.Item(self._name, key, context=self._context)
[ "def", "item", "(", "self", ",", "key", ")", ":", "return", "_item", ".", "Item", "(", "self", ".", "_name", ",", "key", ",", "context", "=", "self", ".", "_context", ")" ]
Retrieves an Item object for the specified key in this bucket. The item need not exist. Args: key: the key of the item within the bucket. Returns: An Item instance representing the specified key.
[ "Retrieves", "an", "Item", "object", "for", "the", "specified", "key", "in", "this", "bucket", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_bucket.py#L134-L144
train
googledatalab/pydatalab
datalab/storage/_bucket.py
Bucket.items
def items(self, prefix=None, delimiter=None): """Get an iterator for the items within this bucket. Args: prefix: an optional prefix to match items. delimiter: an optional string to simulate directory-like semantics. The returned items will be those whose names do not contain the delimite...
python
def items(self, prefix=None, delimiter=None): """Get an iterator for the items within this bucket. Args: prefix: an optional prefix to match items. delimiter: an optional string to simulate directory-like semantics. The returned items will be those whose names do not contain the delimite...
[ "def", "items", "(", "self", ",", "prefix", "=", "None", ",", "delimiter", "=", "None", ")", ":", "return", "_item", ".", "Items", "(", "self", ".", "_name", ",", "prefix", ",", "delimiter", ",", "context", "=", "self", ".", "_context", ")" ]
Get an iterator for the items within this bucket. Args: prefix: an optional prefix to match items. delimiter: an optional string to simulate directory-like semantics. The returned items will be those whose names do not contain the delimiter after the prefix. For the remaining item...
[ "Get", "an", "iterator", "for", "the", "items", "within", "this", "bucket", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_bucket.py#L146-L158
train
googledatalab/pydatalab
datalab/storage/_bucket.py
Bucket.create
def create(self, project_id=None): """Creates the bucket. Args: project_id: the project in which to create the bucket. Returns: The bucket. Raises: Exception if there was an error creating the bucket. """ if not self.exists(): if project_id is None: project_id = ...
python
def create(self, project_id=None): """Creates the bucket. Args: project_id: the project in which to create the bucket. Returns: The bucket. Raises: Exception if there was an error creating the bucket. """ if not self.exists(): if project_id is None: project_id = ...
[ "def", "create", "(", "self", ",", "project_id", "=", "None", ")", ":", "if", "not", "self", ".", "exists", "(", ")", ":", "if", "project_id", "is", "None", ":", "project_id", "=", "self", ".", "_api", ".", "project_id", "try", ":", "self", ".", "_...
Creates the bucket. Args: project_id: the project in which to create the bucket. Returns: The bucket. Raises: Exception if there was an error creating the bucket.
[ "Creates", "the", "bucket", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_bucket.py#L167-L184
train
googledatalab/pydatalab
datalab/storage/_bucket.py
Buckets.create
def create(self, name): """Creates a new bucket. Args: name: a unique name for the new bucket. Returns: The newly created bucket. Raises: Exception if there was an error creating the bucket. """ return Bucket(name, context=self._context).create(self._project_id)
python
def create(self, name): """Creates a new bucket. Args: name: a unique name for the new bucket. Returns: The newly created bucket. Raises: Exception if there was an error creating the bucket. """ return Bucket(name, context=self._context).create(self._project_id)
[ "def", "create", "(", "self", ",", "name", ")", ":", "return", "Bucket", "(", "name", ",", "context", "=", "self", ".", "_context", ")", ".", "create", "(", "self", ".", "_project_id", ")" ]
Creates a new bucket. Args: name: a unique name for the new bucket. Returns: The newly created bucket. Raises: Exception if there was an error creating the bucket.
[ "Creates", "a", "new", "bucket", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_bucket.py#L238-L248
train
googledatalab/pydatalab
solutionbox/structured_data/mltoolbox/regression/dnn/_regression_dnn.py
train
def train(train_dataset, eval_dataset, analysis_dir, output_dir, features, layer_sizes, max_steps=5000, num_epochs=None, train_batch_size=100, eval_batch_size=16, min_eval_frequency=100, learning_rate=0.01, ...
python
def train(train_dataset, eval_dataset, analysis_dir, output_dir, features, layer_sizes, max_steps=5000, num_epochs=None, train_batch_size=100, eval_batch_size=16, min_eval_frequency=100, learning_rate=0.01, ...
[ "def", "train", "(", "train_dataset", ",", "eval_dataset", ",", "analysis_dir", ",", "output_dir", ",", "features", ",", "layer_sizes", ",", "max_steps", "=", "5000", ",", "num_epochs", "=", "None", ",", "train_batch_size", "=", "100", ",", "eval_batch_size", ...
Blocking version of train_async. See documentation for train_async.
[ "Blocking", "version", "of", "train_async", ".", "See", "documentation", "for", "train_async", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/regression/dnn/_regression_dnn.py#L4-L39
train
googledatalab/pydatalab
datalab/stackdriver/monitoring/_resource.py
ResourceDescriptors.list
def list(self, pattern='*'): """Returns a list of resource descriptors that match the filters. Args: pattern: An optional pattern to further filter the descriptors. This can include Unix shell-style wildcards. E.g. ``"aws*"``, ``"*cluster*"``. Returns: A list of ResourceDescriptor ob...
python
def list(self, pattern='*'): """Returns a list of resource descriptors that match the filters. Args: pattern: An optional pattern to further filter the descriptors. This can include Unix shell-style wildcards. E.g. ``"aws*"``, ``"*cluster*"``. Returns: A list of ResourceDescriptor ob...
[ "def", "list", "(", "self", ",", "pattern", "=", "'*'", ")", ":", "if", "self", ".", "_descriptors", "is", "None", ":", "self", ".", "_descriptors", "=", "self", ".", "_client", ".", "list_resource_descriptors", "(", "filter_string", "=", "self", ".", "_...
Returns a list of resource descriptors that match the filters. Args: pattern: An optional pattern to further filter the descriptors. This can include Unix shell-style wildcards. E.g. ``"aws*"``, ``"*cluster*"``. Returns: A list of ResourceDescriptor objects that match the filters.
[ "Returns", "a", "list", "of", "resource", "descriptors", "that", "match", "the", "filters", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/stackdriver/monitoring/_resource.py#L43-L57
train
googledatalab/pydatalab
google/datalab/storage/commands/_storage.py
_gcs_list_buckets
def _gcs_list_buckets(project, pattern): """ List all Google Cloud Storage buckets that match a pattern. """ data = [{'Bucket': 'gs://' + bucket.name, 'Created': bucket.metadata.created_on} for bucket in google.datalab.storage.Buckets(_make_context(project)) if fnmatch.fnmatch(bucket.name, patte...
python
def _gcs_list_buckets(project, pattern): """ List all Google Cloud Storage buckets that match a pattern. """ data = [{'Bucket': 'gs://' + bucket.name, 'Created': bucket.metadata.created_on} for bucket in google.datalab.storage.Buckets(_make_context(project)) if fnmatch.fnmatch(bucket.name, patte...
[ "def", "_gcs_list_buckets", "(", "project", ",", "pattern", ")", ":", "data", "=", "[", "{", "'Bucket'", ":", "'gs://'", "+", "bucket", ".", "name", ",", "'Created'", ":", "bucket", ".", "metadata", ".", "created_on", "}", "for", "bucket", "in", "google"...
List all Google Cloud Storage buckets that match a pattern.
[ "List", "all", "Google", "Cloud", "Storage", "buckets", "that", "match", "a", "pattern", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/commands/_storage.py#L278-L283
train
googledatalab/pydatalab
google/datalab/storage/commands/_storage.py
_gcs_list_keys
def _gcs_list_keys(bucket, pattern): """ List all Google Cloud Storage keys in a specified bucket that match a pattern. """ data = [{'Name': obj.metadata.name, 'Type': obj.metadata.content_type, 'Size': obj.metadata.size, 'Updated': obj.metadata.updated_on} for obj in _gcs...
python
def _gcs_list_keys(bucket, pattern): """ List all Google Cloud Storage keys in a specified bucket that match a pattern. """ data = [{'Name': obj.metadata.name, 'Type': obj.metadata.content_type, 'Size': obj.metadata.size, 'Updated': obj.metadata.updated_on} for obj in _gcs...
[ "def", "_gcs_list_keys", "(", "bucket", ",", "pattern", ")", ":", "data", "=", "[", "{", "'Name'", ":", "obj", ".", "metadata", ".", "name", ",", "'Type'", ":", "obj", ".", "metadata", ".", "content_type", ",", "'Size'", ":", "obj", ".", "metadata", ...
List all Google Cloud Storage keys in a specified bucket that match a pattern.
[ "List", "all", "Google", "Cloud", "Storage", "keys", "in", "a", "specified", "bucket", "that", "match", "a", "pattern", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/commands/_storage.py#L296-L303
train
googledatalab/pydatalab
solutionbox/ml_workbench/tensorflow/transform.py
prepare_image_transforms
def prepare_image_transforms(element, image_columns): """Replace an images url with its jpeg bytes. Args: element: one input row, as a dict image_columns: list of columns that are image paths Return: element, where each image file path has been replaced by a base64 image. """ import base64 im...
python
def prepare_image_transforms(element, image_columns): """Replace an images url with its jpeg bytes. Args: element: one input row, as a dict image_columns: list of columns that are image paths Return: element, where each image file path has been replaced by a base64 image. """ import base64 im...
[ "def", "prepare_image_transforms", "(", "element", ",", "image_columns", ")", ":", "import", "base64", "import", "cStringIO", "from", "PIL", "import", "Image", "from", "tensorflow", ".", "python", ".", "lib", ".", "io", "import", "file_io", "as", "tf_file_io", ...
Replace an images url with its jpeg bytes. Args: element: one input row, as a dict image_columns: list of columns that are image paths Return: element, where each image file path has been replaced by a base64 image.
[ "Replace", "an", "images", "url", "with", "its", "jpeg", "bytes", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/tensorflow/transform.py#L197-L238
train
googledatalab/pydatalab
solutionbox/ml_workbench/tensorflow/transform.py
decode_csv
def decode_csv(csv_string, column_names): """Parse a csv line into a dict. Args: csv_string: a csv string. May contain missing values "a,,c" column_names: list of column names Returns: Dict of {column_name, value_from_csv}. If there are missing values, value_from_csv will be ''. """ import ...
python
def decode_csv(csv_string, column_names): """Parse a csv line into a dict. Args: csv_string: a csv string. May contain missing values "a,,c" column_names: list of column names Returns: Dict of {column_name, value_from_csv}. If there are missing values, value_from_csv will be ''. """ import ...
[ "def", "decode_csv", "(", "csv_string", ",", "column_names", ")", ":", "import", "csv", "r", "=", "next", "(", "csv", ".", "reader", "(", "[", "csv_string", "]", ")", ")", "if", "len", "(", "r", ")", "!=", "len", "(", "column_names", ")", ":", "rai...
Parse a csv line into a dict. Args: csv_string: a csv string. May contain missing values "a,,c" column_names: list of column names Returns: Dict of {column_name, value_from_csv}. If there are missing values, value_from_csv will be ''.
[ "Parse", "a", "csv", "line", "into", "a", "dict", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/tensorflow/transform.py#L355-L370
train
googledatalab/pydatalab
solutionbox/ml_workbench/tensorflow/transform.py
encode_csv
def encode_csv(data_dict, column_names): """Builds a csv string. Args: data_dict: dict of {column_name: 1 value} column_names: list of column names Returns: A csv string version of data_dict """ import csv import six values = [str(data_dict[x]) for x in column_names] str_buff = six.StringI...
python
def encode_csv(data_dict, column_names): """Builds a csv string. Args: data_dict: dict of {column_name: 1 value} column_names: list of column names Returns: A csv string version of data_dict """ import csv import six values = [str(data_dict[x]) for x in column_names] str_buff = six.StringI...
[ "def", "encode_csv", "(", "data_dict", ",", "column_names", ")", ":", "import", "csv", "import", "six", "values", "=", "[", "str", "(", "data_dict", "[", "x", "]", ")", "for", "x", "in", "column_names", "]", "str_buff", "=", "six", ".", "StringIO", "("...
Builds a csv string. Args: data_dict: dict of {column_name: 1 value} column_names: list of column names Returns: A csv string version of data_dict
[ "Builds", "a", "csv", "string", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/tensorflow/transform.py#L373-L389
train
googledatalab/pydatalab
solutionbox/ml_workbench/tensorflow/transform.py
serialize_example
def serialize_example(transformed_json_data, info_dict): """Makes a serialized tf.example. Args: transformed_json_data: dict of transformed data. info_dict: output of feature_transforms.get_transfrormed_feature_info() Returns: The serialized tf.example version of transformed_json_data. """ impor...
python
def serialize_example(transformed_json_data, info_dict): """Makes a serialized tf.example. Args: transformed_json_data: dict of transformed data. info_dict: output of feature_transforms.get_transfrormed_feature_info() Returns: The serialized tf.example version of transformed_json_data. """ impor...
[ "def", "serialize_example", "(", "transformed_json_data", ",", "info_dict", ")", ":", "import", "six", "import", "tensorflow", "as", "tf", "def", "_make_int64_list", "(", "x", ")", ":", "return", "tf", ".", "train", ".", "Feature", "(", "int64_list", "=", "t...
Makes a serialized tf.example. Args: transformed_json_data: dict of transformed data. info_dict: output of feature_transforms.get_transfrormed_feature_info() Returns: The serialized tf.example version of transformed_json_data.
[ "Makes", "a", "serialized", "tf", ".", "example", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/tensorflow/transform.py#L392-L428
train
googledatalab/pydatalab
solutionbox/ml_workbench/tensorflow/transform.py
preprocess
def preprocess(pipeline, args): """Transfrom csv data into transfromed tf.example files. Outline: 1) read the input data (as csv or bigquery) into a dict format 2) replace image paths with base64 encoded image files 3) build a csv input string with images paths replaced with base64. This matche...
python
def preprocess(pipeline, args): """Transfrom csv data into transfromed tf.example files. Outline: 1) read the input data (as csv or bigquery) into a dict format 2) replace image paths with base64 encoded image files 3) build a csv input string with images paths replaced with base64. This matche...
[ "def", "preprocess", "(", "pipeline", ",", "args", ")", ":", "from", "tensorflow", ".", "python", ".", "lib", ".", "io", "import", "file_io", "from", "trainer", "import", "feature_transforms", "schema", "=", "json", ".", "loads", "(", "file_io", ".", "read...
Transfrom csv data into transfromed tf.example files. Outline: 1) read the input data (as csv or bigquery) into a dict format 2) replace image paths with base64 encoded image files 3) build a csv input string with images paths replaced with base64. This matches the serving csv that a trained mode...
[ "Transfrom", "csv", "data", "into", "transfromed", "tf", ".", "example", "files", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/tensorflow/transform.py#L431-L506
train
googledatalab/pydatalab
solutionbox/ml_workbench/tensorflow/transform.py
main
def main(argv=None): """Run Preprocessing as a Dataflow.""" args = parse_arguments(sys.argv if argv is None else argv) temp_dir = os.path.join(args.output, 'tmp') if args.cloud: pipeline_name = 'DataflowRunner' else: pipeline_name = 'DirectRunner' # Suppress TF warnings. os.environ['TF_CPP_MI...
python
def main(argv=None): """Run Preprocessing as a Dataflow.""" args = parse_arguments(sys.argv if argv is None else argv) temp_dir = os.path.join(args.output, 'tmp') if args.cloud: pipeline_name = 'DataflowRunner' else: pipeline_name = 'DirectRunner' # Suppress TF warnings. os.environ['TF_CPP_MI...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "args", "=", "parse_arguments", "(", "sys", ".", "argv", "if", "argv", "is", "None", "else", "argv", ")", "temp_dir", "=", "os", ".", "path", ".", "join", "(", "args", ".", "output", ",", "'tmp'", ...
Run Preprocessing as a Dataflow.
[ "Run", "Preprocessing", "as", "a", "Dataflow", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/tensorflow/transform.py#L509-L545
train
googledatalab/pydatalab
solutionbox/ml_workbench/tensorflow/transform.py
TransformFeaturesDoFn.start_bundle
def start_bundle(self, element=None): """Build the transfromation graph once.""" import tensorflow as tf from trainer import feature_transforms g = tf.Graph() session = tf.Session(graph=g) # Build the transformation graph with g.as_default(): transformed_features, _, placeholders = (...
python
def start_bundle(self, element=None): """Build the transfromation graph once.""" import tensorflow as tf from trainer import feature_transforms g = tf.Graph() session = tf.Session(graph=g) # Build the transformation graph with g.as_default(): transformed_features, _, placeholders = (...
[ "def", "start_bundle", "(", "self", ",", "element", "=", "None", ")", ":", "import", "tensorflow", "as", "tf", "from", "trainer", "import", "feature_transforms", "g", "=", "tf", ".", "Graph", "(", ")", "session", "=", "tf", ".", "Session", "(", "graph", ...
Build the transfromation graph once.
[ "Build", "the", "transfromation", "graph", "once", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/tensorflow/transform.py#L278-L299
train
googledatalab/pydatalab
solutionbox/ml_workbench/tensorflow/transform.py
TransformFeaturesDoFn.process
def process(self, element): """Run the transformation graph on batched input data Args: element: list of csv strings, representing one batch input to the TF graph. Returns: dict containing the transformed data. Results are un-batched. Sparse tensors are converted to lists. """ im...
python
def process(self, element): """Run the transformation graph on batched input data Args: element: list of csv strings, representing one batch input to the TF graph. Returns: dict containing the transformed data. Results are un-batched. Sparse tensors are converted to lists. """ im...
[ "def", "process", "(", "self", ",", "element", ")", ":", "import", "apache_beam", "as", "beam", "import", "six", "import", "tensorflow", "as", "tf", "tf", ".", "logging", ".", "set_verbosity", "(", "tf", ".", "logging", ".", "ERROR", ")", "try", ":", "...
Run the transformation graph on batched input data Args: element: list of csv strings, representing one batch input to the TF graph. Returns: dict containing the transformed data. Results are un-batched. Sparse tensors are converted to lists.
[ "Run", "the", "transformation", "graph", "on", "batched", "input", "data" ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/tensorflow/transform.py#L304-L352
train
googledatalab/pydatalab
google/datalab/bigquery/_parser.py
Parser.parse_row
def parse_row(schema, data): """Parses a row from query results into an equivalent object. Args: schema: the array of fields defining the schema of the data. data: the JSON row from a query result. Returns: The parsed row object. """ def parse_value(data_type, value): """Par...
python
def parse_row(schema, data): """Parses a row from query results into an equivalent object. Args: schema: the array of fields defining the schema of the data. data: the JSON row from a query result. Returns: The parsed row object. """ def parse_value(data_type, value): """Par...
[ "def", "parse_row", "(", "schema", ",", "data", ")", ":", "def", "parse_value", "(", "data_type", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "if", "value", "==", "'null'", ":", "value", "=", "None", "elif", "data_type", "==", "'...
Parses a row from query results into an equivalent object. Args: schema: the array of fields defining the schema of the data. data: the JSON row from a query result. Returns: The parsed row object.
[ "Parses", "a", "row", "from", "query", "results", "into", "an", "equivalent", "object", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_parser.py#L31-L89
train
googledatalab/pydatalab
google/datalab/contrib/mlworkbench/_local_predict.py
_tf_predict
def _tf_predict(model_dir, input_csvlines): """Prediction with a tf savedmodel. Args: model_dir: directory that contains a saved model input_csvlines: list of csv strings Returns: Dict in the form tensor_name:prediction_list. Note that the value is always a list, even if there was only 1 row...
python
def _tf_predict(model_dir, input_csvlines): """Prediction with a tf savedmodel. Args: model_dir: directory that contains a saved model input_csvlines: list of csv strings Returns: Dict in the form tensor_name:prediction_list. Note that the value is always a list, even if there was only 1 row...
[ "def", "_tf_predict", "(", "model_dir", ",", "input_csvlines", ")", ":", "with", "tf", ".", "Graph", "(", ")", ".", "as_default", "(", ")", ",", "tf", ".", "Session", "(", ")", "as", "sess", ":", "input_alias_map", ",", "output_alias_map", "=", "_tf_load...
Prediction with a tf savedmodel. Args: model_dir: directory that contains a saved model input_csvlines: list of csv strings Returns: Dict in the form tensor_name:prediction_list. Note that the value is always a list, even if there was only 1 row in input_csvlines.
[ "Prediction", "with", "a", "tf", "savedmodel", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_local_predict.py#L56-L87
train
googledatalab/pydatalab
google/datalab/contrib/mlworkbench/_local_predict.py
_download_images
def _download_images(data, img_cols): """Download images given image columns.""" images = collections.defaultdict(list) for d in data: for img_col in img_cols: if d.get(img_col, None): if isinstance(d[img_col], Image.Image): # If it is already an Image, just copy and continue. ...
python
def _download_images(data, img_cols): """Download images given image columns.""" images = collections.defaultdict(list) for d in data: for img_col in img_cols: if d.get(img_col, None): if isinstance(d[img_col], Image.Image): # If it is already an Image, just copy and continue. ...
[ "def", "_download_images", "(", "data", ",", "img_cols", ")", ":", "images", "=", "collections", ".", "defaultdict", "(", "list", ")", "for", "d", "in", "data", ":", "for", "img_col", "in", "img_cols", ":", "if", "d", ".", "get", "(", "img_col", ",", ...
Download images given image columns.
[ "Download", "images", "given", "image", "columns", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_local_predict.py#L90-L108
train
googledatalab/pydatalab
google/datalab/contrib/mlworkbench/_local_predict.py
_get_predicton_csv_lines
def _get_predicton_csv_lines(data, headers, images): """Create CSV lines from list-of-dict data.""" if images: data = copy.deepcopy(data) for img_col in images: for d, im in zip(data, images[img_col]): if im == '': continue im = im.copy() im.thumbnail((299, 299), Im...
python
def _get_predicton_csv_lines(data, headers, images): """Create CSV lines from list-of-dict data.""" if images: data = copy.deepcopy(data) for img_col in images: for d, im in zip(data, images[img_col]): if im == '': continue im = im.copy() im.thumbnail((299, 299), Im...
[ "def", "_get_predicton_csv_lines", "(", "data", ",", "headers", ",", "images", ")", ":", "if", "images", ":", "data", "=", "copy", ".", "deepcopy", "(", "data", ")", "for", "img_col", "in", "images", ":", "for", "d", ",", "im", "in", "zip", "(", "dat...
Create CSV lines from list-of-dict data.
[ "Create", "CSV", "lines", "from", "list", "-", "of", "-", "dict", "data", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_local_predict.py#L111-L135
train
googledatalab/pydatalab
google/datalab/contrib/mlworkbench/_local_predict.py
_get_display_data_with_images
def _get_display_data_with_images(data, images): """Create display data by converting image urls to base64 strings.""" if not images: return data display_data = copy.deepcopy(data) for img_col in images: for d, im in zip(display_data, images[img_col]): if im == '': d[img_col + '_image'] ...
python
def _get_display_data_with_images(data, images): """Create display data by converting image urls to base64 strings.""" if not images: return data display_data = copy.deepcopy(data) for img_col in images: for d, im in zip(display_data, images[img_col]): if im == '': d[img_col + '_image'] ...
[ "def", "_get_display_data_with_images", "(", "data", ",", "images", ")", ":", "if", "not", "images", ":", "return", "data", "display_data", "=", "copy", ".", "deepcopy", "(", "data", ")", "for", "img_col", "in", "images", ":", "for", "d", ",", "im", "in"...
Create display data by converting image urls to base64 strings.
[ "Create", "display", "data", "by", "converting", "image", "urls", "to", "base64", "strings", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_local_predict.py#L138-L157
train
googledatalab/pydatalab
google/datalab/contrib/mlworkbench/_local_predict.py
get_model_schema_and_features
def get_model_schema_and_features(model_dir): """Get a local model's schema and features config. Args: model_dir: local or GCS path of a model. Returns: A tuple of schema (list) and features config (dict). """ schema_file = os.path.join(model_dir, 'assets.extra', 'schema.json') schema = json.loads(...
python
def get_model_schema_and_features(model_dir): """Get a local model's schema and features config. Args: model_dir: local or GCS path of a model. Returns: A tuple of schema (list) and features config (dict). """ schema_file = os.path.join(model_dir, 'assets.extra', 'schema.json') schema = json.loads(...
[ "def", "get_model_schema_and_features", "(", "model_dir", ")", ":", "schema_file", "=", "os", ".", "path", ".", "join", "(", "model_dir", ",", "'assets.extra'", ",", "'schema.json'", ")", "schema", "=", "json", ".", "loads", "(", "file_io", ".", "read_file_to_...
Get a local model's schema and features config. Args: model_dir: local or GCS path of a model. Returns: A tuple of schema (list) and features config (dict).
[ "Get", "a", "local", "model", "s", "schema", "and", "features", "config", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_local_predict.py#L160-L172
train
googledatalab/pydatalab
google/datalab/contrib/mlworkbench/_local_predict.py
get_prediction_results
def get_prediction_results(model_dir_or_id, data, headers, img_cols=None, cloud=False, with_source=True, show_image=True): """ Predict with a specified model. It predicts with the model, join source data with prediction results, and formats the results so they can be displayed nicely i...
python
def get_prediction_results(model_dir_or_id, data, headers, img_cols=None, cloud=False, with_source=True, show_image=True): """ Predict with a specified model. It predicts with the model, join source data with prediction results, and formats the results so they can be displayed nicely i...
[ "def", "get_prediction_results", "(", "model_dir_or_id", ",", "data", ",", "headers", ",", "img_cols", "=", "None", ",", "cloud", "=", "False", ",", "with_source", "=", "True", ",", "show_image", "=", "True", ")", ":", "if", "img_cols", "is", "None", ":", ...
Predict with a specified model. It predicts with the model, join source data with prediction results, and formats the results so they can be displayed nicely in Datalab. Args: model_dir_or_id: The model directory if cloud is False, or model.version if cloud is True. data: Can be a list of dictionaries, ...
[ "Predict", "with", "a", "specified", "model", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_local_predict.py#L175-L239
train
googledatalab/pydatalab
google/datalab/contrib/mlworkbench/_local_predict.py
get_probs_for_labels
def get_probs_for_labels(labels, prediction_results): """ Given ML Workbench prediction results, get probs of each label for each instance. The prediction results are like: [ {'predicted': 'daisy', 'probability': 0.8, 'predicted_2': 'rose', 'probability_2': 0.1}, {'predicted': 'sunflower', 'probability':...
python
def get_probs_for_labels(labels, prediction_results): """ Given ML Workbench prediction results, get probs of each label for each instance. The prediction results are like: [ {'predicted': 'daisy', 'probability': 0.8, 'predicted_2': 'rose', 'probability_2': 0.1}, {'predicted': 'sunflower', 'probability':...
[ "def", "get_probs_for_labels", "(", "labels", ",", "prediction_results", ")", ":", "probs", "=", "[", "]", "if", "'probability'", "in", "prediction_results", ":", "for", "i", ",", "r", "in", "prediction_results", ".", "iterrows", "(", ")", ":", "probs_one", ...
Given ML Workbench prediction results, get probs of each label for each instance. The prediction results are like: [ {'predicted': 'daisy', 'probability': 0.8, 'predicted_2': 'rose', 'probability_2': 0.1}, {'predicted': 'sunflower', 'probability': 0.9, 'predicted_2': 'daisy', 'probability_2': 0.01}, .....
[ "Given", "ML", "Workbench", "prediction", "results", "get", "probs", "of", "each", "label", "for", "each", "instance", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_local_predict.py#L242-L297
train
googledatalab/pydatalab
google/datalab/contrib/mlworkbench/_local_predict.py
local_batch_predict
def local_batch_predict(model_dir, csv_file_pattern, output_dir, output_format, batch_size=100): """ Batch Predict with a specified model. It does batch prediction, saves results to output files and also creates an output schema file. The output file names are input file names prepended by 'predict_results_'. ...
python
def local_batch_predict(model_dir, csv_file_pattern, output_dir, output_format, batch_size=100): """ Batch Predict with a specified model. It does batch prediction, saves results to output files and also creates an output schema file. The output file names are input file names prepended by 'predict_results_'. ...
[ "def", "local_batch_predict", "(", "model_dir", ",", "csv_file_pattern", ",", "output_dir", ",", "output_format", ",", "batch_size", "=", "100", ")", ":", "file_io", ".", "recursive_create_dir", "(", "output_dir", ")", "csv_files", "=", "file_io", ".", "get_matchi...
Batch Predict with a specified model. It does batch prediction, saves results to output files and also creates an output schema file. The output file names are input file names prepended by 'predict_results_'. Args: model_dir: The model directory containing a SavedModel (usually saved_model.pb). csv_fil...
[ "Batch", "Predict", "with", "a", "specified", "model", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_local_predict.py#L359-L397
train
googledatalab/pydatalab
google/datalab/ml/_job.py
Job.submit_training
def submit_training(job_request, job_id=None): """Submit a training job. Args: job_request: the arguments of the training job in a dict. For example, { 'package_uris': 'gs://my-bucket/iris/trainer-0.1.tar.gz', 'python_module': 'trainer.task', 'scale_tier': '...
python
def submit_training(job_request, job_id=None): """Submit a training job. Args: job_request: the arguments of the training job in a dict. For example, { 'package_uris': 'gs://my-bucket/iris/trainer-0.1.tar.gz', 'python_module': 'trainer.task', 'scale_tier': '...
[ "def", "submit_training", "(", "job_request", ",", "job_id", "=", "None", ")", ":", "new_job_request", "=", "dict", "(", "job_request", ")", "if", "'args'", "in", "job_request", "and", "isinstance", "(", "job_request", "[", "'args'", "]", ",", "dict", ")", ...
Submit a training job. Args: job_request: the arguments of the training job in a dict. For example, { 'package_uris': 'gs://my-bucket/iris/trainer-0.1.tar.gz', 'python_module': 'trainer.task', 'scale_tier': 'BASIC', 'region': 'us-central1', ...
[ "Submit", "a", "training", "job", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_job.py#L62-L116
train
googledatalab/pydatalab
google/datalab/ml/_job.py
Job.submit_batch_prediction
def submit_batch_prediction(job_request, job_id=None): """Submit a batch prediction job. Args: job_request: the arguments of the training job in a dict. For example, { 'version_name': 'projects/my-project/models/my-model/versions/my-version', 'data_format': 'TEXT', ...
python
def submit_batch_prediction(job_request, job_id=None): """Submit a batch prediction job. Args: job_request: the arguments of the training job in a dict. For example, { 'version_name': 'projects/my-project/models/my-model/versions/my-version', 'data_format': 'TEXT', ...
[ "def", "submit_batch_prediction", "(", "job_request", ",", "job_id", "=", "None", ")", ":", "if", "job_id", "is", "None", ":", "job_id", "=", "'prediction_'", "+", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "'%y%m%d_%H%M%S'", ...
Submit a batch prediction job. Args: job_request: the arguments of the training job in a dict. For example, { 'version_name': 'projects/my-project/models/my-model/versions/my-version', 'data_format': 'TEXT', 'input_paths': ['gs://my_bucket/my_file.csv'], ...
[ "Submit", "a", "batch", "prediction", "job", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_job.py#L119-L151
train
googledatalab/pydatalab
solutionbox/image_classification/mltoolbox/image/classification/_inceptionlib.py
_reduced_kernel_size_for_small_input
def _reduced_kernel_size_for_small_input(input_tensor, kernel_size): """Define kernel size which is automatically reduced for small input. If the shape of the input images is unknown at graph construction time this function assumes that the input images are is large enough. Args: input_tensor: input tenso...
python
def _reduced_kernel_size_for_small_input(input_tensor, kernel_size): """Define kernel size which is automatically reduced for small input. If the shape of the input images is unknown at graph construction time this function assumes that the input images are is large enough. Args: input_tensor: input tenso...
[ "def", "_reduced_kernel_size_for_small_input", "(", "input_tensor", ",", "kernel_size", ")", ":", "shape", "=", "input_tensor", ".", "get_shape", "(", ")", ".", "as_list", "(", ")", "if", "shape", "[", "1", "]", "is", "None", "or", "shape", "[", "2", "]", ...
Define kernel size which is automatically reduced for small input. If the shape of the input images is unknown at graph construction time this function assumes that the input images are is large enough. Args: input_tensor: input tensor of size [batch_size, height, width, channels]. kernel_size: desired ...
[ "Define", "kernel", "size", "which", "is", "automatically", "reduced", "for", "small", "input", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_inceptionlib.py#L556-L584
train
googledatalab/pydatalab
solutionbox/image_classification/mltoolbox/image/classification/_inceptionlib.py
inception_v3_arg_scope
def inception_v3_arg_scope(weight_decay=0.00004, stddev=0.1, batch_norm_var_collection='moving_vars'): """Defines the default InceptionV3 arg scope. Args: weight_decay: The weight decay to use for regularizing the model. stddev: The standard deviation o...
python
def inception_v3_arg_scope(weight_decay=0.00004, stddev=0.1, batch_norm_var_collection='moving_vars'): """Defines the default InceptionV3 arg scope. Args: weight_decay: The weight decay to use for regularizing the model. stddev: The standard deviation o...
[ "def", "inception_v3_arg_scope", "(", "weight_decay", "=", "0.00004", ",", "stddev", "=", "0.1", ",", "batch_norm_var_collection", "=", "'moving_vars'", ")", ":", "batch_norm_params", "=", "{", "'decay'", ":", "0.9997", ",", "'epsilon'", ":", "0.001", ",", "'upd...
Defines the default InceptionV3 arg scope. Args: weight_decay: The weight decay to use for regularizing the model. stddev: The standard deviation of the trunctated normal weight initializer. batch_norm_var_collection: The name of the collection for the batch norm variables. Returns: An `arg_...
[ "Defines", "the", "default", "InceptionV3", "arg", "scope", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_inceptionlib.py#L587-L624
train
googledatalab/pydatalab
solutionbox/image_classification/mltoolbox/image/classification/_local.py
Local.preprocess
def preprocess(train_dataset, output_dir, eval_dataset, checkpoint): """Preprocess data locally.""" import apache_beam as beam from google.datalab.utils import LambdaJob from . import _preprocess if checkpoint is None: checkpoint = _util._DEFAULT_CHECKPOINT_GSURL job_id = ('preprocess-im...
python
def preprocess(train_dataset, output_dir, eval_dataset, checkpoint): """Preprocess data locally.""" import apache_beam as beam from google.datalab.utils import LambdaJob from . import _preprocess if checkpoint is None: checkpoint = _util._DEFAULT_CHECKPOINT_GSURL job_id = ('preprocess-im...
[ "def", "preprocess", "(", "train_dataset", ",", "output_dir", ",", "eval_dataset", ",", "checkpoint", ")", ":", "import", "apache_beam", "as", "beam", "from", "google", ".", "datalab", ".", "utils", "import", "LambdaJob", "from", ".", "import", "_preprocess", ...
Preprocess data locally.
[ "Preprocess", "data", "locally", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_local.py#L32-L51
train
googledatalab/pydatalab
solutionbox/image_classification/mltoolbox/image/classification/_local.py
Local.train
def train(input_dir, batch_size, max_steps, output_dir, checkpoint): """Train model locally.""" from google.datalab.utils import LambdaJob if checkpoint is None: checkpoint = _util._DEFAULT_CHECKPOINT_GSURL labels = _util.get_labels(input_dir) model = _model.Model(labels, 0.5, checkpoint) ...
python
def train(input_dir, batch_size, max_steps, output_dir, checkpoint): """Train model locally.""" from google.datalab.utils import LambdaJob if checkpoint is None: checkpoint = _util._DEFAULT_CHECKPOINT_GSURL labels = _util.get_labels(input_dir) model = _model.Model(labels, 0.5, checkpoint) ...
[ "def", "train", "(", "input_dir", ",", "batch_size", ",", "max_steps", ",", "output_dir", ",", "checkpoint", ")", ":", "from", "google", ".", "datalab", ".", "utils", "import", "LambdaJob", "if", "checkpoint", "is", "None", ":", "checkpoint", "=", "_util", ...
Train model locally.
[ "Train", "model", "locally", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_local.py#L54-L67
train
googledatalab/pydatalab
solutionbox/image_classification/mltoolbox/image/classification/_local.py
Local.predict
def predict(model_dir, image_files, resize, show_image): """Predict using an model in a local or GCS directory.""" from . import _predictor images = _util.load_images(image_files, resize=resize) labels_and_scores = _predictor.predict(model_dir, images) results = zip(image_files, images, labels_and...
python
def predict(model_dir, image_files, resize, show_image): """Predict using an model in a local or GCS directory.""" from . import _predictor images = _util.load_images(image_files, resize=resize) labels_and_scores = _predictor.predict(model_dir, images) results = zip(image_files, images, labels_and...
[ "def", "predict", "(", "model_dir", ",", "image_files", ",", "resize", ",", "show_image", ")", ":", "from", ".", "import", "_predictor", "images", "=", "_util", ".", "load_images", "(", "image_files", ",", "resize", "=", "resize", ")", "labels_and_scores", "...
Predict using an model in a local or GCS directory.
[ "Predict", "using", "an", "model", "in", "a", "local", "or", "GCS", "directory", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_local.py#L70-L79
train
googledatalab/pydatalab
solutionbox/image_classification/mltoolbox/image/classification/_local.py
Local.batch_predict
def batch_predict(dataset, model_dir, output_csv, output_bq_table): """Batch predict running locally.""" import apache_beam as beam from google.datalab.utils import LambdaJob from . import _predictor if output_csv is None and output_bq_table is None: raise ValueError('output_csv and output_b...
python
def batch_predict(dataset, model_dir, output_csv, output_bq_table): """Batch predict running locally.""" import apache_beam as beam from google.datalab.utils import LambdaJob from . import _predictor if output_csv is None and output_bq_table is None: raise ValueError('output_csv and output_b...
[ "def", "batch_predict", "(", "dataset", ",", "model_dir", ",", "output_csv", ",", "output_bq_table", ")", ":", "import", "apache_beam", "as", "beam", "from", "google", ".", "datalab", ".", "utils", "import", "LambdaJob", "from", ".", "import", "_predictor", "i...
Batch predict running locally.
[ "Batch", "predict", "running", "locally", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_local.py#L82-L103
train
googledatalab/pydatalab
datalab/utils/_job.py
Job.result
def result(self): """ Get the result for a job. This will block if the job is incomplete. Returns: The result for the Job. Raises: An exception if the Job resulted in an exception. """ self.wait() if self._fatal_error: raise self._fatal_error return self._result
python
def result(self): """ Get the result for a job. This will block if the job is incomplete. Returns: The result for the Job. Raises: An exception if the Job resulted in an exception. """ self.wait() if self._fatal_error: raise self._fatal_error return self._result
[ "def", "result", "(", "self", ")", ":", "self", ".", "wait", "(", ")", "if", "self", ".", "_fatal_error", ":", "raise", "self", ".", "_fatal_error", "return", "self", ".", "_result" ]
Get the result for a job. This will block if the job is incomplete. Returns: The result for the Job. Raises: An exception if the Job resulted in an exception.
[ "Get", "the", "result", "for", "a", "job", ".", "This", "will", "block", "if", "the", "job", "is", "incomplete", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/utils/_job.py#L119-L132
train
googledatalab/pydatalab
datalab/utils/_job.py
Job._refresh_state
def _refresh_state(self): """ Get the state of a job. Must be overridden by derived Job classes for Jobs that don't use a Future. """ if self._is_complete: return if not self._future: raise Exception('Please implement this in the derived class') if self._future.done(): se...
python
def _refresh_state(self): """ Get the state of a job. Must be overridden by derived Job classes for Jobs that don't use a Future. """ if self._is_complete: return if not self._future: raise Exception('Please implement this in the derived class') if self._future.done(): se...
[ "def", "_refresh_state", "(", "self", ")", ":", "if", "self", ".", "_is_complete", ":", "return", "if", "not", "self", ".", "_future", ":", "raise", "Exception", "(", "'Please implement this in the derived class'", ")", "if", "self", ".", "_future", ".", "done...
Get the state of a job. Must be overridden by derived Job classes for Jobs that don't use a Future.
[ "Get", "the", "state", "of", "a", "job", ".", "Must", "be", "overridden", "by", "derived", "Job", "classes", "for", "Jobs", "that", "don", "t", "use", "a", "Future", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/utils/_job.py#L151-L169
train
googledatalab/pydatalab
datalab/utils/_job.py
Job.state
def state(self): """ Describe the state of a Job. Returns: A string describing the job's state. """ state = 'in progress' if self.is_complete: if self.failed: state = 'failed with error: %s' % str(self._fatal_error) elif self._errors: state = 'completed with some non-fat...
python
def state(self): """ Describe the state of a Job. Returns: A string describing the job's state. """ state = 'in progress' if self.is_complete: if self.failed: state = 'failed with error: %s' % str(self._fatal_error) elif self._errors: state = 'completed with some non-fat...
[ "def", "state", "(", "self", ")", ":", "state", "=", "'in progress'", "if", "self", ".", "is_complete", ":", "if", "self", ".", "failed", ":", "state", "=", "'failed with error: %s'", "%", "str", "(", "self", ".", "_fatal_error", ")", "elif", "self", "."...
Describe the state of a Job. Returns: A string describing the job's state.
[ "Describe", "the", "state", "of", "a", "Job", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/utils/_job.py#L202-L215
train
googledatalab/pydatalab
datalab/utils/_job.py
Job.wait_any
def wait_any(jobs, timeout=None): """ Return when at least one of the specified jobs has completed or timeout expires. Args: jobs: a Job or list of Jobs to wait on. timeout: a timeout in seconds to wait for. None (the default) means no timeout. Returns: A list of the jobs that have now co...
python
def wait_any(jobs, timeout=None): """ Return when at least one of the specified jobs has completed or timeout expires. Args: jobs: a Job or list of Jobs to wait on. timeout: a timeout in seconds to wait for. None (the default) means no timeout. Returns: A list of the jobs that have now co...
[ "def", "wait_any", "(", "jobs", ",", "timeout", "=", "None", ")", ":", "return", "Job", ".", "_wait", "(", "jobs", ",", "timeout", ",", "concurrent", ".", "futures", ".", "FIRST_COMPLETED", ")" ]
Return when at least one of the specified jobs has completed or timeout expires. Args: jobs: a Job or list of Jobs to wait on. timeout: a timeout in seconds to wait for. None (the default) means no timeout. Returns: A list of the jobs that have now completed or None if there were no jobs.
[ "Return", "when", "at", "least", "one", "of", "the", "specified", "jobs", "has", "completed", "or", "timeout", "expires", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/utils/_job.py#L257-L267
train
googledatalab/pydatalab
datalab/utils/_job.py
Job.wait_all
def wait_all(jobs, timeout=None): """ Return when at all of the specified jobs have completed or timeout expires. Args: jobs: a Job or list of Jobs to wait on. timeout: a timeout in seconds to wait for. None (the default) means no timeout. Returns: A list of the jobs that have now complet...
python
def wait_all(jobs, timeout=None): """ Return when at all of the specified jobs have completed or timeout expires. Args: jobs: a Job or list of Jobs to wait on. timeout: a timeout in seconds to wait for. None (the default) means no timeout. Returns: A list of the jobs that have now complet...
[ "def", "wait_all", "(", "jobs", ",", "timeout", "=", "None", ")", ":", "return", "Job", ".", "_wait", "(", "jobs", ",", "timeout", ",", "concurrent", ".", "futures", ".", "ALL_COMPLETED", ")" ]
Return when at all of the specified jobs have completed or timeout expires. Args: jobs: a Job or list of Jobs to wait on. timeout: a timeout in seconds to wait for. None (the default) means no timeout. Returns: A list of the jobs that have now completed or None if there were no jobs.
[ "Return", "when", "at", "all", "of", "the", "specified", "jobs", "have", "completed", "or", "timeout", "expires", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/utils/_job.py#L270-L279
train
googledatalab/pydatalab
solutionbox/image_classification/mltoolbox/image/classification/_trainer.py
Evaluator.evaluate
def evaluate(self, num_eval_batches=None): """Run one round of evaluation, return loss and accuracy.""" num_eval_batches = num_eval_batches or self.num_eval_batches with tf.Graph().as_default() as graph: self.tensors = self.model.build_eval_graph(self.eval_data_paths, ...
python
def evaluate(self, num_eval_batches=None): """Run one round of evaluation, return loss and accuracy.""" num_eval_batches = num_eval_batches or self.num_eval_batches with tf.Graph().as_default() as graph: self.tensors = self.model.build_eval_graph(self.eval_data_paths, ...
[ "def", "evaluate", "(", "self", ",", "num_eval_batches", "=", "None", ")", ":", "num_eval_batches", "=", "num_eval_batches", "or", "self", ".", "num_eval_batches", "with", "tf", ".", "Graph", "(", ")", ".", "as_default", "(", ")", "as", "graph", ":", "self...
Run one round of evaluation, return loss and accuracy.
[ "Run", "one", "round", "of", "evaluation", "return", "loss", "and", "accuracy", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_trainer.py#L65-L101
train
googledatalab/pydatalab
solutionbox/image_classification/mltoolbox/image/classification/_trainer.py
Trainer.log
def log(self, session): """Logs training progress.""" logging.info('Train [%s/%d], step %d (%.3f sec) %.1f ' 'global steps/s, %.1f local steps/s', self.task.type, self.task.index, self.global_step, (self.now - self.start_time), (self.global_ste...
python
def log(self, session): """Logs training progress.""" logging.info('Train [%s/%d], step %d (%.3f sec) %.1f ' 'global steps/s, %.1f local steps/s', self.task.type, self.task.index, self.global_step, (self.now - self.start_time), (self.global_ste...
[ "def", "log", "(", "self", ",", "session", ")", ":", "logging", ".", "info", "(", "'Train [%s/%d], step %d (%.3f sec) %.1f '", "'global steps/s, %.1f local steps/s'", ",", "self", ".", "task", ".", "type", ",", "self", ".", "task", ".", "index", ",", "self", "...
Logs training progress.
[ "Logs", "training", "progress", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_trainer.py#L232-L244
train
googledatalab/pydatalab
solutionbox/image_classification/mltoolbox/image/classification/_trainer.py
Trainer.eval
def eval(self, session): """Runs evaluation loop.""" eval_start = time.time() self.saver.save(session, self.sv.save_path, self.tensors.global_step) logging.info( 'Eval, step %d:\n- on train set %s\n-- on eval set %s', self.global_step, self.model.format_metric_values(self.train_e...
python
def eval(self, session): """Runs evaluation loop.""" eval_start = time.time() self.saver.save(session, self.sv.save_path, self.tensors.global_step) logging.info( 'Eval, step %d:\n- on train set %s\n-- on eval set %s', self.global_step, self.model.format_metric_values(self.train_e...
[ "def", "eval", "(", "self", ",", "session", ")", ":", "eval_start", "=", "time", ".", "time", "(", ")", "self", ".", "saver", ".", "save", "(", "session", ",", "self", ".", "sv", ".", "save_path", ",", "self", ".", "tensors", ".", "global_step", ")...
Runs evaluation loop.
[ "Runs", "evaluation", "loop", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_trainer.py#L246-L266
train
googledatalab/pydatalab
google/datalab/ml/_feature_slice_view.py
FeatureSliceView.plot
def plot(self, data): """ Plots a featire slice view on given data. Args: data: Can be one of: A string of sql query. A sql query module defined by "%%sql --module module_name". A pandas DataFrame. Regardless of data type, it must include the following columns: ...
python
def plot(self, data): """ Plots a featire slice view on given data. Args: data: Can be one of: A string of sql query. A sql query module defined by "%%sql --module module_name". A pandas DataFrame. Regardless of data type, it must include the following columns: ...
[ "def", "plot", "(", "self", ",", "data", ")", ":", "import", "IPython", "if", "(", "(", "sys", ".", "version_info", ".", "major", ">", "2", "and", "isinstance", "(", "data", ",", "str", ")", ")", "or", "(", "sys", ".", "version_info", ".", "major",...
Plots a featire slice view on given data. Args: data: Can be one of: A string of sql query. A sql query module defined by "%%sql --module module_name". A pandas DataFrame. Regardless of data type, it must include the following columns: "feature": identifies a s...
[ "Plots", "a", "featire", "slice", "view", "on", "given", "data", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_feature_slice_view.py#L46-L88
train
googledatalab/pydatalab
solutionbox/structured_data/mltoolbox/_structured_data/preprocess/cloud_preprocess.py
run_analysis
def run_analysis(args): """Builds an analysis file for training. Uses BiqQuery tables to do the analysis. Args: args: command line args Raises: ValueError if schema contains unknown types. """ import google.datalab.bigquery as bq if args.bigquery_table: table = bq.Table(args.bigquery_table)...
python
def run_analysis(args): """Builds an analysis file for training. Uses BiqQuery tables to do the analysis. Args: args: command line args Raises: ValueError if schema contains unknown types. """ import google.datalab.bigquery as bq if args.bigquery_table: table = bq.Table(args.bigquery_table)...
[ "def", "run_analysis", "(", "args", ")", ":", "import", "google", ".", "datalab", ".", "bigquery", "as", "bq", "if", "args", ".", "bigquery_table", ":", "table", "=", "bq", ".", "Table", "(", "args", ".", "bigquery_table", ")", "schema_list", "=", "table...
Builds an analysis file for training. Uses BiqQuery tables to do the analysis. Args: args: command line args Raises: ValueError if schema contains unknown types.
[ "Builds", "an", "analysis", "file", "for", "training", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/preprocess/cloud_preprocess.py#L222-L256
train
googledatalab/pydatalab
google/datalab/ml/_confusion_matrix.py
ConfusionMatrix.from_csv
def from_csv(input_csv, headers=None, schema_file=None): """Create a ConfusionMatrix from a csv file. Args: input_csv: Path to a Csv file (with no header). Can be local or GCS path. headers: Csv headers. If present, it must include 'target' and 'predicted'. schema_file: Path to a JSON file co...
python
def from_csv(input_csv, headers=None, schema_file=None): """Create a ConfusionMatrix from a csv file. Args: input_csv: Path to a Csv file (with no header). Can be local or GCS path. headers: Csv headers. If present, it must include 'target' and 'predicted'. schema_file: Path to a JSON file co...
[ "def", "from_csv", "(", "input_csv", ",", "headers", "=", "None", ",", "schema_file", "=", "None", ")", ":", "if", "headers", "is", "not", "None", ":", "names", "=", "headers", "elif", "schema_file", "is", "not", "None", ":", "with", "_util", ".", "ope...
Create a ConfusionMatrix from a csv file. Args: input_csv: Path to a Csv file (with no header). Can be local or GCS path. headers: Csv headers. If present, it must include 'target' and 'predicted'. schema_file: Path to a JSON file containing BigQuery schema. Used if "headers" is None. I...
[ "Create", "a", "ConfusionMatrix", "from", "a", "csv", "file", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_confusion_matrix.py#L41-L77
train
googledatalab/pydatalab
google/datalab/ml/_confusion_matrix.py
ConfusionMatrix.from_bigquery
def from_bigquery(sql): """Create a ConfusionMatrix from a BigQuery table or query. Args: sql: Can be one of: A SQL query string. A Bigquery table string. A Query object defined with '%%bq query --name [query_name]'. The query results or table must include "target", "p...
python
def from_bigquery(sql): """Create a ConfusionMatrix from a BigQuery table or query. Args: sql: Can be one of: A SQL query string. A Bigquery table string. A Query object defined with '%%bq query --name [query_name]'. The query results or table must include "target", "p...
[ "def", "from_bigquery", "(", "sql", ")", ":", "if", "isinstance", "(", "sql", ",", "bq", ".", "Query", ")", ":", "sql", "=", "sql", ".", "_expanded_sql", "(", ")", "parts", "=", "sql", ".", "split", "(", "'.'", ")", "if", "len", "(", "parts", ")"...
Create a ConfusionMatrix from a BigQuery table or query. Args: sql: Can be one of: A SQL query string. A Bigquery table string. A Query object defined with '%%bq query --name [query_name]'. The query results or table must include "target", "predicted" columns. Returns:...
[ "Create", "a", "ConfusionMatrix", "from", "a", "BigQuery", "table", "or", "query", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_confusion_matrix.py#L80-L113
train
googledatalab/pydatalab
google/datalab/ml/_confusion_matrix.py
ConfusionMatrix.to_dataframe
def to_dataframe(self): """Convert the confusion matrix to a dataframe. Returns: A DataFrame with "target", "predicted", "count" columns. """ data = [] for target_index, target_row in enumerate(self._cm): for predicted_index, count in enumerate(target_row): data.append((self._l...
python
def to_dataframe(self): """Convert the confusion matrix to a dataframe. Returns: A DataFrame with "target", "predicted", "count" columns. """ data = [] for target_index, target_row in enumerate(self._cm): for predicted_index, count in enumerate(target_row): data.append((self._l...
[ "def", "to_dataframe", "(", "self", ")", ":", "data", "=", "[", "]", "for", "target_index", ",", "target_row", "in", "enumerate", "(", "self", ".", "_cm", ")", ":", "for", "predicted_index", ",", "count", "in", "enumerate", "(", "target_row", ")", ":", ...
Convert the confusion matrix to a dataframe. Returns: A DataFrame with "target", "predicted", "count" columns.
[ "Convert", "the", "confusion", "matrix", "to", "a", "dataframe", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_confusion_matrix.py#L115-L127
train
googledatalab/pydatalab
google/datalab/ml/_confusion_matrix.py
ConfusionMatrix.plot
def plot(self, figsize=None, rotation=45): """Plot the confusion matrix. Args: figsize: tuple (x, y) of ints. Sets the size of the figure rotation: the rotation angle of the labels on the x-axis. """ fig, ax = plt.subplots(figsize=figsize) plt.imshow(self._cm, interpolation='nearest',...
python
def plot(self, figsize=None, rotation=45): """Plot the confusion matrix. Args: figsize: tuple (x, y) of ints. Sets the size of the figure rotation: the rotation angle of the labels on the x-axis. """ fig, ax = plt.subplots(figsize=figsize) plt.imshow(self._cm, interpolation='nearest',...
[ "def", "plot", "(", "self", ",", "figsize", "=", "None", ",", "rotation", "=", "45", ")", ":", "fig", ",", "ax", "=", "plt", ".", "subplots", "(", "figsize", "=", "figsize", ")", "plt", ".", "imshow", "(", "self", ".", "_cm", ",", "interpolation", ...
Plot the confusion matrix. Args: figsize: tuple (x, y) of ints. Sets the size of the figure rotation: the rotation angle of the labels on the x-axis.
[ "Plot", "the", "confusion", "matrix", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_confusion_matrix.py#L129-L159
train
googledatalab/pydatalab
google/datalab/contrib/pipeline/composer/_api.py
Api.get_environment_details
def get_environment_details(zone, environment): """ Issues a request to Composer to get the environment details. Args: zone: GCP zone of the composer environment environment: name of the Composer environment Returns: A parsed result object. Raises: Exception if there is an error...
python
def get_environment_details(zone, environment): """ Issues a request to Composer to get the environment details. Args: zone: GCP zone of the composer environment environment: name of the Composer environment Returns: A parsed result object. Raises: Exception if there is an error...
[ "def", "get_environment_details", "(", "zone", ",", "environment", ")", ":", "default_context", "=", "google", ".", "datalab", ".", "Context", ".", "default", "(", ")", "url", "=", "(", "Api", ".", "_ENDPOINT", "+", "(", "Api", ".", "_ENVIRONMENTS_PATH_FORMA...
Issues a request to Composer to get the environment details. Args: zone: GCP zone of the composer environment environment: name of the Composer environment Returns: A parsed result object. Raises: Exception if there is an error performing the operation.
[ "Issues", "a", "request", "to", "Composer", "to", "get", "the", "environment", "details", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/pipeline/composer/_api.py#L24-L39
train
googledatalab/pydatalab
google/datalab/storage/_api.py
Api.buckets_delete
def buckets_delete(self, bucket): """Issues a request to delete a bucket. Args: bucket: the name of the bucket. Raises: Exception if there is an error performing the operation. """ url = Api._ENDPOINT + (Api._BUCKET_PATH % bucket) google.datalab.utils.Http.request(url, method='DELET...
python
def buckets_delete(self, bucket): """Issues a request to delete a bucket. Args: bucket: the name of the bucket. Raises: Exception if there is an error performing the operation. """ url = Api._ENDPOINT + (Api._BUCKET_PATH % bucket) google.datalab.utils.Http.request(url, method='DELET...
[ "def", "buckets_delete", "(", "self", ",", "bucket", ")", ":", "url", "=", "Api", ".", "_ENDPOINT", "+", "(", "Api", ".", "_BUCKET_PATH", "%", "bucket", ")", "google", ".", "datalab", ".", "utils", ".", "Http", ".", "request", "(", "url", ",", "metho...
Issues a request to delete a bucket. Args: bucket: the name of the bucket. Raises: Exception if there is an error performing the operation.
[ "Issues", "a", "request", "to", "delete", "a", "bucket", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/_api.py#L72-L82
train
googledatalab/pydatalab
google/datalab/storage/_api.py
Api.buckets_get
def buckets_get(self, bucket, projection='noAcl'): """Issues a request to retrieve information about a bucket. Args: bucket: the name of the bucket. projection: the projection of the bucket information to retrieve. Returns: A parsed bucket information dictionary. Raises: Excepti...
python
def buckets_get(self, bucket, projection='noAcl'): """Issues a request to retrieve information about a bucket. Args: bucket: the name of the bucket. projection: the projection of the bucket information to retrieve. Returns: A parsed bucket information dictionary. Raises: Excepti...
[ "def", "buckets_get", "(", "self", ",", "bucket", ",", "projection", "=", "'noAcl'", ")", ":", "args", "=", "{", "'projection'", ":", "projection", "}", "url", "=", "Api", ".", "_ENDPOINT", "+", "(", "Api", ".", "_BUCKET_PATH", "%", "bucket", ")", "ret...
Issues a request to retrieve information about a bucket. Args: bucket: the name of the bucket. projection: the projection of the bucket information to retrieve. Returns: A parsed bucket information dictionary. Raises: Exception if there is an error performing the operation.
[ "Issues", "a", "request", "to", "retrieve", "information", "about", "a", "bucket", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/_api.py#L84-L97
train
googledatalab/pydatalab
google/datalab/storage/_api.py
Api.buckets_list
def buckets_list(self, projection='noAcl', max_results=0, page_token=None, project_id=None): """Issues a request to retrieve the list of buckets. Args: projection: the projection of the bucket information to retrieve. max_results: an optional maximum number of objects to retrieve. page_token:...
python
def buckets_list(self, projection='noAcl', max_results=0, page_token=None, project_id=None): """Issues a request to retrieve the list of buckets. Args: projection: the projection of the bucket information to retrieve. max_results: an optional maximum number of objects to retrieve. page_token:...
[ "def", "buckets_list", "(", "self", ",", "projection", "=", "'noAcl'", ",", "max_results", "=", "0", ",", "page_token", "=", "None", ",", "project_id", "=", "None", ")", ":", "if", "max_results", "==", "0", ":", "max_results", "=", "Api", ".", "_MAX_RESU...
Issues a request to retrieve the list of buckets. Args: projection: the projection of the bucket information to retrieve. max_results: an optional maximum number of objects to retrieve. page_token: an optional token to continue the retrieval. project_id: the project whose buckets should be ...
[ "Issues", "a", "request", "to", "retrieve", "the", "list", "of", "buckets", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/_api.py#L99-L122
train
googledatalab/pydatalab
google/datalab/storage/_api.py
Api.object_download
def object_download(self, bucket, key, start_offset=0, byte_count=None): """Reads the contents of an object as text. Args: bucket: the name of the bucket containing the object. key: the key of the object to be read. start_offset: the start offset of bytes to read. byte_count: the number...
python
def object_download(self, bucket, key, start_offset=0, byte_count=None): """Reads the contents of an object as text. Args: bucket: the name of the bucket containing the object. key: the key of the object to be read. start_offset: the start offset of bytes to read. byte_count: the number...
[ "def", "object_download", "(", "self", ",", "bucket", ",", "key", ",", "start_offset", "=", "0", ",", "byte_count", "=", "None", ")", ":", "args", "=", "{", "'alt'", ":", "'media'", "}", "headers", "=", "{", "}", "if", "start_offset", ">", "0", "or",...
Reads the contents of an object as text. Args: bucket: the name of the bucket containing the object. key: the key of the object to be read. start_offset: the start offset of bytes to read. byte_count: the number of bytes to read. If None, it reads to the end. Returns: The text con...
[ "Reads", "the", "contents", "of", "an", "object", "as", "text", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/_api.py#L124-L146
train
googledatalab/pydatalab
google/datalab/storage/_api.py
Api.object_upload
def object_upload(self, bucket, key, content, content_type): """Writes text content to the object. Args: bucket: the name of the bucket containing the object. key: the key of the object to be written. content: the text content to be written. content_type: the type of text content. R...
python
def object_upload(self, bucket, key, content, content_type): """Writes text content to the object. Args: bucket: the name of the bucket containing the object. key: the key of the object to be written. content: the text content to be written. content_type: the type of text content. R...
[ "def", "object_upload", "(", "self", ",", "bucket", ",", "key", ",", "content", ",", "content_type", ")", ":", "args", "=", "{", "'uploadType'", ":", "'media'", ",", "'name'", ":", "key", "}", "headers", "=", "{", "'Content-Type'", ":", "content_type", "...
Writes text content to the object. Args: bucket: the name of the bucket containing the object. key: the key of the object to be written. content: the text content to be written. content_type: the type of text content. Raises: Exception if the object could not be written to.
[ "Writes", "text", "content", "to", "the", "object", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/_api.py#L148-L164
train
googledatalab/pydatalab
solutionbox/image_classification/mltoolbox/image/classification/_api.py
preprocess_async
def preprocess_async(train_dataset, output_dir, eval_dataset=None, checkpoint=None, cloud=None): """Preprocess data. Produce output that can be used by training efficiently. Args: train_dataset: training data source to preprocess. Can be CsvDataset or BigQueryDataSet. If eval_dataset is None, the pipel...
python
def preprocess_async(train_dataset, output_dir, eval_dataset=None, checkpoint=None, cloud=None): """Preprocess data. Produce output that can be used by training efficiently. Args: train_dataset: training data source to preprocess. Can be CsvDataset or BigQueryDataSet. If eval_dataset is None, the pipel...
[ "def", "preprocess_async", "(", "train_dataset", ",", "output_dir", ",", "eval_dataset", "=", "None", ",", "checkpoint", "=", "None", ",", "cloud", "=", "None", ")", ":", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilte...
Preprocess data. Produce output that can be used by training efficiently. Args: train_dataset: training data source to preprocess. Can be CsvDataset or BigQueryDataSet. If eval_dataset is None, the pipeline will randomly split train_dataset into train/eval set with 7:3 ratio. output_dir: The ...
[ "Preprocess", "data", ".", "Produce", "output", "that", "can", "be", "used", "by", "training", "efficiently", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_api.py#L25-L52
train
googledatalab/pydatalab
solutionbox/image_classification/mltoolbox/image/classification/_api.py
train_async
def train_async(input_dir, batch_size, max_steps, output_dir, checkpoint=None, cloud=None): """Train model. The output can be used for batch prediction or online deployment. Args: input_dir: A directory path containing preprocessed results. Can be local or GCS path. batch_size: size of batch used for train...
python
def train_async(input_dir, batch_size, max_steps, output_dir, checkpoint=None, cloud=None): """Train model. The output can be used for batch prediction or online deployment. Args: input_dir: A directory path containing preprocessed results. Can be local or GCS path. batch_size: size of batch used for train...
[ "def", "train_async", "(", "input_dir", ",", "batch_size", ",", "max_steps", ",", "output_dir", ",", "checkpoint", "=", "None", ",", "cloud", "=", "None", ")", ":", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilter", ...
Train model. The output can be used for batch prediction or online deployment. Args: input_dir: A directory path containing preprocessed results. Can be local or GCS path. batch_size: size of batch used for training. max_steps: number of steps to train. output_dir: The output directory to use. Can be...
[ "Train", "model", ".", "The", "output", "can", "be", "used", "for", "batch", "prediction", "or", "online", "deployment", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_api.py#L66-L86
train
googledatalab/pydatalab
solutionbox/image_classification/mltoolbox/image/classification/_api.py
batch_predict_async
def batch_predict_async(dataset, model_dir, output_csv=None, output_bq_table=None, cloud=None): """Batch prediction with an offline model. Args: dataset: CsvDataSet or BigQueryDataSet for batch prediction input. Can contain either one column 'image_url', or two columns with another being 'label'. m...
python
def batch_predict_async(dataset, model_dir, output_csv=None, output_bq_table=None, cloud=None): """Batch prediction with an offline model. Args: dataset: CsvDataSet or BigQueryDataSet for batch prediction input. Can contain either one column 'image_url', or two columns with another being 'label'. m...
[ "def", "batch_predict_async", "(", "dataset", ",", "model_dir", ",", "output_csv", "=", "None", ",", "output_bq_table", "=", "None", ",", "cloud", "=", "None", ")", ":", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilter...
Batch prediction with an offline model. Args: dataset: CsvDataSet or BigQueryDataSet for batch prediction input. Can contain either one column 'image_url', or two columns with another being 'label'. model_dir: The directory of a trained inception model. Can be local or GCS paths. output_csv: The ...
[ "Batch", "prediction", "with", "an", "offline", "model", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_api.py#L126-L156
train
googledatalab/pydatalab
google/datalab/bigquery/_job.py
Job._refresh_state
def _refresh_state(self): """ Get the state of a job. If the job is complete this does nothing; otherwise it gets a refreshed copy of the job resource. """ # TODO(gram): should we put a choke on refreshes? E.g. if the last call was less than # a second ago should we return the cached value? ...
python
def _refresh_state(self): """ Get the state of a job. If the job is complete this does nothing; otherwise it gets a refreshed copy of the job resource. """ # TODO(gram): should we put a choke on refreshes? E.g. if the last call was less than # a second ago should we return the cached value? ...
[ "def", "_refresh_state", "(", "self", ")", ":", "if", "self", ".", "_is_complete", ":", "return", "try", ":", "response", "=", "self", ".", "_api", ".", "jobs_get", "(", "self", ".", "_job_id", ")", "except", "Exception", "as", "e", ":", "raise", "e", ...
Get the state of a job. If the job is complete this does nothing; otherwise it gets a refreshed copy of the job resource.
[ "Get", "the", "state", "of", "a", "job", ".", "If", "the", "job", "is", "complete", "this", "does", "nothing", ";", "otherwise", "it", "gets", "a", "refreshed", "copy", "of", "the", "job", "resource", "." ]
d9031901d5bca22fe0d5925d204e6698df9852e1
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_job.py#L43-L70
train