Skip to content

Commit

Permalink
fix: raise resolution errors when it was expect an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonasiv committed Feb 4, 2025
1 parent d187f56 commit 0eafc30
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
13 changes: 11 additions & 2 deletions lib/syskit/cli/doc/gen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ def self.save_profile_model(target_path, profile_m)
# @param [Actions::Profile::Definition] profile_def
def self.save_profile_definition(target_path, profile_def)
begin
task = compute_system_network(
task, resolution_errors = compute_system_network(
profile_def,
validate_abstract_network: false,
validate_generated_network: false
)
unless resolution_errors.empty?
raise NetworkGeneration::PartialNetworkResolution,
resolution_errors
end

hierarchy, dataflow =
save_profile_definition_graphs(target_path, task, profile_def)
Expand Down Expand Up @@ -266,7 +270,12 @@ def self.compute_system_network(model, main_plan = Roby::Plan.new, **options)
main_plan.add(original_task = model.as_plan)
engine = Syskit::NetworkGeneration::Engine.new(main_plan)
planning_task = original_task.planning_task
mapping = engine.compute_system_network([planning_task], **options)
mapping, resolution_errors =
engine.compute_system_network([planning_task], **options)
unless resolution_errors.empty?
raise Syskit::NetworkGeneration::PartialNetworkResolution,
resolution_errors
end

if engine.work_plan.respond_to?(:commit_transaction)
engine.work_plan.commit_transaction
Expand Down
10 changes: 8 additions & 2 deletions lib/syskit/gui/component_network_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,17 @@ def render(model,
begin
if method == :compute_system_network
tic = Time.now
@task = compute_system_network(model, plan)
@task, resolution_errors = compute_system_network(model, plan)
exception = NetworkGeneration::PartialNetworkResolution.new(
resolution_errors
)
timing = Time.now - tic
elsif method == :compute_deployed_network
tic = Time.now
@task = compute_deployed_network(model, plan)
@task, resolution_errors = compute_deployed_network(model, plan)
exception = NetworkGeneration::PartialNetworkResolution.new(
resolution_errors
)
timing = Time.now - tic
else
@task = instanciate_model(model, plan, instanciate_options)
Expand Down
13 changes: 9 additions & 4 deletions lib/syskit/test/stub_network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,15 @@ def apply_in_transaction(trsc, root_tasks, remote_task: false)
trsc.static_garbage_collect(
protected_roots: trsc_new_roots | trsc_other_tasks
)
NetworkGeneration::SystemNetworkGenerator
.verify_task_allocation(
trsc, components: trsc_tasks.find_all(&:plan)
)
allocation_error = NetworkGeneration::SystemNetworkGenerator
.verify_task_allocation(
trsc, syskit_tasks, merge_solver,
components: trsc_tasks.find_all(&:plan)
)
unless allocation_error.empty?
raise NetworkGeneration::PartialNetworkResolution, allocation_error
end

mapped_tasks
end

Expand Down

0 comments on commit 0eafc30

Please sign in to comment.