parameters: (filename)
docstring: _load_library
docstring_summary: _load_library
docstring_tokens: _load_library
function: def _load_library(filename):
      """_load_library"""
      f = inspect.getfile(sys._getframe(1))  # pylint: disable=protected-access
  
      # Construct filename
      f = os.path.join(os.path.dirname(f), filename)
      filenames = [f]
  
      # Add datapath to load if en var is set, used for running tests where shared
      # libraries are built in a different path
      datapath = os.environ.get("TFIO_DATAPATH")
      if datapath is not None:
          # Build filename from:
          # `datapath` + `tensorflow_io_package` + `package_name` + `relpath_to_library`
          rootpath = os.path.dirname(sys.modules["tensorflow_io_gcs_filesystem"].__file__)
          filename = sys.modules[__name__].__file__
          f = os.path.join(
              datapath,
              "tensorflow_io_gcs_filesystem",
              os.path.relpath(os.path.dirname(filename), rootpath),
              os.path.relpath(f, os.path.dirname(filename)),
          )
          filenames.append(f)
      # Function to load the library, return True if file system library is loaded
      load_fn = lambda f: tf.experimental.register_filesystem_plugin(f) is None
  
      # Try to load all paths for file, fail if none succeed
      errs = []
      for f in filenames:
          try:
              l = load_fn(f)
              if l is not None:
                  return l
          except (tf.errors.NotFoundError, OSError) as e:
              errs.append(str(e))
      raise NotImplementedError(
          "unable to open file: "
          + f"{filename}, from paths: {filenames}\ncaused by: {errs}"
      )
function_tokens: def _load_library ( filename ) : f = inspect . getfile ( sys . _getframe ( 1 ) ) # pylint: disable=protected-access # Construct filename f = os . path . join ( os . path . dirname ( f ) , filename ) filenames = [ f ] # Add datapath to load if en var is set, used for running tests where shared # libraries are built in a different path datapath = os . environ . get ( "TFIO_DATAPATH" ) if datapath is not None : # Build filename from: # `datapath` + `tensorflow_io_package` + `package_name` + `relpath_to_library` rootpath = os . path . dirname ( sys . modules [ "tensorflow_io_gcs_filesystem" ] . __file__ ) filename = sys . modules [ __name__ ] . __file__ f = os . path . join ( datapath , "tensorflow_io_gcs_filesystem" , os . path . relpath ( os . path . dirname ( filename ) , rootpath ) , os . path . relpath ( f , os . path . dirname ( filename ) ) , ) filenames . append ( f ) # Function to load the library, return True if file system library is loaded load_fn = lambda f : tf . experimental . register_filesystem_plugin ( f ) is None # Try to load all paths for file, fail if none succeed errs = [ ] for f in filenames : try : l = load_fn ( f ) if l is not None : return l except ( tf . errors . NotFoundError , OSError ) as e : errs . append ( str ( e ) ) raise NotImplementedError ( "unable to open file: " + f"{filename}, from paths: {filenames}\ncaused by: {errs}" )