Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…Link into devel
  • Loading branch information
jdcpni committed Nov 28, 2024
2 parents 8ae27bb + 8d2fafc commit 80d0dd2
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pnl-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ jobs:
- name: Test with pytest
timeout-minutes: 180
run: pytest --junit-xml=tests_out.xml --verbosity=0 -n logical ${{ matrix.extra-args }}
run: pytest --junit-xml=tests_out.xml --verbosity=0 -n logical --capture=sys -o console_output_style=count ${{ matrix.extra-args }}

- name: Upload test results
uses: actions/upload-artifact@v4
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ jobs:
python-version: [3.7, 3.8, 3.9, '3.10', 3.11, 3.12]
os: [ubuntu-latest, macos-latest, windows-latest]
dist: [wheel, sdist]
exclude:
# 3.7 is broken on macos-11,
# https://github.com/actions/virtual-environments/issues/4230
- python-version: '3.7'
os: macos-latest

runs-on: ${{ matrix.os }}
needs: [create-python-dist]
Expand Down Expand Up @@ -128,7 +133,7 @@ jobs:
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}-${{ matrix.python-version }}
name: test-results-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.dist }}
path: tests_out.xml
retention-days: 30
if: success() || failure()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ def _instantiate_objective_mechanism(self, input_ports=None, context=None):
if not isinstance(monitor_for_control, list):
monitor_for_control = [monitor_for_control]

# If objective_mechanism is used to specify OutputPorts to be monitored (legacy feature)
# If objective_mechanism arg is used to specify OutputPorts to be monitored (legacy feature)
# move them to monitor_for_control
if isinstance(self.objective_mechanism, list):
monitor_for_control.extend(self.objective_mechanism)
Expand Down
29 changes: 18 additions & 11 deletions psyneulink/core/compositions/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2912,7 +2912,7 @@ def input_function(env, result):
from psyneulink.core.components.mechanisms.modulatory.modulatorymechanism import ModulatoryMechanism_Base
from psyneulink.core.components.mechanisms.processing.compositioninterfacemechanism import CompositionInterfaceMechanism
from psyneulink.core.components.mechanisms.processing.objectivemechanism import ObjectiveMechanism
from psyneulink.core.components.mechanisms.processing.processingmechanism import ProcessingMechanism
from psyneulink.core.components.mechanisms.processing.processingmechanism import ProcessingMechanism, ProcessingMechanism_Base
from psyneulink.core.components.ports.inputport import InputPort, InputPortError
from psyneulink.core.components.ports.modulatorysignals.controlsignal import ControlSignal
from psyneulink.core.components.ports.modulatorysignals.learningsignal import LearningSignal
Expand All @@ -2939,7 +2939,8 @@ def input_function(env, result):
INPUT, INPUT_PORTS, INPUTS, INPUT_CIM_NAME, \
LEARNABLE, LEARNED_PROJECTIONS, LEARNING_FUNCTION, LEARNING_MECHANISM, LEARNING_MECHANISMS, LEARNING_PATHWAY, \
LEARNING_SIGNAL, Loss, \
MATRIX, MAYBE, MODEL_SPEC_ID_METADATA, MONITOR, MONITOR_FOR_CONTROL, NAME, NESTED, NO_CLAMP, NODE, NODES, \
MATRIX, MAYBE, MODEL_SPEC_ID_METADATA, MONITOR, MONITOR_FOR_CONTROL, MULTIPLICATIVE_PARAM, \
NAME, NESTED, NO_CLAMP, NODE, NODES, \
OBJECTIVE_MECHANISM, ONLINE, ONLY, OUTCOME, OUTPUT, OUTPUT_CIM_NAME, OUTPUT_MECHANISM, OUTPUT_PORTS, OWNER_VALUE, \
PARAMETER, PARAMETER_CIM_NAME, PORT, \
PROCESSING_PATHWAY, PROJECTION, PROJECTIONS, PROJECTION_TYPE, PROJECTION_PARAMS, PULSE_CLAMP, RECEIVER, \
Expand Down Expand Up @@ -4368,6 +4369,7 @@ def add_node(self, node, required_roles=None, context=None):
else:
self._pre_existing_pathway_components[NODES].append(node)

# Aux components are being added by Composition, even if main Node is being added was from COMMAND_LINE
invalid_aux_components = self._add_node_aux_components(node, context=context)

# Implement required_roles
Expand Down Expand Up @@ -4639,13 +4641,9 @@ def _add_required_node_role(self, node, role, context=None):
raise CompositionError('Invalid NodeRole: {0}'.format(role))

# Disallow assignment of NodeRoles by user that are not programmitically modifiable:
# FIX 4/25/20 [JDC]: CHECK IF ROLE OR EQUIVALENT STATUS HAS ALREADY BEEN ASSIGNED AND, IF SO, ISSUE WARNING
# FIX 4/25/20 [JDC] - CHECK IF ROLE OR EQUIVALENT STATUS HAS ALREADY BEEN ASSIGNED AND, IF SO, ISSUE WARNING
if context.source == ContextFlags.COMMAND_LINE:
if role in {NodeRole.CONTROL_OBJECTIVE, NodeRole.CONTROLLER_OBJECTIVE}:
# raise CompositionError(f"{role} cannot be directly assigned to an {ObjectiveMechanism.__name__};"
# # f"assign 'CONTROL' to 'role' argument of consructor for {node} of {self.name}")
# f"try assigning {node} to '{OBJECTIVE_MECHANISM}' argument of "
# f"the constructor for the desired {ControlMechanism.__name__}.")
if role in {NodeRole.CONTROL_OBJECTIVE, NodeRole.CONTROLLER_OBJECTIVE} and not node.control_mechanism:
warnings.warn(f"{role} should be assigned with caution to {self.name}. "
f"{ObjectiveMechanism.__name__}s are generally constructed automatically by a "
f"{ControlMechanism.__name__}, or assigned to it in the '{OBJECTIVE_MECHANISM}' "
Expand Down Expand Up @@ -5116,7 +5114,7 @@ def _add_node_aux_components(self, node, context=None):
# ignore these for now and try to activate them again during every call to _analyze_graph
# and, at runtime, if there are still any invalid aux_components left, issue a warning
projections = []
# Add all "nodes" to the composition first (in case projections reference them)
# Add all Nodes to the Composition first (in case Projections reference them)
for i, component in enumerate(node.aux_components):
if isinstance(component, (Mechanism, Composition)):
if isinstance(component, Composition):
Expand All @@ -5137,10 +5135,10 @@ def _add_node_aux_components(self, node, context=None):
"specification (True or False).".format(component, node.name))
elif isinstance(component[0], (Mechanism, Composition)):
if isinstance(component[1], NodeRole):
self.add_node(node=component[0], required_roles=component[1])
self.add_node(node=component[0], required_roles=component[1], context=context)
elif isinstance(component[1], list):
if isinstance(component[1][0], NodeRole):
self.add_node(node=component[0], required_roles=component[1])
self.add_node(node=component[0], required_roles=component[1], context=context)
else:
raise CompositionError("Invalid Component specification ({}) in {}'s aux_components. "
"If a tuple is used to specify a Mechanism or Composition, then "
Expand Down Expand Up @@ -9803,6 +9801,15 @@ def get_controller(comp):

return total_cost

def _get_modulable_mechanisms(self):
modulated_mechanisms = []
for mech in [m for m in self.nodes if (isinstance(m, ProcessingMechanism_Base) and
not (isinstance(m, ObjectiveMechanism)
and self.get_roles_for_node(m) != NodeRole.CONTROL)
and hasattr(m.function, MULTIPLICATIVE_PARAM))]:
modulated_mechanisms.append(mech)
return modulated_mechanisms

# endregion CONTROL

# ******************************************************************************************************************
Expand Down
Loading

0 comments on commit 80d0dd2

Please sign in to comment.