docstr: Opens stream from specified devices or returns one by name if
  it was created before.
docstr_tok: ["Opens","stream","from","specified","devices","or","returns","one","by","name","if","it","was","created","before","."]
code: def open_stream(
      self, name: str = None, devices: Sequence[str] = None
  ) -> Stream:
      r"""Opens stream from specified devices or returns one by name if
      it was created before.
      """
      # TODO: what if devices were specified AND stream exist in cache?
  
      # create devices is any
      devices = self.devices_or_default(devices)
      device_streams = None
      if devices is not None:
          # we open devices in read-only mode
          device_streams = self._stream_factory.get_streams(
              stream_types=devices, for_write=False
          )
      # if no devices then open stream by name from cache
      if device_streams is None:
          if name is None:
              raise ValueError("Both device and name cannot be None")
  
          stream_info = None
          for (
              event_name,
              stream_infos,
          ) in self._stream_infos:  # per event
              stream_info = stream_infos.get(name, None)
              if stream_info is not None:
                  break
          if stream_info is None:
              raise ValueError(
                  "Requested stream was not found: " + name
              )
          return stream_info.stream
  
      # if we have device, first create stream and then attach device to it
      stream = Stream(stream_name=name)
      for device_stream in device_streams:
          # each device may have multiple streams so let's filter it
          filtered_stream = FilteredStream(
              source_stream=device_stream,
              filter_expr=functools.partial(
                  WatcherBase._filter_stream, name
              )
              if name is not None
              else None,
          )
          stream.subscribe(filtered_stream)
          stream.held_refs.add(
              filtered_stream
          )  # otherwise filtered stream will be destroyed by gc
      return stream
  
imports: from typing import Dict, Any, Sequence
  from .lv_types import EventData, StreamItem, StreamCreateRequest, VisArgs
  from .evaler import Evaler
  from .stream import Stream
  from .stream_factory import StreamFactory
  from .filtered_stream import FilteredStream
  import uuid, time, functools
  from .None import utils
  from .notebook_maker import NotebookMaker
label_desc: Use image node_id 7 for calling the WatcherBase obj's underlying member method code with example usage: obj.open_stream(name, devices) and returns: stream, stream_info