本文整理汇总了Python中spinn_utilities.progress_bar.ProgressBar.update方法的典型用法代码示例。如果您正苦于以下问题:Python ProgressBar.update方法的具体用法?Python ProgressBar.update怎么用?Python ProgressBar.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spinn_utilities.progress_bar.ProgressBar
的用法示例。
在下文中一共展示了ProgressBar.update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def __call__(self, placements, file_path):
"""
:param placements: the memory placements object
:param file_path: the file path for the placements.json
:return: file path for the placements.json
"""
# write basic stuff
json_obj = dict()
vertex_by_id = dict()
progress = ProgressBar(placements.n_placements + 1,
"converting to JSON placements")
# process placements
for placement in progress.over(placements, False):
vertex_id = ident(placement.vertex)
vertex_by_id[vertex_id] = placement.vertex
json_obj[vertex_id] = [placement.x, placement.y]
# dump dict into json file
with open(file_path, "w") as file_to_write:
json.dump(json_obj, file_to_write)
progress.update()
# validate the schema
file_format_schemas.validate(json_obj, "placements.json")
progress.end()
# return the file format
return file_path, vertex_by_id
示例2: __call__
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def __call__(self, machine_graph, machine, file_path):
"""
:param machine_graph: the machine graph
:param machine: the machine
"""
progress = ProgressBar(
machine_graph.n_vertices + 2, "creating JSON constraints")
json_obj = list()
self._add_monitor_core_reserve(json_obj)
progress.update()
self._add_extra_monitor_cores(json_obj, machine)
progress.update()
vertex_by_id = self._search_graph_for_placement_constraints(
json_obj, machine_graph, machine, progress)
with open(file_path, "w") as f:
json.dump(json_obj, f)
# validate the schema
file_format_schemas.validate(json_obj, "constraints.json")
# complete progress bar
progress.end()
return file_path, vertex_by_id
示例3: __call__
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def __call__(self, placements, file_path):
"""
:param placements:
:param file_path:
"""
progress = ProgressBar(len(placements) + 1,
"Converting to JSON core allocations")
# write basic stuff
json_obj = OrderedDict()
json_obj['type'] = "cores"
vertex_by_id = OrderedDict()
# process placements
for placement in progress.over(placements, False):
self._convert_placement(placement, vertex_by_id, json_obj)
# dump dict into json file
with open(file_path, "w") as f:
json.dump(json_obj, f)
progress.update()
# validate the schema
file_format_schemas.validate(json_obj, "core_allocations.json")
# complete progress bar
progress.end()
# return the file format
return file_path, vertex_by_id
示例4: synapse_expander
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def synapse_expander(
app_graph, graph_mapper, placements, transceiver,
provenance_file_path, executable_finder):
""" Run the synapse expander - needs to be done after data has been loaded
"""
synapse_expander = executable_finder.get_executable_path(SYNAPSE_EXPANDER)
delay_expander = executable_finder.get_executable_path(DELAY_EXPANDER)
progress = ProgressBar(len(app_graph.vertices) + 2, "Expanding Synapses")
# Find the places where the synapse expander and delay receivers should run
expander_cores = ExecutableTargets()
for vertex in progress.over(app_graph.vertices, finish_at_end=False):
# Find population vertices
if isinstance(
vertex, (AbstractPopulationVertex, DelayExtensionVertex)):
# Add all machine vertices of the population vertex to ones
# that need synapse expansion
for m_vertex in graph_mapper.get_machine_vertices(vertex):
vertex_slice = graph_mapper.get_slice(m_vertex)
if vertex.gen_on_machine(vertex_slice):
placement = placements.get_placement_of_vertex(m_vertex)
if isinstance(vertex, AbstractPopulationVertex):
binary = synapse_expander
else:
binary = delay_expander
expander_cores.add_processor(
binary, placement.x, placement.y, placement.p)
# Launch the delay receivers
expander_app_id = transceiver.app_id_tracker.get_new_id()
transceiver.execute_application(expander_cores, expander_app_id)
progress.update()
# Wait for everything to finish
finished = False
try:
transceiver.wait_for_cores_to_be_in_state(
expander_cores.all_core_subsets, expander_app_id,
[CPUState.FINISHED])
progress.update()
finished = True
_extract_iobuf(expander_cores, transceiver, provenance_file_path)
progress.end()
except Exception:
logger.exception("Synapse expander has failed")
_handle_failure(
expander_cores, transceiver, provenance_file_path)
finally:
transceiver.stop_application(expander_app_id)
transceiver.app_id_tracker.free_id(expander_app_id)
if not finished:
raise SpynnakerException(
"The synapse expander failed to complete")
示例5: __call__
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def __call__(self, executable_targets, app_id, transceiver):
progress = ProgressBar(
executable_targets.total_processors + 1,
"Loading executables onto the machine")
for binary in executable_targets.binaries:
progress.update(self._launch_binary(
executable_targets, binary, transceiver, app_id))
self._start_simulation(executable_targets, transceiver, app_id)
progress.update()
progress.end()
示例6: __call__
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def __call__(self, app_id, txrx, executable_types):
total_processors = \
len(executable_types[ExecutableType.USES_SIMULATION_INTERFACE])
all_core_subsets = \
executable_types[ExecutableType.USES_SIMULATION_INTERFACE]
progress = ProgressBar(
total_processors,
"Turning off all the cores within the simulation")
# check that the right number of processors are finished
processors_finished = txrx.get_core_state_count(
app_id, CPUState.FINISHED)
finished_cores = processors_finished
while processors_finished != total_processors:
if processors_finished > finished_cores:
progress.update(processors_finished - finished_cores)
finished_cores = processors_finished
processors_rte = txrx.get_core_state_count(
app_id, CPUState.RUN_TIME_EXCEPTION)
processors_watchdogged = txrx.get_core_state_count(
app_id, CPUState.WATCHDOG)
if processors_rte > 0 or processors_watchdogged > 0:
raise ExecutableFailedToStopException(
"{} of {} processors went into an error state when"
" shutting down".format(
processors_rte + processors_watchdogged,
total_processors))
successful_cores_finished = txrx.get_cores_in_state(
all_core_subsets, CPUState.FINISHED)
for core_subset in all_core_subsets:
for processor in core_subset.processor_ids:
if not successful_cores_finished.is_core(
core_subset.x, core_subset.y, processor):
self._update_provenance_and_exit(
txrx, processor, core_subset)
time.sleep(0.5)
processors_finished = txrx.get_core_state_count(
app_id, CPUState.FINISHED)
progress.end()
示例7: __call__
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def __call__(self, report_folder, application_graph):
"""
:param report_folder: the report folder to put figure into
:param application_graph: the app graph
:rtype: None
"""
# create holders for data
vertex_holders = dict()
dot_diagram = self._get_diagram(
"The graph of the network in graphical form")
# build progress bar for the vertices, edges, and rendering
progress = ProgressBar(
application_graph.n_vertices +
application_graph.n_outgoing_edge_partitions + 1,
"generating the graphical representation of the neural network")
# write vertices into dot diagram
for vertex_counter, vertex in progress.over(
enumerate(application_graph.vertices), False):
dot_diagram.node(
"{}".format(vertex_counter),
"{} ({} neurons)".format(vertex.label, vertex.n_atoms))
vertex_holders[vertex] = vertex_counter
# write edges into dot diagram
for partition in progress.over(
application_graph.outgoing_edge_partitions, False):
for edge in partition.edges:
source_vertex_id = vertex_holders[edge.pre_vertex]
dest_vertex_id = vertex_holders[edge.post_vertex]
if isinstance(edge, ProjectionApplicationEdge):
for synapse_info in edge.synapse_information:
dot_diagram.edge(
"{}".format(source_vertex_id),
"{}".format(dest_vertex_id),
"{}".format(synapse_info.connector))
else:
dot_diagram.edge(
"{}".format(source_vertex_id),
"{}".format(dest_vertex_id))
# write dot file and generate pdf
file_to_output = os.path.join(report_folder, "network_graph.gv")
dot_diagram.render(file_to_output, view=False)
progress.update()
progress.end()
开发者ID:SpiNNakerManchester,项目名称:sPyNNaker,代码行数:50,代码来源:spynnaker_neuron_network_specification_report.py
示例8: __call__
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def __call__(self, machine, file_path):
"""
:param machine:
:param file_path:
"""
progress = ProgressBar(
(machine.max_chip_x + 1) * (machine.max_chip_y + 1) + 2,
"Converting to JSON machine")
# write basic stuff
json_obj = {
"width": machine.max_chip_x + 1,
"height": machine.max_chip_y + 1,
"chip_resources": {
"cores": CHIP_HOMOGENEOUS_CORES,
"sdram": CHIP_HOMOGENEOUS_SDRAM,
"sram": CHIP_HOMOGENEOUS_SRAM,
"router_entries": ROUTER_HOMOGENEOUS_ENTRIES,
"tags": CHIP_HOMOGENEOUS_TAGS},
"dead_chips": [],
"dead_links": []}
# handle exceptions (dead chips)
exceptions = defaultdict(dict)
for x in range(0, machine.max_chip_x + 1):
for y in progress.over(range(0, machine.max_chip_y + 1), False):
self._add_exceptions(json_obj, machine, x, y, exceptions)
json_obj["chip_resource_exceptions"] = [
[x, y, exceptions[x, y]] for x, y in exceptions]
progress.update()
# dump to json file
with open(file_path, "w") as f:
json.dump(json_obj, f)
progress.update()
# validate the schema
file_format_schemas.validate(json_obj, "machine.json")
# update and complete progress bar
progress.end()
return file_path
示例9: call
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def call(self, inputs):
# Get the inputs to pass as the arguments
arg_inputs = self._get_inputs(inputs)
# Convert the arguments using the inputs
args = [
arg.format(**arg_inputs) for arg in self._command_line_arguments
]
algorithm_progress_bar = ProgressBar(
1, "Running external algorithm {}".format(self._algorithm_id))
# Run the external command
child = subprocess.Popen(
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
child.wait()
algorithm_progress_bar.update(1)
algorithm_progress_bar.end()
# Detect any errors
if child.returncode != 0:
stdout, stderr = child.communicate()
raise PacmanExternalAlgorithmFailedToCompleteException(
"Algorithm {} returned a non-zero error code {}\n"
" Inputs: {}\n"
" Output: {}\n"
" Error: {}\n".format(
self._algorithm_id, child.returncode,
inputs.keys(), stdout, stderr))
# Return the results processed into a dict
# Use None here as the results don't actually exist, and are expected
# to be obtained from a file, whose name is in inputs
return self._get_outputs(inputs, [None] * len(self._outputs))
示例10: __call__
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def __call__(self, machine_graph, plan_n_timesteps, file_path):
"""
:param machine_graph: The graph to convert
:param plan_n_timesteps: number of timesteps to plan for
:type plan_n_timesteps: int
:param file_path: Where to write the JSON
"""
progress = ProgressBar(
machine_graph.n_vertices + 1, "Converting to JSON graph")
# write basic stuff
json_graph = dict()
# write vertices data
vertices_resources = dict()
json_graph["vertices_resources"] = vertices_resources
edges_resources = defaultdict()
json_graph["edges"] = edges_resources
vertex_by_id = dict()
partition_by_id = dict()
for vertex in progress.over(machine_graph.vertices, False):
self._convert_vertex(
vertex, vertex_by_id, vertices_resources, edges_resources,
machine_graph, plan_n_timesteps, partition_by_id)
with open(file_path, "w") as f:
json.dump(json_graph, f)
progress.update()
file_format_schemas.validate(json_graph, "machine_graph.json")
progress.end()
return file_path, vertex_by_id, partition_by_id
示例11: __call__
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def __call__(self, machine_graph, machine, plan_n_timesteps):
"""
:param machine_graph: The machine_graph to place
:type machine_graph:\
:py:class:`pacman.model.graphs.machine.MachineGraph`
:param machine:\
The machine with respect to which to partition the application\
graph
:type machine: :py:class:`spinn_machine.Machine`
:param plan_n_timesteps: number of timesteps to plan for
:type plan_n_timesteps: int
:return: A set of placements
:rtype: :py:class:`pacman.model.placements.Placements`
:raise pacman.exceptions.PacmanPlaceException: \
If something goes wrong with the placement
"""
# Iterate over vertices and generate placements
# +3 covers check_constraints, get_same_chip_vertex_groups and
# create_vertices_groups
progress = ProgressBar(
machine_graph.n_vertices + 3, "Placing graph vertices")
# check that the algorithm can handle the constraints
self._check_constraints(
machine_graph.vertices,
additional_placement_constraints={SameChipAsConstraint})
progress.update()
# Get which vertices must be placed on the same chip as another vertex
same_chip_vertex_groups = get_same_chip_vertex_groups(machine_graph)
progress.update()
# Work out the vertices that should be on the same chip by one-to-one
# connectivity
one_to_one_groups = create_vertices_groups(
machine_graph.vertices,
functools.partial(_find_one_to_one_vertices, graph=machine_graph))
progress.update()
return self._do_allocation(
one_to_one_groups, same_chip_vertex_groups, machine,
plan_n_timesteps, machine_graph, progress)
示例12: __call__
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def __call__(self, machine_graph, machine, plan_n_timesteps):
progress_bar = ProgressBar(9, "Placing and Routing")
vertices_resources, nets, net_names = \
convert_to_rig_graph(machine_graph, plan_n_timesteps)
progress_bar.update()
rig_machine = convert_to_rig_machine(machine)
progress_bar.update()
rig_constraints = create_rig_machine_constraints(machine)
progress_bar.update()
rig_constraints.extend(create_rig_graph_constraints(
machine_graph, rig_machine))
progress_bar.update()
rig_placements = place(
vertices_resources, nets, rig_machine, rig_constraints)
progress_bar.update()
rig_allocations = allocate(
vertices_resources, nets, rig_machine, rig_constraints,
rig_placements)
progress_bar.update()
rig_routes = route(
vertices_resources, nets, rig_machine, rig_constraints,
rig_placements, rig_allocations, "cores")
rig_routes = {
name: rig_routes[net] for net, name in iteritems(net_names)}
progress_bar.update()
placements = convert_from_rig_placements(
rig_placements, rig_allocations, machine_graph)
progress_bar.update()
routes = convert_from_rig_routes(rig_routes, machine_graph)
progress_bar.update()
progress_bar.end()
return placements, routes
示例13: __call__
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def __call__(
self, routing_tables, transceiver, machine, app_id,
provenance_file_path, compress_only_when_needed=True,
compress_as_much_as_possible=False):
"""
:param routing_tables: the memory routing tables to be compressed
:param transceiver: the spinnman interface
:param machine: the SpiNNaker machine representation
:param app_id: the application ID used by the main application
:param provenance_file_path: the path to where to write the data
:return: flag stating routing compression and loading has been done
"""
# pylint: disable=too-many-arguments
# build progress bar
progress = ProgressBar(
len(routing_tables.routing_tables) + 2,
"Running routing table compression on chip")
compressor_app_id = transceiver.app_id_tracker.get_new_id()
# figure size of SDRAM needed for each chip for storing the routing
# table
for routing_table in progress.over(routing_tables, False):
self._load_routing_table(
routing_table, transceiver, app_id, compressor_app_id,
compress_only_when_needed, compress_as_much_as_possible)
# load the router compressor executable
executable_targets = self._load_executables(
routing_tables, compressor_app_id, transceiver, machine)
# update progress bar
progress.update()
# Wait for the executable to finish
succeeded = False
try:
transceiver.wait_for_cores_to_be_in_state(
executable_targets.all_core_subsets, compressor_app_id,
[CPUState.FINISHED])
succeeded = True
finally:
# get the debug data
if not succeeded:
self._handle_failure(
executable_targets, transceiver, provenance_file_path,
compressor_app_id)
# Check if any cores have not completed successfully
self._check_for_success(
executable_targets, transceiver,
provenance_file_path, compressor_app_id)
# update progress bar
progress.update()
# stop anything that's associated with the compressor binary
transceiver.stop_application(compressor_app_id)
transceiver.app_id_tracker.free_id(compressor_app_id)
# update the progress bar
progress.end()
示例14: __call__
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def __call__(self, machine_graph, machine, plan_n_timesteps):
progress_bar = ProgressBar(7, "Placing")
vertices_resources, nets, _ = \
convert_to_rig_graph(machine_graph, plan_n_timesteps)
progress_bar.update()
rig_machine = convert_to_rig_machine(machine)
progress_bar.update()
rig_constraints = create_rig_machine_constraints(machine)
progress_bar.update()
rig_constraints.extend(create_rig_graph_constraints(
machine_graph, rig_machine))
progress_bar.update()
rig_placements = place(
vertices_resources, nets, rig_machine, rig_constraints)
progress_bar.update()
rig_allocations = allocate(
vertices_resources, nets, rig_machine, rig_constraints,
rig_placements)
progress_bar.update()
placements = convert_from_rig_placements(
rig_placements, rig_allocations, machine_graph)
progress_bar.update()
progress_bar.end()
return placements
示例15: __call__
# 需要导入模块: from spinn_utilities.progress_bar import ProgressBar [as 别名]
# 或者: from spinn_utilities.progress_bar.ProgressBar import update [as 别名]
def __call__(self, application_graph, graph_mapper, machine_graph,
n_keys_map):
"""
:param application_graph: The application graph
:param graph_mapper: the mapping between graphs
:param machine_graph: the machine graph
:param n_keys_map: the mapping between edges and n keys
:return: routing information objects
"""
progress_bar = ProgressBar(
machine_graph.n_outgoing_edge_partitions * 3,
"Allocating routing keys")
# ensure groups are stable and correct
self._determine_groups(
machine_graph, graph_mapper, application_graph, n_keys_map,
progress_bar)
# define the key space
bit_field_space = BitField(32)
field_positions = set()
# locate however many types of constraints there are
seen_fields = deduce_types(machine_graph)
progress_bar.update(machine_graph.n_outgoing_edge_partitions)
if len(seen_fields) > 1:
self._adds_application_field_to_the_fields(seen_fields)
# handle the application space
self._create_application_space_in_the_bit_field_space(
bit_field_space, seen_fields, field_positions)
# assign fields to positions in the space
bit_field_space.assign_fields()
# get positions of the flexible fields:
self._assign_flexi_field_positions(
bit_field_space, seen_fields, field_positions)
# create routing_info_allocator
routing_info = RoutingInfo()
seen_mask_instances = 0
# extract keys and masks for each edge from the bitfield
for partition in machine_graph.outgoing_edge_partitions:
# get keys and masks
keys_and_masks, seen_mask_instances = \
self._extract_keys_and_masks_from_bit_field(
partition, bit_field_space, n_keys_map,
seen_mask_instances)
# update routing info for each edge in the partition
partition_info = PartitionRoutingInfo(keys_and_masks, partition)
routing_info.add_partition_info(partition_info)
# update the progress bar again
progress_bar.update()
progress_bar.end()
return routing_info, field_positions