Skip to content
Snippets Groups Projects
Select Git revision
  • dae97a7e47748c7dd18388d1bfd60cf9435e127f
  • master default protected
  • L2SS-1914-fix_job_dispatch
  • TMSS-3170
  • TMSS-3167
  • TMSS-3161
  • TMSS-3158-Front-End-Only-Allow-Changing-Again
  • TMSS-3133
  • TMSS-3319-Fix-Templates
  • test-fix-deploy
  • TMSS-3134
  • TMSS-2872
  • defer-state
  • add-custom-monitoring-points
  • TMSS-3101-Front-End-Only
  • TMSS-984-choices
  • SDC-1400-Front-End-Only
  • TMSS-3079-PII
  • TMSS-2936
  • check-for-max-244-subbands
  • TMSS-2927---Front-End-Only-PXII
  • Before-Remove-TMSS
  • LOFAR-Release-4_4_318 protected
  • LOFAR-Release-4_4_317 protected
  • LOFAR-Release-4_4_316 protected
  • LOFAR-Release-4_4_315 protected
  • LOFAR-Release-4_4_314 protected
  • LOFAR-Release-4_4_313 protected
  • LOFAR-Release-4_4_312 protected
  • LOFAR-Release-4_4_311 protected
  • LOFAR-Release-4_4_310 protected
  • LOFAR-Release-4_4_309 protected
  • LOFAR-Release-4_4_308 protected
  • LOFAR-Release-4_4_307 protected
  • LOFAR-Release-4_4_306 protected
  • LOFAR-Release-4_4_304 protected
  • LOFAR-Release-4_4_303 protected
  • LOFAR-Release-4_4_302 protected
  • LOFAR-Release-4_4_301 protected
  • LOFAR-Release-4_4_300 protected
  • LOFAR-Release-4_4_299 protected
41 results

schedulingunitflow.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    node_queries.py 3.70 KiB
    
    from neo4j import Driver
    from neo4j_queries.utils import clean_component_id
    
    def ensure_component_node(driver: Driver, prefixed_component_id: str) -> tuple[int,str]:
        """
        Ensures that there exists a component node corresponding to the file with local path prefixed_component_id.
        The ID of the component can be given based on the local relative path, so it is cleaned 
        before querying Neo4j.
    
        Parameters:
            driver (Driver): the Neo4j driver
            prefixed_component_id (str): the local relative path of the component
    
        Returns:
            tuple[int,str]: the Neoj4 internal ID of the component node, the component ID of the component
        """
        component_id = clean_component_id(prefixed_component_id)
        query = """
        MERGE (c:Component {component_id: $component_id})
        RETURN elementId(c) AS node_internal_id, c.component_id AS component_id
        """
        with driver.session() as session:
            result = session.run(query, component_id=component_id)
            record = result.single()
            return record["node_internal_id"], record["component_id"]
    
    def ensure_parameter_node(driver: Driver, node_id: str, prefixed_component_id: str, param_type: str) \
            -> tuple[int,str,str,str]: 
        """
        Ensures that there exists a parameter node with ID node_id and type param_type
        associated with the component in the file with local path prefixed_component_id.
        The ID of the component can be given based on the local relative path, so it is cleaned 
        before querying Neo4j.
    
        Parameters:
            driver (Driver): the Neo4j driver
            node_id (str): the ID of the parameter
            prefixed_component_id (str): the local relative path of the component
            param_type (str): the type of the parameter ('in' or 'out')
    
        Returns:
            tuple[int,str,str, str]: the Neoj4 internal ID of the parameter node, the parameter ID, the component ID, the parameter type
        """
        component_id = clean_component_id(prefixed_component_id)
        query = """
        MERGE (n:Parameter {parameter_id: $node_id, component_id: $component_id, parameter_type: $param_type})
        RETURN elementId(n) AS node_internal_id, n.parameter_id AS id_property, n.component_id AS component_id_property,
            n.parameter_type AS parameter_type_property
        """
        with driver.session() as session:
            result = session.run(query, node_id=node_id, component_id=component_id, param_type=param_type)
            record = result.single()
            return record["node_internal_id"], record["id_property"], record["component_id_property"], record['parameter_type_property']
        
    def ensure_data_node(driver: Driver, node_id: str, prefixed_component_id: str) -> tuple[int,str,str]:
        """
        Ensures that there exists a data node with ID node_id
        associated with the component in the file with local path prefixed_component_id.
        The ID of the component can be given based on the local relative path, so it is cleaned 
        before querying Neo4j.
    
        Parameters:
            driver (Driver): the Neo4j driver
            node_id (str): the ID of the data 
            prefixed_component_id (str): the local relative path of the component
    
        Returns:
            tuple[int,str,str, str]: the Neoj4 internal ID of the data node, the data ID, the component ID
        """
        component_id = clean_component_id(prefixed_component_id)
        query = """
        MERGE (n:Data {data_id: $node_id, component_id: $component_id})
        RETURN elementId(n) AS node_internal_id, n.data_id AS id_property, n.component_id AS component_id_property
        """
        with driver.session() as session:
            result = session.run(query, node_id=node_id, component_id=component_id)
            record = result.single()
            return record["node_internal_id"], record["id_property"], record["component_id_property"]