1
- # client.py
1
+ """
2
+ Client module for DataFog.
3
+
4
+ Provides CLI commands for scanning images and text using DataFog's OCR and PII detection capabilities.
5
+ """
2
6
3
7
import asyncio
4
8
import logging
@@ -25,7 +29,18 @@ def scan_image(
25
29
),
26
30
operations : str = typer .Option ("annotate_pii" , help = "Operation to perform" ),
27
31
):
28
- """Extract text from images."""
32
+ """
33
+ Scan images for text and PII.
34
+
35
+ Extracts text from images using OCR, then detects PII entities.
36
+ Handles both remote URLs and local file paths.
37
+
38
+ Args:
39
+ image_urls: List of image URLs or file paths
40
+ operations: Pipeline operations to run (default: annotate_pii)
41
+
42
+ Prints results or exits with error on failure.
43
+ """
29
44
if not image_urls :
30
45
typer .echo ("No image URLs or file paths provided. Please provide at least one." )
31
46
raise typer .Exit (code = 1 )
@@ -48,7 +63,17 @@ def scan_text(
48
63
),
49
64
operations : str = typer .Option ("annotate_pii" , help = "Operation to perform" ),
50
65
):
51
- """Annotate texts to detect PII entities."""
66
+ """
67
+ Scan texts for PII.
68
+
69
+ Detects PII entities in a list of input texts.
70
+
71
+ Args:
72
+ str_list: List of texts to analyze
73
+ operations: Pipeline operations to run (default: annotate_pii)
74
+
75
+ Prints results or exits with error on failure.
76
+ """
52
77
if not str_list :
53
78
typer .echo ("No texts provided." )
54
79
raise typer .Exit (code = 1 )
@@ -66,19 +91,34 @@ def scan_text(
66
91
67
92
@app .command ()
68
93
def health ():
69
- """Check DataFog service health."""
94
+ """
95
+ Check DataFog service health.
96
+
97
+ Prints a message indicating that DataFog is running.
98
+ """
70
99
typer .echo ("DataFog is running." )
71
100
72
101
73
102
@app .command ()
74
103
def show_config ():
75
- """Show current configuration."""
104
+ """
105
+ Show current configuration.
106
+
107
+ Prints the current DataFog configuration.
108
+ """
76
109
typer .echo (get_config ())
77
110
78
111
79
112
@app .command ()
80
113
def download_model (model_name : str = typer .Argument (..., help = "Model to download" )):
81
- """Download a model."""
114
+ """
115
+ Download a spaCy model.
116
+
117
+ Args:
118
+ model_name: Name of the model to download.
119
+
120
+ Prints a confirmation message after downloading.
121
+ """
82
122
SpacyAnnotator .download_model (model_name )
83
123
typer .echo (f"Model { model_name } downloaded." )
84
124
@@ -87,21 +127,36 @@ def download_model(model_name: str = typer.Argument(..., help="Model to download
87
127
def show_spacy_model_directory (
88
128
model_name : str = typer .Argument (..., help = "Model to check" )
89
129
):
90
- """Show model path."""
130
+ """
131
+ Show the directory path for a spaCy model.
132
+
133
+ Args:
134
+ model_name: Name of the model to check.
135
+
136
+ Prints the directory path of the specified model.
137
+ """
91
138
annotator = SpacyAnnotator (model_name )
92
139
typer .echo (annotator .show_model_path ())
93
140
94
141
95
142
@app .command ()
96
143
def list_spacy_models ():
97
- """List available models."""
144
+ """
145
+ List available spaCy models.
146
+
147
+ Prints a list of all available spaCy models.
148
+ """
98
149
annotator = SpacyAnnotator ()
99
150
typer .echo (annotator .list_models ())
100
151
101
152
102
153
@app .command ()
103
154
def list_entities ():
104
- """List available entities."""
155
+ """
156
+ List available entities.
157
+
158
+ Prints a list of all available entities that can be recognized.
159
+ """
105
160
annotator = SpacyAnnotator ()
106
161
typer .echo (annotator .list_entities ())
107
162
0 commit comments