Commit b395985e authored by ashivani's avatar ashivani

added pipeline

parent bbc51524
Pipeline #4081 failed with stages
in 1 minute and 3 seconds
stages:
- test-baseline
- submit-baseline
- rails-update
.aicrowd-setup: &aicrowd-setup
image: python:3.8
before_script:
- git clone https://github.com/AIcrowd/aicrowd-cli.git && cd aicrowd-cli
- pip install -r requirements.txt
- python setup.py develop
- cd ..
- aicrowd evaluations login -e "${SUPER_USER_EMAIL}" -p "${SUPER_USER_PASSWORD}"
test-baseline:
stage: test-baseline
image: python:3.8
before_script:
- apt install curl
- curl -o /usr/local/bin/jq http://stedolan.github.io/jq/download/linux64/jq && chmod +x /usr/local/bin/jq
- pip install yq
- pip install jupyter
script:
- export BASELINE=`yq -r .official_baseline aicrowd.yaml | awk -F. '{print $1}'`
- jupyter nbconvert --to python baselines/${BASELINE}.ipynb
- ipython baselines/${BASELINE}.py
artifacts:
paths:
- submission.csv
only:
changes:
- baselines/*
submit-baseline:
stage: submit-baseline
<<: *aicrowd-setup
script:
- apt install curl
- curl -o /usr/local/bin/jq http://stedolan.github.io/jq/download/linux64/jq && chmod +x /usr/local/bin/jq
- pip install yq
- export CHALLENGE_NAME=`yq -r .challenge_name aicrowd.yaml`
- export EVALUATIONS_API_TOKEN=`yq -r .aicrowd_evaluations_token ~/.aicrowd/config.yaml`
- export GRADER_ID=`curl -k -X GET "https://evaluations-api.internal.k8s.aicrowd.com/v1/graders/?name=${CHALLENGE_NAME}"
-H "accept:application/json"
-H "AUTHORIZATION:${EVALUATIONS_API_TOKEN}" | jq '.[length-1].id'`
- aicrowd evaluations submission create --file ./submission.csv -g ${GRADER_ID} --wait
only:
changes:
- baselines/*
rails-update:
stage: rails-update
image: python:3.8-slim
before_script:
- pip install pyyaml requests markdown
script:
- python utils.py
only:
changes:
- README.md
---
challenge_name: aicrowd_WINEQ_challenge
challenge_name: wineq
evaluation_repo: git@gitlab.aicrowd.com:aicrowd/practice-challenges/aicrowd_WINEQ_challenge_evaluator.git
data_url: https://s3.wasabisys.com/aicrowd-practice-challenges/public/wineq/v0.1/test_ground_truth.csv
official_baseline: WINEQ_baseline.ipynb
......
......@@ -546,7 +546,7 @@
"outputs": [],
"source": [
"submission = pd.DataFrame(submission)\n",
"submission.to_csv('/tmp/submission.csv',header=['quality'],index=False)"
"submission.to_csv('submission.csv',header=['quality'],index=False)"
]
},
{
......@@ -565,12 +565,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"only in Colab\n"
]
}
],
"source": [
"from google.colab import files\n",
"files.download('/tmp/submission.csv') "
"try:\n",
" from google.colab import files\n",
" files.download('submission.csv') \n",
"except:\n",
" print(\"only in Colab\")"
]
},
{
......@@ -604,7 +615,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.8.2"
}
},
"nbformat": 4,
......
import requests
import html
import markdown
import yaml
import os
class Utils():
def __init__(self):
self.base_url = "https://www.aicrowd.com/api/v1/challenges"
self.api_key = os.getenv("AICROWD_API_KEY")
self.headers = {'Authorization': 'Token token="' + self.api_key +'"', 'Content-Type': 'application/json'}
with open("aicrowd.yaml", "r") as f:
self.challenge = yaml.safe_load(f)['challenge_name']
with open("README.md", "r") as f:
self.content = f.read()
self.convert()
def convert(self):
self.content = markdown.markdown(self.content)
self.content = self.content.replace("\"","'")
self.content = self.content.replace("h1","h2")
html.unescape(self.content)
def create_challenge(self):
payload = {
"challenge": self.challenge,
"status_cd": "draft",
"tagline": "",
"perpetual_challenge": False,
"answer_file_s3_key": None,
"slug": self.challenge,
"submission_license": "",
"api_required": False,
"media_on_leaderboard": False,
"online_grading": True,
"description": self.content,
"evaluation": None,
"rules": None,
"prizes": None,
"resources": None,
"submission_instructions": None,
"subissions_page": True,
"license": "",
"dataset_description": None,
"image_file": {"url": "/images/"+self.challenge},
"show_leaderboard": True,
"grader_identifier": "AIcrowd_GRADER_POOL",
"online_submissions": True,
"grader_logs": False,
"require_registration": False,
"grading_history": False,
"post_challenge_submissions": False,
"submissions_downloadable": False,
"dataset_note": None,
"discussions_visible": True,
"latest_submission": False,
"other_scores_fieldnames": "",
"teams_allowed": True,
"max_team_participants": 5,
"team_freeze_seconds_before_end": 604800,
"hidden_challenge": True,
"team_freeze_time": None,
"score_title": "",
"score_secondary_title": "",
"primary_sort_order_cd": "",
"secondary_sort_order_cd": "",
"challenges_organizers_attributes": [{"organizer_id": 9, "challenge_id": 1}],
"category_challenges_attributes": [{"category_id": "8"}],
"dataset_files_attributes": [
{
"seq": 1,
"title": "Training Data",
"description": "Data to be used for training",
"evaluation": False,
"visible": True,
"hosting_location": "External",
"external_url": f"https://s3.eu-central-1.wasabisys.com/aicrowd-practice-challenges/public/"+self.challenge+"/v0.1/train.csv",
"external_file_size": ""
},
{
"seq": 2,
"title": "Validation Data",
"description": "Data to be used for validation",
"evaluation": False,
"visible": True,
"hosting_location": "External",
"external_url": f"https://s3.eu-central-1.wasabisys.com/aicrowd-practice-challenges/public/"+self.challenge+"/v0.1/test.csv",
"external_file_size": ""
},
]
}
return requests.post(self.base_url, json=payload, headers=self.headers)
def update_challenge(self):
payload = {"description": self.content}
request_url = f"{self.base_url}/{self.challenge}"
return requests.patch(request_url, json=payload, headers=self.headers)
def update_or_create(self):
response = self.update_challenge()
if response.status_code == 404:
response = self.create_challenge()
print(response.text)
return response
if __name__ == "__main__":
utils = Utils()
print(utils.update_or_create())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment