Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for an API to analyze and anonymize files #9

Merged
merged 8 commits into from
Jun 5, 2024

Conversation

akshaykarle
Copy link
Member

No description provided.

try:
file = request.files['file']
language = request.form['language']
if file.filename == '':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Need to include validation for checking only the uploaded file is csv or not?
  2. Also need to limit size for upload

Comment on lines +59 to +68
analyzer_results_list = {}
for a in analyzer_results:
recognizer_results = []
for r in a.recognizer_results:
recognizer_results.append([o.to_dict() for o in r])
analyzer_results_list[a.key] = {
"value": a.value,
"recognizer_results": recognizer_results
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be moved inside service kind of file.

f"A fatal error occurred during execution of "
f"AnalyzerEngine.analyze(). {e}"
)
return jsonify(error=e.args[0]), 500
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will status code be always 500

Comment on lines +83 to +93
for key, value in analyzer_results.items():
recognizer_results = []
for results_for_each_entry in value["recognizer_results"]:
each_entry_recognizer_results = []
for r in results_for_each_entry:
each_entry_recognizer_results.append(
RecognizerResult(r["entity_type"],
r["start"],
r["end"],
r["score"]))
recognizer_results.append(each_entry_recognizer_results)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic can be moved into respective domain file

self.logger.setLevel(os.environ.get("LOG_LEVEL", self.logger.level))
self.app = Flask(__name__)
self.logger.info("Starting analyzer engine")
nlp_engine = FlairNLPEngine(NLP_ENGINE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shld also think about how model loading can be done efficiently. For every request it shld not download it.

@l-r-sowmya l-r-sowmya merged commit 17f7939 into main Jun 5, 2024
1 check passed
@akshaykarle akshaykarle deleted the api_anonymize branch June 5, 2024 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants