-
Notifications
You must be signed in to change notification settings - Fork 8
Fix dependencies and migrate benchmark auth #490
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
Changes from 1 commit
03ccc8a
1311b6a
1812507
e2bed7d
7e71c36
0114487
83bd3ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ | |
| import time | ||
| import os | ||
|
|
||
| from clkhash import rest_client | ||
| from clkhash.rest_client import RestClient | ||
| from pprint import pprint | ||
| from traceback import format_exc | ||
|
|
||
|
|
@@ -41,6 +41,8 @@ | |
| logger = logging | ||
| logger.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO) | ||
|
|
||
| rest_client = RestClient(os.getenv('SERVER')) | ||
|
|
||
|
|
||
| def load_experiments(filepath): | ||
|
|
||
|
|
@@ -232,11 +234,11 @@ def compose_result(status, tt, experiment, sizes, threshold): | |
| return result | ||
|
|
||
|
|
||
| def delete_resources(config, credentials, run): | ||
| def delete_resources(credentials, run): | ||
| try: | ||
| if run is not None and 'run_id' in run: | ||
| rest_client.run_delete(config['server'], credentials['project_id'], run['run_id'], credentials['result_token']) | ||
| rest_client.project_delete(config['server'], credentials['project_id'], credentials['result_token']) | ||
| rest_client.run_delete(credentials['project_id'], run['run_id'], credentials['result_token']) | ||
| rest_client.project_delete(credentials['project_id'], credentials['result_token']) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it true that currently there is only server in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, there is lots of stuff in |
||
| except Exception as e: | ||
| logger.warning('Error while deleting resources... {}'.format(e)) | ||
|
|
||
|
|
@@ -299,8 +301,7 @@ def run_experiments(config): | |
| """ | ||
| Run all the experiments specified in the configuration. | ||
| """ | ||
| server = config['server'] | ||
| rest_client.server_get_status(server) | ||
| rest_client.server_get_status() | ||
|
|
||
| results = {'experiments': []} | ||
| for experiment in config['experiments']: | ||
|
|
@@ -314,39 +315,39 @@ def run_experiments(config): | |
| logger.info('running experiment: {}'.format(current_experiment)) | ||
| if repetition != 1: | ||
| logger.info('\trepetition {} out of {}'.format(rep + 1, repetition)) | ||
| result = run_single_experiment(server, config, threshold, sizes, current_experiment) | ||
| result = run_single_experiment(config, threshold, sizes, current_experiment) | ||
| results['experiments'].append(result) | ||
|
|
||
| return results | ||
|
|
||
|
|
||
| def run_single_experiment(server, config, threshold, sizes, experiment): | ||
| def run_single_experiment(config, threshold, sizes, experiment): | ||
| result = {} | ||
| credentials = {} | ||
| run = {} | ||
| logger.info("Starting time: {}".format(time.asctime())) | ||
| nb_parties = len(sizes) | ||
| try: | ||
| credentials = rest_client.project_create(server, config['schema'], 'groups', | ||
| credentials = rest_client.project_create(config['schema'], 'groups', | ||
| "benchy_{}".format(experiment), parties=nb_parties) | ||
| # upload clks | ||
| upload_binary_clks(config, sizes, credentials) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ideally, that should be done by the rest_client as well.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree => data61/anonlink-client#23 |
||
| # create run | ||
| project_id = credentials['project_id'] | ||
| result['project_id'] = project_id | ||
| run = rest_client.run_create(server, project_id, credentials['result_token'], | ||
| run = rest_client.run_create(project_id, credentials['result_token'], | ||
| threshold, | ||
| "{}_{}".format(experiment, threshold)) | ||
| # wait for result | ||
| run_id = run['run_id'] | ||
| result['run_id'] = run_id | ||
| logger.info(f'waiting for run {run_id} from the project {project_id} to finish') | ||
| status = rest_client.wait_for_run(server, project_id, run_id, | ||
| credentials['result_token'], timeout=config['timeout']) | ||
| status = rest_client.wait_for_run(project_id, run_id, | ||
| credentials['result_token'], timeout=config['timeout'], update_period=5) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will that lead to a new line in the logs every 5 seconds? what about those huge benchmarks? How big's the log file going to be?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not on the benchmark container side - we just wait until the whole thing is done (perhaps we should be outputting progress but that is another question). On the server side we would log the request in both nginx and the flask app. |
||
| if status['state'] != 'completed': | ||
| raise RuntimeError('run did not finish!\n{}'.format(status)) | ||
| logger.info('experiment successful. Evaluating results now...') | ||
| groups = rest_client.run_get_result_text(server, project_id, run_id, credentials['result_token']) | ||
| groups = rest_client.run_get_result_text(project_id, run_id, credentials['result_token']) | ||
| groups = json.loads(groups)['groups'] | ||
| truth_groups = load_truth(config, sizes) | ||
| tt = score_accuracy(groups, truth_groups, nb_parties) | ||
|
|
@@ -357,7 +358,7 @@ def run_single_experiment(server, config, threshold, sizes, experiment): | |
| result.update({'name': experiment, 'status': 'ERROR', 'description': e_trace}) | ||
| finally: | ||
| logger.info('cleaning up...') | ||
| delete_resources(config, credentials, run) | ||
| delete_resources(credentials, run) | ||
|
|
||
| logger.info("Ending time: {}".format(time.asctime())) | ||
| return result | ||
|
|
@@ -383,7 +384,7 @@ def push_to_object_store(config): | |
|
|
||
| def main(): | ||
| config = read_config() | ||
| server_status = rest_client.server_get_status(config['server']) | ||
| server_status = rest_client.server_get_status() | ||
| version = requests.get(config['server'] + "/api/v1/version").json() | ||
| logger.info(server_status) | ||
| download_data(config) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be great to see what key-value pairs might be in
configin doc