Skip to content

Commit

Permalink
Chagned resolving methods to use refactored core methods
Browse files Browse the repository at this point in the history
  • Loading branch information
shehadak committed Nov 11, 2023
1 parent 2404df1 commit f0098de
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions brainscore_language/submission/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from brainscore_core import Score, Benchmark
from brainscore_core.submission import RunScoringEndpoint, DomainPlugins
from brainscore_core.submission.endpoints import make_argparser, retrieve_models_and_benchmarks, get_user_id, \
from brainscore_core.submission.endpoints import make_argparser, retrieve_models_and_benchmarks, resolve_models, resolve_benchmarks, get_user_id, \
send_email_to_submitter as send_email_to_submitter_core
from brainscore_language import load_model, load_benchmark, score
from brainscore_language.submission import config
Expand All @@ -24,15 +24,24 @@ def score(self, model_identifier: str, benchmark_identifier: str) -> Score:


def run_scoring(args_dict: Dict[str, Union[str, List]]):
benchmarks, models = retrieve_models_and_benchmarks(args_dict)
model_ids, benchmark_ids = resolve_models_benchmarks(args_dict)

for benchmark in benchmarks:
for model in models:
for benchmark in benchmark_ids:
for model in model_ids:
run_scoring_endpoint(domain="language", jenkins_id=args_dict["jenkins_id"],
model_identifier=model, benchmark_identifier=benchmark,
user_id=args_dict["user_id"], model_type="artificialsubject",
public=args_dict["public"], competition=args_dict["competition"])


def resolve_models_benchmarks(args_dict: Dict[str, Union[str, List]]):
benchmarks, models = retrieve_models_and_benchmarks(args_dict)

model_ids = resolve_models(models)
benchmark_ids = resolve_benchmarks(benchmarks)
print("BS_NEW_MODELS=" + " ".join(model_ids))
print("BS_NEW_BENCHMARKS=" + " ".join(benchmark_ids))
return model_ids, benchmark_ids

def send_email_to_submitter(uid: int, domain: str, pr_number: str,
mail_username: str, mail_password: str):
send_email_to_submitter_core(uid=uid, domain=domain, pr_number=pr_number,
Expand All @@ -44,7 +53,7 @@ def send_email_to_submitter(uid: int, domain: str, pr_number: str,
parser = make_argparser()
parser.add_argument('--fn', type=str, nargs='?', default='run_scoring',
choices=['run_scoring', 'retrieve_models_and_benchmarks'],
help='The endpoint method to run. `run_scoring` to score `new_models` on `new_benchmarks`, or `get_models_and_benchmarks` to respond with a list of models and benchmarks to score.')
help='The endpoint method to run. `run_scoring` to score `new_models` on `new_benchmarks`, or `retrieve_models_and_benchmarks` to respond with a list of models and benchmarks to score.')

args, remaining_args = parser.parse_known_args()
args_dict = vars(args)
Expand All @@ -56,8 +65,6 @@ def send_email_to_submitter(uid: int, domain: str, pr_number: str,
if args.fn == 'run_scoring':
run_scoring(args_dict)
elif args.fn == 'retrieve_models_and_benchmarks':
benchmark_ids, model_ids = retrieve_models_and_benchmarks(args_dict)
print("BS_NEW_MODELS=" + " ".join(model_ids))
print("BS_NEW_BENCHMARKS=" + " ".join(benchmark_ids))
retrieve_models_and_benchmarks(args_dict)
else:
raise ValueError(f'Invalid method: {args.fn}')

0 comments on commit f0098de

Please sign in to comment.