Skip to content

Commit

Permalink
chore: test if agents are mergeable
Browse files Browse the repository at this point in the history
testing for object equality is too strict, and it fails on tests
of 'reuses an existing network', because the agents are created in
different cyles
  • Loading branch information
wvmcastro committed Jan 29, 2025
1 parent 633c291 commit 1c41f2b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/syskit/network_generation/merge_solver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ def mergeable_agents?(merged_task, task)

return false unless merge_when_identical_agents?

return true if task.execution_agent == merged_task.execution_agent
return true if task.execution_agent
.can_merge?(merged_task.execution_agent)

false
end
Expand Down
7 changes: 4 additions & 3 deletions lib/syskit/network_generation/system_network_deployer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ def initialize(plan,
# will run on the generated network
# @return [Set] the set of tasks for which the deployer could
# not find a deployment
def deploy(validate: true, reuse_deployments: false, deployment_tasks: {})
def deploy(validate: true, reuse_deployments: false)
debug "Deploying the system network"

all_tasks = plan.find_local_tasks(TaskContext).to_a
selected_deployments, missing_deployments =
select_deployments(all_tasks, reuse: reuse_deployments)
log_timepoint "select_deployments"

apply_selected_deployments(selected_deployments, deployment_tasks)
apply_selected_deployments(selected_deployments)
log_timepoint "apply_selected_deployments"

if validate
Expand Down Expand Up @@ -167,7 +167,8 @@ def select_deployments(tasks, reuse: false)
# @param [Component=>Deployment] selected_deployments the
# component-to-deployment association
# @return [void]
def apply_selected_deployments(selected_deployments, deployment_tasks = {})
def apply_selected_deployments(selected_deployments)
deployment_tasks = {}
selected_deployments.each do |task, deployed_task|
deployed_task, = deployed_task.instanciate(
plan,
Expand Down
11 changes: 4 additions & 7 deletions lib/syskit/network_generation/system_network_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,15 @@ def self.remove_abstract_composition_optional_children(plan)
end
end

def deploy(deployment_tasks)
def deploy
network_deployer = SystemNetworkDeployer.new(
plan,
merge_solver: merge_solver,
default_deployment_group: default_deployment_group
)

missing = network_deployer.deploy(validate: false,
reuse_deployments: true,
deployment_tasks: deployment_tasks)
reuse_deployments: true)
network_deployer.verify_all_tasks_deployed if validate_deployed_network?

raise unless missing.empty? # TODO
Expand All @@ -237,9 +236,7 @@ def compute_system_network(instance_requirements, garbage_collect: true,

@toplevel_instance_requirements = instance_requirements

deployment_tasks = {}

deploy(deployment_tasks) if early_deploy?
deploy if early_deploy?

merge_identical_tasks
log_timepoint "merge"
Expand All @@ -250,7 +247,7 @@ def compute_system_network(instance_requirements, garbage_collect: true,
link_to_busses
log_timepoint "link_to_busses"

deploy(deployment_tasks) if early_deploy?
deploy if early_deploy?

merge_identical_tasks

Expand Down

0 comments on commit 1c41f2b

Please sign in to comment.