Refactor NodeCollection, breaking up single NodeCollection class and NodeCollectionType Enum into
distinct classes with inheritance.
Changes
Breaks up NodeCollection into subclasses. BaseNodeCollection, which has subclasses UserCodeNodeCollection, ImportNodeCollection and InputVarNodeCollection. UserCodeNodeCollection has a subclass for ArtifactNodeCollection. Artifact collections coming from re-use precomputed are unchanged, and defined by is_pre_computed_artifact.
Remove unused parameters from these NodeCollections. For ImportNodeCollection and InputVarNodeCollection, only a node_list inherited from BaseNodeCollection is necessary.
Remove module_import, predecessor_artifact, sliced_nodes and other unneeded parameters from dataclass.
Moved get_input_variable_sources to method of UserCodeNodeCollection instead of a function in SessionArtifacts.
Moved graph to be a parameter for a NodeCollection, removing the need to update_graph when NodeCollection is created. This allows _get_subgraph_from_node_list to be moved as a helper function in NodeCollection constructor.
Kept get_function_definition and other methods which require the use of a raw_codeblock generated from the NodeCollection nodes as methods of NodeCollection.
Move get_function_call_block to SessionWriters along with other utilities in SessionArtifacts to generate code from SessionsArtifacts.
Redo matched_pre_computed logic to be explicit if else condition instead of implicit None=non-reuse Artifact collection type.
Move writer methods from SessionArtifacts and NodeCollection to SessionWriter. These include get_session_module_imports, get_session_function_name, get_session_function_body, get_session_input_parameters_lines, get_session_input_parameters_spec, get_session_function_callblock, get_session_artifact_function_definitions, get_session_function, all of which return code which is defined by the SessionArtifact.
Move include_non_slice_as_comment to be a property of SessionWriters.
Fixes # (issue)
LIN-640
LIN-667
Type of change
Please delete options that are not relevant.
[ X ] Refactor (non-breaking change which does not change functionality)
How Has This Been Tested?
Existing pytest
Also added example test creating a UserNodeCollection, which can be used in the future to test other NodeCollection functionality.
Description
Refactor NodeCollection, breaking up single NodeCollection class and NodeCollectionType Enum into distinct classes with inheritance.
Changes
is_pre_computed_artifact
.module_import
,predecessor_artifact
,sliced_nodes
and other unneeded parameters from dataclass.get_input_variable_sources
to method ofUserCodeNodeCollection
instead of a function in SessionArtifacts.update_graph
when NodeCollection is created. This allows_get_subgraph_from_node_list
to be moved as a helper function in NodeCollection constructor.get_function_definition
and other methods which require the use of a raw_codeblock generated from the NodeCollection nodes as methods of NodeCollection.get_function_call_block
to SessionWriters along with other utilities in SessionArtifacts to generate code from SessionsArtifacts.matched_pre_computed
logic to be explicit if else condition instead of implicit None=non-reuse Artifact collection type.get_session_module_imports
,get_session_function_name
,get_session_function_body
,get_session_input_parameters_lines
,get_session_input_parameters_spec
,get_session_function_callblock
,get_session_artifact_function_definitions
,get_session_function
, all of which return code which is defined by the SessionArtifact.include_non_slice_as_comment
to be a property of SessionWriters.Fixes # (issue) LIN-640 LIN-667
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Existing pytest
Also added example test creating a UserNodeCollection, which can be used in the future to test other NodeCollection functionality.