Skip to content

Commit

Permalink
Minor fixes for registration
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMarzahl committed Jan 18, 2022
1 parent b3b811c commit c993547
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,7 @@ examples/temp*
examples/Results*
examples/*.py

locustfile_*.py

.vscode/settings.json
.vscode/launch.json
2 changes: 1 addition & 1 deletion exact_sync/locust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ pip install locust
Please edit the [locustfile.py](locustfile.py) according to our test case and add authorization.

```bash
locust --host=http://localhost:1337 --locustfile locustfile.py
locust --web-port 8090 --locustfile locustfile.py
```
34 changes: 19 additions & 15 deletions exact_sync/locust/locustfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,31 @@
import random
import json
from locust import HttpUser, between, task
#from locust_plugins import run_single_user

image_ids = [329, 331, 324]

username = 'exact'
password = 'exact'

from locust_plugins import run_single_user

class ApiUser(HttpUser):
#wait_time = between(5, 15)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

self.username = '*****'
self.password = '****'
self.max_level = 10
self.image_ids = [335]

def on_start(self):
# login user
response = self.client.get('/accounts/login/')
self.csrftoken = response.cookies['csrftoken']
self.client.post('/accounts/login/',
{'username': username, 'password': password},
headers={'X-CSRFToken': self.csrftoken})

headers={'X-CSRFToken': self.csrftoken, "referer": self.host} if "https" in self.host else {'X-CSRFToken': self.csrftoken}
result = self.client.post('/accounts/login/',
{'username': self.username, 'password': self.password},
headers=headers)

# select random image
self.image_id = random.choice(image_ids)
self.image_id = random.choice(self.image_ids)

# get image information
response = self.client.get(f'/api/v1/images/images/{self.image_id}/slide_information/', headers={'X-CSRFToken': self.csrftoken})
Expand All @@ -36,13 +40,13 @@ def index(self):

@task
def get_tile(self):
level = random.randint(0, len(self.slide_information["level_tiles"]) - 1)
level = random.randint(0, min(self.max_level, len(self.slide_information["level_tiles"]) - 1))
num_x_tiles, num_y_tiles = self.slide_information["level_tiles"][level]
x_tile = random.randint(0, num_x_tiles -1)
y_tile = random.randint(0, num_y_tiles -1)
result = self.client.get(f"/images/image/{self.image_id}/1/1/tile_files/{level}/{x_tile}_{y_tile}.jpeg",
headers={'X-CSRFToken': self.csrftoken})

#if __name__ == "__main__":
# ApiUser.host = "http://127.0.0.1:1337"
# run_single_user(ApiUser, include_time=True, include_length=True)
if __name__ == "__main__":
ApiUser.host = "http://127.0.0.1:8000" #"https://exact.cs.fau.de"
run_single_user(ApiUser, include_time=True, include_length=True)
16 changes: 8 additions & 8 deletions exact_sync/v1/api/image_registration_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ def create_image_registration_with_http_info(self, **kwargs): # noqa: E501
if 'file' in params:
local_var_files['file'] = params['file'] # noqa: E501

body_params = None
if 'body' in params:
body_params['body'] = params['body']
body_params = {}
#if 'body' in params:
# body_params['body'] = params['body']
if 'source_image' in params:
body_params['source_image'] = params['source_image']
if 'target_image' in params:
Expand Down Expand Up @@ -480,13 +480,13 @@ def partial_update_image_registration_with_http_info(self, id, **kwargs): # noq
local_var_files['file'] = params['file'] # noqa: E501


body_params = None
body_params = {}
if 'registration_error' in params:
body_params = params['registration_error']
body_params['registration_error'] = params['registration_error']
if 'runtime' in params:
body_params = params['runtime']
body_params['runtime'] = params['runtime']
if 'transformation_matrix' in params:
body_params = params['transformation_matrix']
body_params['transformation_matrix'] = params['transformation_matrix']

# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
Expand Down Expand Up @@ -715,7 +715,7 @@ def update_image_registration_with_http_info(self, id, **kwargs): # noqa: E501
form_params = []
local_var_files = {}

body_params = None
body_params = {}
if 'body' in params:
body_params = params['body']

Expand Down
5 changes: 3 additions & 2 deletions exact_sync/v1/api/images_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ def partial_update_image_with_http_info(self, id, **kwargs): # noqa: E501
returns the request thread.
"""

all_params = ['id', 'mpp', 'objective_power', 'image_set', 'image_type'] # noqa: E501
all_params = ['id', 'mpp', 'objective_power', 'image_set', 'image_type', 'name'] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
Expand Down Expand Up @@ -713,7 +713,8 @@ def partial_update_image_with_http_info(self, id, **kwargs): # noqa: E501
body_params['image_set'] = params['image_set']
if 'image_type' in params:
body_params['image_type'] = params['image_type']

if 'name' in params:
body_params['name'] = params['name'] # noqa: E501

# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
Expand Down
3 changes: 0 additions & 3 deletions exact_sync/v1/models/screening_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ def user(self, user):
:param user: The user of this ScreeningMode. # noqa: E501
:type: int
"""
if user is None:
raise ValueError("Invalid value for `user`, must not be `None`") # noqa: E501

self._user = user

@property
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ requests
tqdm
requests-toolbelt
pillow
locust
locust==1.1.0
#locust-plugins==1.1.0
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="EXCAT-Sync",
version="0.0.28",
version="0.0.32",
author="Christian Marzahl",
author_email="[email protected]",
description="A package to download images and annotations from the EXACT Server https://github.com/ChristianMarzahl/Exact",
Expand All @@ -17,7 +17,8 @@
'requests',
'tqdm',
'requests-toolbelt',
'pillow'
'pillow',
"locust==1.1.0"
],
classifiers=[
"Programming Language :: Python :: 3",
Expand Down

0 comments on commit c993547

Please sign in to comment.