<commit_before>require '/opt/engines/lib/ruby/system/system_config.rb'
require '/opt/engines/lib/ruby/system/system_utils.rb'
require '/opt/engines/lib/ruby/api/system/errors_api.rb'
require '/opt/engines/lib/ruby/containers/managed_container.rb'
require '/opt/engines/lib/ruby/containers/managed_engine.rb'
require '/opt/engines/lib/ruby/containers/managed_service.rb'
require '/opt/engines/lib/ruby/containers/system_service.rb'
require '/opt/engines/lib/ruby/managed_services/system_services/volume_service.rb'
require '/opt/engines/lib/ruby/managed_services/service_definitions/software_service_definition.rb'
require '/opt/engines/lib/ruby/service_manager/service_manager.rb'
require '/opt/engines/lib/ruby/api/public/engines_osapi_result.rb'

class EnginesCore < ErrorsApi
  require '/opt/engines/lib/ruby/system_registry/registry_handler.rb'
  require '/opt/engines/lib/ruby/api/public/build_controller.rb'
  require '/opt/engines/lib/ruby/system/dnshosting.rb'
  require_relative 'containers/container_api.rb'
  require_relative 'containers/service_api.rb'
  require_relative 'docker/docker_api.rb'
  require_relative 'system_api.rb'
  require_relative 'dns_api.rb'
  require_relative 'configurations_api.rb'
  require_relative 'blueprint_api.rb'
  require_relative 'system_preferences.rb'
  require_relative 'memory_statistics.rb'
  def initialize
    Signal.trap('HUP', proc { api_shutdown })
    Signal.trap('TERM', proc { api_shutdown })
    @docker_api = DockerApi.new
    @system_api = SystemApi.new(self)  # will change to to docker_api and not self
    @registry_handler = RegistryHandler.new(@system_api)
    @container_api = ContainerApi.new(@docker_api, @system_api, self)
    @service_api = ServiceApi.new(@docker_api, @system_api, self)
    @registry_handler.start
  end
  
  attr_reader :container_api, :service_api

  def check_hash(service_hash)
    return log_error_mesg('Nil service Hash', service_hash) if service_hash.nil?
    return log_error_mesg('Not a Service Hash', service_hash) unless service_hash.is_a?(Hash)  
    return true
  end
  
  def check_service_hash(service_hash)
    return false unless check_hash(service_hash)
    return log_error_mesg('No publisher name space', service_hash) unless service_hash.key?(:publisher_namespace)
    return log_error_mesg('nil publisher name space', service_hash) if service_hash[:publisher_namespace].nil? || service_hash[:publisher_namespace] == ''
    return log_error_mesg('No type path', service_hash) unless service_hash.key?(:type_path)
    return log_error_mesg('nil type path', service_hash) if service_hash[:type_path].nil? || service_hash[:type_path] == ''
    
    return true
  end
  
  def check_engine_hash(service_hash)
    return false unless check_hash(service_hash)
    # FIXME: Kludge
    # Klugde to avoid gui bugss
    unless service_hash.key?(:parent_engine)
      service_hash[:parent_engine] = service_hash[:engine_name]
    end
    # End of Kludge
    return log_error_mesg('No parent engine', service_hash) unless service_hash.key?(:parent_engine)
    return log_error_mesg('nil parent_engine', service_hash) if service_hash[:parent_engine].nil? || service_hash[:parent_engine] == ''
    return log_error_mesg('No container type path', service_hash) unless service_hash.key?(:container_type)
    return log_error_mesg('nil container type path', service_hash)  if service_hash[:container_type].nil? || service_hash[:container_type] == ''
    return true
  end
  
  def check_sub_service_hash(service_hash)
    return false unless check_service_hash(service_hash)
    return log_error_mesg('No parent service', service_hash) unless service_hash.key?(:parent_service)
    return true
  end
  
  def check_engine_service_hash(service_hash)
      return false unless check_engine_service_query(service_hash)
    return log_error_mesg('No service variables', service_hash) unless service_hash.key?(:variables)
      return true
    end
    
  def check_engine_service_query(service_hash)
       return false unless check_service_hash(service_hash)
     return false unless check_engine_hash(service_hash)  
    return true
     end<commit_msg>handle missing container_type from gi<commit_after>require '/opt/engines/lib/ruby/system/system_config.rb'
require '/opt/engines/lib/ruby/system/system_utils.rb'
require '/opt/engines/lib/ruby/api/system/errors_api.rb'
require '/opt/engines/lib/ruby/containers/managed_container.rb'
require '/opt/engines/lib/ruby/containers/managed_engine.rb'
require '/opt/engines/lib/ruby/containers/managed_service.rb'
require '/opt/engines/lib/ruby/containers/system_service.rb'
require '/opt/engines/lib/ruby/managed_services/system_services/volume_service.rb'
require '/opt/engines/lib/ruby/managed_services/service_definitions/software_service_definition.rb'
require '/opt/engines/lib/ruby/service_manager/service_manager.rb'
require '/opt/engines/lib/ruby/api/public/engines_osapi_result.rb'

class EnginesCore < ErrorsApi
  require '/opt/engines/lib/ruby/system_registry/registry_handler.rb'
  require '/opt/engines/lib/ruby/api/public/build_controller.rb'
  require '/opt/engines/lib/ruby/system/dnshosting.rb'
  require_relative 'containers/container_api.rb'
  require_relative 'containers/service_api.rb'
  require_relative 'docker/docker_api.rb'
  require_relative 'system_api.rb'
  require_relative 'dns_api.rb'
  require_relative 'configurations_api.rb'
  require_relative 'blueprint_api.rb'
  require_relative 'system_preferences.rb'
  require_relative 'memory_statistics.rb'
  def initialize
    Signal.trap('HUP', proc { api_shutdown })
    Signal.trap('TERM', proc { api_shutdown })
    @docker_api = DockerApi.new
    @system_api = SystemApi.new(self)  # will change to to docker_api and not self
    @registry_handler = RegistryHandler.new(@system_api)
    @container_api = ContainerApi.new(@docker_api, @system_api, self)
    @service_api = ServiceApi.new(@docker_api, @system_api, self)
    @registry_handler.start
  end
  
  attr_reader :container_api, :service_api

  def check_hash(service_hash)
    return log_error_mesg('Nil service Hash', service_hash) if service_hash.nil?
    return log_error_mesg('Not a Service Hash', service_hash) unless service_hash.is_a?(Hash)  
    return true
  end
  
  def check_service_hash(service_hash)
    return false unless check_hash(service_hash)
    return log_error_mesg('No publisher name space', service_hash) unless service_hash.key?(:publisher_namespace)
    return log_error_mesg('nil publisher name space', service_hash) if service_hash[:publisher_namespace].nil? || service_hash[:publisher_namespace] == ''
    return log_error_mesg('No type path', service_hash) unless service_hash.key?(:type_path)
    return log_error_mesg('nil type path', service_hash) if service_hash[:type_path].nil? || service_hash[:type_path] == ''
    
    return true
  end
  
  def check_engine_hash(service_hash)
    return false unless check_hash(service_hash)
    # FIXME: Kludge
    # Klugde to avoid gui bugss
    unless service_hash.key?(:parent_engine)
      service_hash[:parent_engine] = service_hash[:engine_name]
    end
    service_hash[:container_type] = "container" unless service_hash.key?(:container_type) 
    # End of Kludge
    return log_error_mesg('No parent engine', service_hash) unless service_hash.key?(:parent_engine)
    return log_error_mesg('nil parent_engine', service_hash) if service_hash[:parent_engine].nil? || service_hash[:parent_engine] == ''
    return log_error_mesg('No container type path', service_hash) unless service_hash.key?(:container_type)
    return log_error_mesg('nil container type path', service_hash)  if service_hash[:container_type].nil? || service_hash[:container_type] == ''
    return true
  end
  
  def check_sub_service_hash(service_hash)
    return false unless check_service_hash(service_hash)
    return log_error_mesg('No parent service', service_hash) unless service_hash.key?(:parent_service)
    return true
  end
  
  def check_engine_service_hash(service_hash)
      return false unless check_engine_service_query(service_hash)
    return log_error_mesg('No service variables', service_hash) unless service_hash.key?(:variables)
      return true
    end
    
  def check_engine_service_query(service_hash)
       return false unless check_service_hash(service_hash)
     return false unless check_engine_hash(service_hash)  
    return true
     end
{'fraction_non_alphanumeric': 0.09917847362781283, 'fraction_numerical': 0.0, 'mean_word_length': 5.278026905829597, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4607791', 'n_tokens_mistral': 2704, 'n_tokens_neox': 2654, 'n_words': 497}