o 'q[e@sddlZddlZddlmZmZddlmZmZmZddlm Z m Z m Z m Z m Z mZddlmZddlmZmZmZmZmZdadadeded ed ed ed ed efddZdS)N)datetimetimezone) styled_errorstyled_messagestyled_warning)APIEVAL_REQUESTS_PATHH4_TOKEN QUEUE_REPORATE_LIMIT_PERIODRATE_LIMIT_QUOTA)DO_NOT_SUBMIT_MODELS)already_submitted_modelscheck_model_cardget_model_sizeis_model_on_hubuser_submission_permissionmodel base_modelrevision precisionprivate weight_type model_typec Cststt\aa|dd}ttj d}|dus |dkr$t dSt |tt t \}} |s3t | S|tvs;|tvr?tdS|dkrEd}|dvr^t||t\} } } | s^t d |d | S|d ksvt||\} } } | svt d |d | Sz tj||d }Wn tyt dYSwt||d}z|jd}Wn tyt dYSwt|\}} |st | Std||||||d|||j||d }d}|}d|vr|dd}|dd}|d|d|tvrtdStdtd|}tj|dd|d|d|d|d|d }t|d}|t|Wdn 1s*wYtdtj ||d dt!d!d"|d#d$t"|t#d%S)&N rz%Y-%m-%dT%H:%M:%SZzPlease select a model type.zRModel authors have requested that their model be not submitted on the leaderboard.main)DeltaAdapterz Base model "z" rzModel ")repo_idrzACould not get your model information. Please fill it up properly.) model_inforlicensez&Please select a license for your modelzAdding new evalPENDING) rrrrrrstatussubmitted_timerlikesparamsr!/_z&This model has been already submitted.zCreating eval fileT)exist_okZ_eval_request_z.jsonwzUploading eval filez eval-queue/datasetzAdd z to eval queue)path_or_fileobj path_in_repor repo_typecommit_messagezYour request has been submitted to the evaluation queue! Please wait for up to an hour for the model to show in the PENDING list.)$REQUESTED_MODELSrrUSERS_TO_SUBMISSION_DATESsplitrnowrutcstrftimerrr r r rrr rr ExceptionrcardDatarprintr%osmakedirsopenwritejsondumps upload_filer remover)rrrrrrr current_timeZuser_can_submit error_msgZbase_model_on_huberrorr)Z model_on_hubr model_sizer!Z modelcard_OKZ eval_entryZ user_nameZ model_pathZOUT_DIRZout_pathfrGM/Users/pasquale/workspace/hallucinations-leaderboard/src/submission/submit.py add_new_evals       "    rI)r>r:rrsrc.display.formattingrrrsrc.envsrrr r r r src.leaderboard.filter_modelsr src.submission.check_validityrrrrrr1r2strboolrIrGrGrGrHs0