<jupyter_start><jupyter_text>Load Testing<jupyter_code>input_json_single = \
"""[
   {
       "title": "applicability of magnetic resonance imaging of the knee in forensic age estimation",
       "doc_type": "Journal",
       "journal": "american journal of forensic medicine and pathology"
       
   }
]"""

%%time
F.get_tags(input_json_multi, 1)[1]
test_payload = [input_json_single]*8000
%%time
final_output = []
with mp.Pool(processes=8) as p:
    results = [p.apply(F.get_tags, args=(x, i)) for i,x in enumerate(test_payload)]
%%time
final_output = []
with mp.Pool(processes=8) as p:
    results = [p.apply_async(F.get_tags, args=(x, i)) for i,x in enumerate(test_payload)]
    output = [r.get(timeout=300) for r in results]

final_output += output

# print("Done with first")
    
# with mp.Pool(processes=8) as p:
#     results = [p.apply_async(F.get_tags, args=(x, i)) for i,x in enumerate(test_payload)]
#     output = [r.get(timeout=300) for r in results]

# final_output += output
# output.sort()
len(final_output)<jupyter_output><empty_output><jupyter_text>Testing the enhanced model<jupyter_code>import os
import io
import boto3
import json
ENDPOINT_NAME = 'mag-imitator-endpoint'
runtime= boto3.client('runtime.sagemaker')
response = runtime.invoke_endpoint(EndpointName=ENDPOINT_NAME,
                                       ContentType='application/json',
                                       Body=input_json_multi)
print(response)
result = json.loads(response['Body'].read().decode())
print(result)<jupyter_output>[{'tags': ['medicine', 'magnetic resonance imaging', 'nuclear medicine', 'forensic anthropology', 'radiology'], 'scores': [0.5264689922332764, 0.4692302346229553, 0.39589232206344604, 0.3734455108642578, 0.3555443286895752], 'tag_ids': [71924100, 143409427, 2989005, 176979668, 126838900]}, {'tags': ['computer science', 'counterfactual thinking', 'task', 'reinforcement learning', 'artificial intelligence'], 'scores': [0.6955634951591492, 0.4845692217350006, 0.39626574516296387, 0.38736552000045776, 0.3649846613407135], 'tag_ids': [41008148, 108650721, 2780451532, 97541855, 154945302]}, {'tags': ['materials science', 'silicone', 'silicone rubber', 'silane', 'elastomer', 'siloxane', 'composite material', 'biofouling', 'chemical engineering', 'coating', 'polydimethylsiloxane', 'surface modification', 'contact angle', 'silane coupling', 'filler', 'silanes', 'polymer'], 'scores': [0.6924267411231995, 0.6599656343460083, 0.584079384803772, 0.5673587322235107, 0.5134502649307251, 0.46404856443[...]
{'fraction_non_alphanumeric': 0.14736012608353033, 'fraction_numerical': 0.14657210401891252, 'mean_word_length': 5.363408521303258, 'pattern_counts': {'":': 3, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '23924', 'license': 'MIT', 'n_tokens_mistral': 1131, 'n_tokens_neox': 872, 'n_words': 188, 'path': 'DEPLOY/testing_API.ipynb', 'repo_name': 'jpbarrett13/MAG-model-code', 'size': '2538'}