parameters: (project_id, user=None)
docstring: Tests which of the needed classes and relations is missing
      from the project's semantic space and adds those.
docstring_summary: Tests which of the needed classes and relations is missing
      from the project's semantic space and adds those.
docstring_tokens: Tests which of the needed classes and relations is missing from the project s semantic space and adds those .
function: def setup_tracing(project_id, user=None) -> None:
      """ Tests which of the needed classes and relations is missing
      from the project's semantic space and adds those.
      """
      if not user:
          user = get_system_user()
      # Remember available classes
      available_classes = {}
  
      # Add missing classes
      for c in needed_classes:
          class_object, _ = Class.objects.get_or_create(
              class_name=c,
              project_id=project_id,
              defaults={'user': user,
                        'description': needed_classes[c]})
          available_classes[c] = class_object
      # Add missing relations
      for r in needed_relations:
          defaults = {
              'user': user,
          }
          data_type = type(needed_relations[r])
          if data_type == str:
              defaults['description'] = needed_relations[r]
          else:
              defaults.update(needed_relations[r]) # type: ignore
  
          Relation.objects.get_or_create(
              relation_name=r,
              project_id=project_id,
              defaults=defaults)
      # Add missing sampler states
      for sn, sd in needed_sampler_states.items():
          SamplerState.objects.get_or_create(
              name=sn, defaults={'description': sd})
      # Add missing sampler interval states
      for sn, sd in needed_sampler_interval_states.items():
          SamplerIntervalState.objects.get_or_create(
              name=sn, defaults={'description': sd})
      # Add missing sampler domain types
      for sn, sd in needed_sampler_domain_types.items():
          SamplerDomainType.objects.get_or_create(
              name=sn, defaults={'description': sd})
      # Add missing sampler connector states
      for sn, sd in needed_sampler_connector_states.items():
          SamplerConnectorState.objects.get_or_create(
              name=sn, defaults={'description': sd})
  
      # Add root class instance
      ClassInstance.objects.get_or_create(
          class_column=available_classes['root'],
          project_id=project_id,
          defaults={'user': user,
                    'name': 'neuropile'})
function_tokens: def setup_tracing ( project_id , user = None ) -> None : if not user : user = get_system_user ( ) # Remember available classes available_classes = { } # Add missing classes for c in needed_classes : class_object , _ = Class . objects . get_or_create ( class_name = c , project_id = project_id , defaults = { 'user' : user , 'description' : needed_classes [ c ] } ) available_classes [ c ] = class_object # Add missing relations for r in needed_relations : defaults = { 'user' : user , } data_type = type ( needed_relations [ r ] ) if data_type == str : defaults [ 'description' ] = needed_relations [ r ] else : defaults . update ( needed_relations [ r ] ) # type: ignore Relation . objects . get_or_create ( relation_name = r , project_id = project_id , defaults = defaults ) # Add missing sampler states for sn , sd in needed_sampler_states . items ( ) : SamplerState . objects . get_or_create ( name = sn , defaults = { 'description' : sd } ) # Add missing sampler interval states for sn , sd in needed_sampler_interval_states . items ( ) : SamplerIntervalState . objects . get_or_create ( name = sn , defaults = { 'description' : sd } ) # Add missing sampler domain types for sn , sd in needed_sampler_domain_types . items ( ) : SamplerDomainType . objects . get_or_create ( name = sn , defaults = { 'description' : sd } ) # Add missing sampler connector states for sn , sd in needed_sampler_connector_states . items ( ) : SamplerConnectorState . objects . get_or_create ( name = sn , defaults = { 'description' : sd } ) # Add root class instance ClassInstance . objects . get_or_create ( class_column = available_classes [ 'root' ] , project_id = project_id , defaults = { 'user' : user , 'name' : 'neuropile' } )