Dave67350 commited on
Commit
d054b5e
·
verified ·
1 Parent(s): 74824f7

Update tools/data_governance_record.py

Browse files
Files changed (1) hide show
  1. tools/data_governance_record.py +12 -11
tools/data_governance_record.py CHANGED
@@ -6,6 +6,8 @@ from fpdf import FPDF
6
  from langdetect import detect
7
  import gradio as gr
8
 
 
 
9
  # === PDF Export Function ===
10
  def export_text_to_pdf(text, metadata=None, output_path=None, language="en"):
11
  if output_path is None:
@@ -23,7 +25,7 @@ def export_text_to_pdf(text, metadata=None, output_path=None, language="en"):
23
  pdf.cell(0, 15, title, ln=True, align='C')
24
  pdf.ln(10)
25
 
26
- # Metadata
27
  if metadata:
28
  pdf.set_font("Arial", '', 12)
29
  pdf.set_text_color(90, 90, 90)
@@ -63,11 +65,8 @@ def export_text_to_pdf(text, metadata=None, output_path=None, language="en"):
63
  return output_path
64
 
65
 
66
- # === Questions ===
67
- QUESTIONS = [
68
- ("organization", "What is the name of your organization?"),
69
- ("completed_by", "What is your full name?"),
70
- ("role", "What is your role in the organization?"),
71
  ("dataset_description", "Please describe the dataset(s) used."),
72
  ("data_sources", "What are the sources of the data?"),
73
  ("data_collection_method", "How was the data collected?"),
@@ -80,6 +79,8 @@ QUESTIONS = [
80
  ("access_control", "Who has access to the data and under what conditions?")
81
  ]
82
 
 
 
83
  def get_questions():
84
  return QUESTIONS
85
 
@@ -100,14 +101,14 @@ def run_tool():
100
  state["step"] += 1
101
  return next_q, state, None
102
 
103
- # Build content and metadata
104
- content = "\n".join([f"- **{label}**: {answers.get(key, '')}" for key, label in QUESTIONS[3:]])
105
  detected_lang = detect(content)
106
 
 
107
  metadata = {
108
- "organization": answers.get("organization", "N/A"),
109
- "completed_by": answers.get("completed_by", "N/A"),
110
- "role": answers.get("role", "N/A"),
111
  "timestamp": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
112
  }
113
 
 
6
  from langdetect import detect
7
  import gradio as gr
8
 
9
+ from tools.common import prepend_metadata_questions # ✅ Import helper
10
+
11
  # === PDF Export Function ===
12
  def export_text_to_pdf(text, metadata=None, output_path=None, language="en"):
13
  if output_path is None:
 
25
  pdf.cell(0, 15, title, ln=True, align='C')
26
  pdf.ln(10)
27
 
28
+ # Metadata block
29
  if metadata:
30
  pdf.set_font("Arial", '', 12)
31
  pdf.set_text_color(90, 90, 90)
 
65
  return output_path
66
 
67
 
68
+ # === Core Questions ===
69
+ BASE_QUESTIONS = [
 
 
 
70
  ("dataset_description", "Please describe the dataset(s) used."),
71
  ("data_sources", "What are the sources of the data?"),
72
  ("data_collection_method", "How was the data collected?"),
 
79
  ("access_control", "Who has access to the data and under what conditions?")
80
  ]
81
 
82
+ QUESTIONS = prepend_metadata_questions(BASE_QUESTIONS) # ✅ Prepend metadata
83
+
84
  def get_questions():
85
  return QUESTIONS
86
 
 
101
  state["step"] += 1
102
  return next_q, state, None
103
 
104
+ content = "\n".join([f"- **{label}**: {answers.get(key, '')}" for key, label in QUESTIONS])
 
105
  detected_lang = detect(content)
106
 
107
+ # ✅ Extract metadata from prepended fields
108
  metadata = {
109
+ "organization": answers.get("organization_name", "N/A"),
110
+ "completed_by": answers.get("user_name", "N/A"),
111
+ "role": answers.get("user_role", "N/A"),
112
  "timestamp": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
113
  }
114