def read_bytes(urlpath, delimiter=None, not_zero=False, blocksize=(2 ** 27), sample=True, compression=None, **kwargs):
 (fs, paths, myopen) = get_fs_paths_myopen(urlpath, compression, 'rb', None, **kwargs)
 client = None
 if (len(paths) == 0):
  raise IOError(('%s resolved to no files' % urlpath))
 (blocks, lengths, machines) = fs.get_block_locations(paths)
 if blocks:
  offsets = blocks
 elif (blocksize is None):
  offsets = ([[0]] * len(paths))
  lengths = ([[None]] * len(offsets))
  machines = ([[None]] * len(offsets))
 else:
  offsets = []
  lengths = []
  for path in paths:
   try:
    size = fs.logical_size(path, compression)
   except KeyError:
    raise ValueError(('Cannot read compressed files (%s) in byte chunks,use blocksize=None' % infer_compression(urlpath)))
   off = list(range(0, size, blocksize))
   length = ([blocksize] * len(off))
   if not_zero:
    off[0] = 1
    length[0] -= 1
   offsets.append(off)
   lengths.append(length)
  machines = ([[None]] * len(offsets))
 out = []
 for (path, offset, length, machine) in zip(paths, offsets, lengths, machines):
  ukey = fs.ukey(path)
  keys = [('read-block-%s-%s' % (o, tokenize(path, compression, offset, ukey, kwargs, delimiter))) for o in offset]
  L = [delayed(read_block_from_file)(myopen(path, mode='rb'), o, l, delimiter, dask_key_name=key) for (o, key, l) in zip(offset, keys, length)]
  out.append(L)
  if (machine is not None):
   if (client is None):
    try:
     from distributed.client import default_client
     client = default_client()
    except (ImportError, ValueError):
     client = False
   if client:
    restrictions = {key: w for (key, w) in zip(keys, machine)}
    client._send_to_scheduler({'op': 'update-graph', 'tasks': {}, 'dependencies': [], 'keys': [], 'restrictions': restrictions, 'loose_restrictions': list(restrictions), 'client': client.id})
 if (sample is not True):
  nbytes = sample
 else:
  nbytes = 10000
 if sample:
  with myopen(paths[0], 'rb') as f:
   sample = read_block(f, 0, nbytes, delimiter)
 return (sample, out)

def read_bytes ( urlpath , delimiter = None , not_zero = False , blocksize = ( 2 ** 27 ) , sample = True , compression = None , ** kwargs ) : ( fs , paths , myopen ) = get_fs_paths_myopen ( urlpath , compression , 'rb' , None , ** kwargs ) client = None if ( len ( paths ) == 0 ) : raise IOError ( ( '%s resolved to no files' % urlpath ) ) ( blocks , lengths , machines ) = fs . get_block_locations ( paths ) if blocks : offsets = blocks elif ( blocksize is None ) : offsets = ( [ [ 0 ] ] * len ( paths ) ) lengths = ( [ [ None ] ] * len ( offsets ) ) machines = ( [ [ None ] ] * len ( offsets ) ) else : offsets = [ ] lengths = [ ] for path in paths : try : size = fs . logical_size ( path , compression ) except KeyError : raise ValueError ( ( 'Cannot read compressed files (%s) in byte chunks,use blocksize=None' % infer_compression ( urlpath ) ) ) off = list ( range ( 0 , size , blocksize ) ) length = ( [ blocksize ] * len ( off ) ) if not_zero : off [ 0 ] = 1 length [ 0 ] -= 1 offsets . append ( off ) lengths . append ( length ) machines = ( [ [ None ] ] * len ( offsets ) ) out = [ ] for ( path , offset , length , machine ) in zip ( paths , offsets , lengths , machines ) : ukey = fs . ukey ( path ) keys = [ ( 'read-block-%s-%s' % ( o , tokenize ( path , compression , offset , ukey , kwargs , delimiter ) ) ) for o in offset ] L = [ delayed ( read_block_from_file ) ( myopen ( path , mode = 'rb' ) , o , l , delimiter , dask_key_name = key ) for ( o , key , l ) in zip ( offset , keys , length ) ] out . append ( L ) if ( machine is not None ) : if ( client is None ) : try : from distributed . client import default_client client = default_client ( ) except ( ImportError , ValueError ) : client = False if client : restrictions = { key : w for ( key , w ) in zip ( keys , machine ) } client . _send_to_scheduler ( { 'op' : 'update-graph' , 'tasks' : { } , 'dependencies' : [ ] , 'keys' : [ ] , 'restrictions' : restrictions , 'loose_restrictions' : list ( restrictions ) , 'client' : client . id } ) if ( sample is not True ) : nbytes = sample else : nbytes = 10000 if sample : with myopen ( paths [ 0 ] , 'rb' ) as f : sample = read_block ( f , 0 , nbytes , delimiter ) return ( sample , out )
read tag data from file and return as byte string .