# Configuration for {{ env_name }} environment
# Generated by MMP get-config

environment:
  name: {{ env_name }}

{% if use_mlflow %}
# MLflow 설정
mlflow:
  tracking_uri: {{ mlflow_tracking_uri }}
  experiment_name: {{ mlflow_experiment_name }}
{% endif %}

# 데이터 소스 설정
data_source:
  name: {{ data_source }}
{% if data_source == "PostgreSQL" %}
  adapter_type: sql
  config:
    connection_uri: "postgresql://${DB_USER:postgres}:${DB_PASSWORD:}@{{ db_host }}:{{ db_port }}/{{ db_name }}"
    query_timeout: 300
{% elif data_source == "BigQuery" %}
  adapter_type: sql
  config:
    connection_uri: bigquery://{{ gcp_project_id }}
    project_id: {{ gcp_project_id }}
    credentials_path: "${GOOGLE_APPLICATION_CREDENTIALS}"
    location: {{ bq_location }}
    use_pandas_gbq: true
{% elif data_source == "Local Files" %}
  adapter_type: storage
  config:
    base_path: {{ local_data_path }}
    storage_options: {}
{% elif data_source == "S3" %}
  adapter_type: storage
  config:
    base_path: s3://{{ s3_data_bucket }}/{{ s3_data_prefix }}
    storage_options:
      aws_access_key_id: "${AWS_ACCESS_KEY_ID}"
      aws_secret_access_key: "${AWS_SECRET_ACCESS_KEY}"
      region_name: {{ aws_region }}
{% elif data_source == "GCS" %}
  adapter_type: storage
  config:
    base_path: gs://{{ gcs_data_bucket }}/{{ gcs_data_prefix }}
    storage_options:
      project: {{ gcp_project_id }}
      token: "${GOOGLE_APPLICATION_CREDENTIALS}"
{% endif %}

# Feature Store 설정
{% if use_feast %}
feature_store:
  provider: feast
  feast_config:
    project: {{ feast_project }}
    registry: {{ feast_registry_path }}
    online_store:
{% if feast_online_store == "Redis" %}
      type: redis
      connection_string: "{{ redis_host }}:{{ redis_port }}"
      password: "${REDIS_PASSWORD:}"
{% elif feast_online_store == "DynamoDB" %}
      type: dynamodb
      region: {{ dynamodb_region }}
      table_name: {{ dynamodb_table }}
{% else %}
      type: sqlite
      path: {{ feast_online_store_path }}
{% endif %}
    offline_store:
{% if data_source == "BigQuery" %}
      type: bigquery
      project_id: {{ gcp_project_id }}
      dataset_id: {{ bq_dataset_id|default('mmp_dataset') }}
{% elif data_source in ["S3", "GCS", "Local Files", "PostgreSQL"] %}
      type: file
      path: {{ feast_offline_path }}
{% endif %}
    entity_key_serialization_version: 2
{% else %}
feature_store:
  provider: none
{% endif %}

# 서빙 설정
serving:
  enabled: true
  model_stage: "None"
  request_timeout_seconds: 30
  metrics_enabled: true

# 로깅 설정
logging:
  base_path: {{ log_path }}
  level: {{ log_level }}
  retention_days: {{ log_retention_days }}
  upload_to_mlflow: true

# 배치 추론 결과 저장 설정
output:
  inference:
    name: InferenceOutput
{% if not inference_output_enabled %}
    enabled: false
{% else %}
    enabled: true
{% if inference_output_source == "Local Files" %}
    adapter_type: storage
    config:
      base_path: {{ infer_local_path }}
{% elif inference_output_source == "S3" %}
    adapter_type: storage
    config:
      base_path: s3://{{ infer_s3_bucket }}/{{ infer_s3_prefix }}
{% elif inference_output_source == "GCS" %}
    adapter_type: storage
    config:
      base_path: gs://{{ infer_gcs_bucket }}/{{ infer_gcs_prefix }}
{% elif inference_output_source == "PostgreSQL" %}
    adapter_type: sql
    config:
      connection_uri: "postgresql://${DB_USER:postgres}:${DB_PASSWORD:}@{{ db_host }}:{{ db_port }}/{{ db_name }}"
      table: {{ infer_pg_table }}
{% elif inference_output_source == "BigQuery" %}
    adapter_type: sql
    config:
      connection_uri: bigquery://{{ gcp_project_id }}/{{ infer_bq_dataset }}
      project_id: {{ gcp_project_id }}
      dataset_id: {{ infer_bq_dataset }}
      table: {{ infer_bq_table }}
      location: {{ bq_location }}
      use_pandas_gbq: true
{% endif %}
{% endif %}
