当前位置: 首页>>代码示例>>Python>>正文


Python Storage.create方法代码示例

本文整理汇总了Python中pants.engine.storage.Storage.create方法的典型用法代码示例。如果您正苦于以下问题:Python Storage.create方法的具体用法?Python Storage.create怎么用?Python Storage.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pants.engine.storage.Storage的用法示例。


在下文中一共展示了Storage.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
  def __init__(self, scheduler, storage=None, cache=None, pool_size=None, debug=True):
    """
    :param scheduler: The local scheduler for creating execution graphs.
    :type scheduler: :class:`pants.engine.scheduler.LocalScheduler`
    :param storage: The storage instance for serializables keyed by their hashes.
    :type storage: :class:`pants.engine.storage.Storage`
    :param cache: The cache instance for storing execution results, by default it uses the same
      Storage instance if not specified.
    :type cache: :class:`pants.engine.storage.Cache`
    :param int pool_size: The number of worker processes to use; by default 2 processes per core will
                          be used.
    :param bool debug: `True` to turn on pickling error debug mode (slower); True by default.
    """
    # This is the only place where non in-memory storage is needed, create one if not specified.
    storage = storage or Storage.create(in_memory=False)
    super(LocalMultiprocessEngine, self).__init__(scheduler, storage, cache)
    self._pool_size = pool_size if pool_size and pool_size > 0 else 2 * multiprocessing.cpu_count()

    execute_step = functools.partial(_execute_step, debug)

    self._processed_queue = Queue()
    self.node_builder = scheduler.node_builder
    process_initializer = functools.partial(_process_initializer, self._storage)
    self._pool = StatefulPool(self._pool_size, process_initializer, execute_step)
    self._debug = debug
    self._pool.start()
开发者ID:kwlzn,项目名称:pants,代码行数:28,代码来源:engine.py

示例2: __init__

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
 def __init__(self):
   # Objects indexed by their keys, i.e, content digests
   self._objects = Storage.create()
   # Memoized object Ids.
   self._id_to_key = dict()
   self._key_to_id = dict()
   self._next_id = 0
开发者ID:pombredanne,项目名称:pants,代码行数:9,代码来源:native.py

示例3: setup_legacy_graph

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
  def setup_legacy_graph(path_ignore_patterns):
    """Construct and return the components necessary for LegacyBuildGraph construction.

    :param list path_ignore_patterns: A list of path ignore patterns for FileSystemProjectTree,
                                      usually taken from the `--pants-ignore` global option.
    :returns: A tuple of (scheduler, engine, symbol_table_cls, build_graph_cls).
    """

    build_root = get_buildroot()
    project_tree = FileSystemProjectTree(build_root, path_ignore_patterns)
    symbol_table_cls = LegacySymbolTable

    # Register "literal" subjects required for these tasks.
    # TODO: Replace with `Subsystems`.
    address_mapper = AddressMapper(symbol_table_cls=symbol_table_cls,
                                   parser_cls=LegacyPythonCallbacksParser)

    # Create a Scheduler containing graph and filesystem tasks, with no installed goals. The
    # LegacyBuildGraph will explicitly request the products it needs.
    tasks = (
      create_legacy_graph_tasks() +
      create_fs_tasks() +
      create_graph_tasks(address_mapper, symbol_table_cls)
    )

    scheduler = LocalScheduler(dict(), tasks, project_tree)
    engine = LocalSerialEngine(scheduler, Storage.create(debug=False))

    return LegacyGraphHelper(scheduler, engine, symbol_table_cls, LegacyBuildGraph)
开发者ID:neven7,项目名称:pants,代码行数:31,代码来源:engine_initializer.py

示例4: hybrid_engine

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
 def hybrid_engine(self, pool_size=None):
   async_nodes = (FilesystemNode,)
   storage = Storage.create(in_memory=True)
   cache = Cache.create(storage=storage)
   with closing(ThreadHybridEngine(self.scheduler, storage,
                                   threaded_node_types=async_nodes, cache=cache,
                                   pool_size=pool_size, debug=True)) as e:
     yield e
开发者ID:CaitieM20,项目名称:pants,代码行数:10,代码来源:test_engine.py

示例5: setUp

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
 def setUp(self):
   self.storage = Storage.create()
   self.result = StepResult(state='something')
   self.request = StepRequest(step_id=123,
                              node='some node',
                              dependencies={'some dep': 'some state',
                                            'another dep': 'another state'},
                              inline_nodes=False,
                              project_tree='some project tree')
开发者ID:adamchainz,项目名称:pants,代码行数:11,代码来源:test_storage.py

示例6: setUp

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
 def setUp(self):
     self.storage = Storage.create(in_memory=True)
     self.result = StepResult(state="something")
     self.request = StepRequest(
         step_id=123,
         node="some node",
         dependencies={"some dep": "some state", "another dep": "another state"},
         project_tree="some project tree",
     )
开发者ID:weian,项目名称:pants,代码行数:11,代码来源:test_storage.py

示例7: visualize_build_request

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
def visualize_build_request(build_root, goals, subjects):
  with subsystem_instance(Native.Factory) as native_factory:
    scheduler = setup_json_scheduler(build_root, native_factory.create())

    execution_request = scheduler.build_request(goals, subjects)
    # NB: Calls `reduce` independently of `execute`, in order to render a graph before validating it.
    engine = LocalSerialEngine(scheduler, Storage.create())
    engine.reduce(execution_request)
    visualize_execution_graph(scheduler)
开发者ID:pombredanne,项目名称:pants,代码行数:11,代码来源:visualizer.py

示例8: visualize_build_request

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
def visualize_build_request(build_root, goals, subjects):
  scheduler = setup_json_scheduler(build_root)

  execution_request = scheduler.build_request(goals, subjects)
  # NB: Calls `reduce` independently of `execute`, in order to render a graph before validating it.
  engine = LocalSerialEngine(scheduler, Storage.create())
  try:
    engine.reduce(execution_request)
    visualize_execution_graph(scheduler, execution_request)
  finally:
    engine.close()
开发者ID:CaitieM20,项目名称:pants,代码行数:13,代码来源:visualizer.py

示例9: __init__

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
 def __init__(self, scheduler, storage=None, cache=None):
   """
   :param scheduler: The local scheduler for creating execution graphs.
   :type scheduler: :class:`pants.engine.scheduler.LocalScheduler`
   :param storage: The storage instance for serializables keyed by their hashes.
   :type storage: :class:`pants.engine.storage.Storage`
   :param cache: The cache instance for storing execution results, by default it uses the same
     Storage instance if not specified.
   :type cache: :class:`pants.engine.storage.Cache`
   """
   self._scheduler = scheduler
   self._storage = storage or Storage.create()
   self._cache = cache or Cache.create(storage)
开发者ID:adamchainz,项目名称:pants,代码行数:15,代码来源:engine.py

示例10: mk_scheduler

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
  def mk_scheduler(self,
                   tasks=None,
                   goals=None,
                   storage=None,
                   project_tree=None,
                   symbol_table_cls=EmptyTable):
    """Creates a Scheduler with "native" tasks already included, and the given additional tasks."""
    goals = goals or dict()
    tasks = tasks or []
    storage = storage or Storage.create(in_memory=True)
    project_tree = project_tree or self.mk_fs_tree()

    tasks = list(tasks) + create_fs_tasks()
    scheduler = LocalScheduler(goals, tasks, storage, project_tree)
    return scheduler, storage
开发者ID:anubnair,项目名称:pants,代码行数:17,代码来源:scheduler_test_base.py

示例11: __init__

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
 def __init__(self, scheduler, storage=None, cache=None, use_cache=True):
   """
   :param scheduler: The local scheduler for creating execution graphs.
   :type scheduler: :class:`pants.engine.scheduler.LocalScheduler`
   :param storage: The storage instance for serializables keyed by their hashes.
   :type storage: :class:`pants.engine.storage.Storage`
   :param cache: The cache instance for storing execution results, by default it uses the same
     Storage instance if not specified.
   :type cache: :class:`pants.engine.storage.Cache`
   :param use_cache: True to enable usage of the cache. The cache incurs a large amount of
     overhead for small tasks, and needs TODO: further improvement.
   :type use_cache: bool
   """
   self._scheduler = scheduler
   self._storage = storage or Storage.create()
   self._cache = cache or Cache.create(storage)
   self._use_cache = use_cache
开发者ID:lahosken,项目名称:pants,代码行数:19,代码来源:engine.py

示例12: setup_legacy_graph

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
  def setup_legacy_graph(pants_ignore_patterns,
                         build_root=None,
                         symbol_table_cls=None,
                         build_ignore_patterns=None,
                         exclude_target_regexps=None):
    """Construct and return the components necessary for LegacyBuildGraph construction.

    :param list pants_ignore_patterns: A list of path ignore patterns for FileSystemProjectTree,
                                       usually taken from the '--pants-ignore' global option.
    :param str build_root: A path to be used as the build root. If None, then default is used.
    :param SymbolTable symbol_table_cls: A SymbolTable class to use for build file parsing, or
                                         None to use the default.
    :param list build_ignore_patterns: A list of paths ignore patterns used when searching for BUILD
                                       files, usually taken from the '--build-ignore' global option.
    :param list exclude_target_regexps: A list of regular expressions for excluding targets.
    :returns: A tuple of (scheduler, engine, symbol_table_cls, build_graph_cls).
    """

    build_root = build_root or get_buildroot()
    scm = get_scm()
    symbol_table_cls = symbol_table_cls or LegacySymbolTable

    project_tree = FileSystemProjectTree(build_root, pants_ignore_patterns)

    # Register "literal" subjects required for these tasks.
    # TODO: Replace with `Subsystems`.
    address_mapper = AddressMapper(symbol_table_cls=symbol_table_cls,
                                   parser_cls=LegacyPythonCallbacksParser,
                                   build_ignore_patterns=build_ignore_patterns,
                                   exclude_target_regexps=exclude_target_regexps)

    # Create a Scheduler containing graph and filesystem tasks, with no installed goals. The
    # LegacyBuildGraph will explicitly request the products it needs.
    tasks = (
      create_legacy_graph_tasks(symbol_table_cls) +
      create_fs_tasks() +
      create_graph_tasks(address_mapper, symbol_table_cls)
    )

    scheduler = LocalScheduler(dict(), tasks, project_tree)
    # TODO: Do not use the cache yet, as it incurs a high overhead.
    engine = LocalSerialEngine(scheduler, Storage.create(), use_cache=False)
    change_calculator = EngineChangeCalculator(engine, scm) if scm else None

    return LegacyGraphHelper(scheduler, engine, symbol_table_cls, change_calculator)
开发者ID:CaitieM20,项目名称:pants,代码行数:47,代码来源:engine_initializer.py

示例13: setUp

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
  def setUp(self):
    # Set up a scheduler that supports address mapping.
    symbol_table_cls = TargetTable
    self.storage = Storage.create(in_memory=True)
    address_mapper = AddressMapper(symbol_table_cls=symbol_table_cls,
                                   parser_cls=JsonParser,
                                   build_pattern=r'.+\.BUILD.json$')
    tasks = create_graph_tasks(address_mapper, symbol_table_cls)

    project_tree = self.mk_fs_tree(os.path.join(os.path.dirname(__file__), 'examples/mapper_test'))
    self.build_root = project_tree.build_root
    self.scheduler, _ = self.mk_scheduler(tasks=tasks,
                                          project_tree=project_tree,
                                          storage=self.storage,
                                          symbol_table_cls=symbol_table_cls)

    self.a_b = Address.parse('a/b')
    self.a_b_target = Target(name='b',
                             dependencies=['//d:e'],
                             configurations=['//a', Struct(embedded='yes')],
                             type_alias='target')
开发者ID:anubnair,项目名称:pants,代码行数:23,代码来源:test_mapper.py

示例14: setUp

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
 def setUp(self):
     """Setup cache as well as request and result."""
     self.storage = Storage.create()
     self.cache = Cache.create(storage=self.storage)
     self.request = Runnable(func=_runnable, args=("this is an arg",), cacheable=True)
     self.result = "something"
开发者ID:pantsbuild-osx,项目名称:pants,代码行数:8,代码来源:test_storage.py

示例15: setUp

# 需要导入模块: from pants.engine.storage import Storage [as 别名]
# 或者: from pants.engine.storage.Storage import create [as 别名]
  def setUp(self):
    build_root = os.path.join(os.path.dirname(__file__), 'examples', 'scheduler_inputs')
    self.scheduler, self.storage = setup_json_scheduler(build_root, debug=True)
    self.cache = Cache.create(Storage.create())

    self.java = Address.parse('src/java/codegen/simple')
开发者ID:drewrothstein,项目名称:pants,代码行数:8,代码来源:test_engine.py


注:本文中的pants.engine.storage.Storage.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。