Skip to content

Commit

Permalink
feat: create user
Browse files Browse the repository at this point in the history
  • Loading branch information
antwxne committed Jun 9, 2022
1 parent a875135 commit 5af4a06
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="CVAT wrapper",
version="0.0.7",
version="0.0.8",
author="antwxne",
author_email="[email protected]",
description="Python wrapper for CVAT API",
Expand Down
2 changes: 1 addition & 1 deletion src/CVAT/Predictions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .Foodvisor import *
from Interface import IPrediction
from .Interface import IPrediction
15 changes: 15 additions & 0 deletions src/CVAT/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,18 @@ def __init__(self, username: str = "admin", password: str = "admin", url: str =
self.session.headers = {"Authorization": f'Token {response.json()["key"]}'}
if response.status_code != 200:
raise ValueError("Bad credentials")

def create_user(self, user_name: str, user_mail: str, password: str, first_name: str, last_name: str) -> None:
body: dict = {
"username": user_name,
"email": user_mail,
"password1": password,
"password2": password,
"first_name": first_name,
"last_name": last_name,
"confirmations": []
}
response: Response = self.session.post(url=f'{self.url}/api/auth/register',
json=body)
if response.status_code != 201:
raise Exception(response.content)
9 changes: 5 additions & 4 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
# API.upload_predictions(task, prediction)

if __name__ == "__main__":
prediction_json: list[dict] = CVAT.get_json_from_file("./foodvisor_valid_12_2021_Fromages_gmd_predictions.json")
directory: str = "data/Images/Fromages"
interface: dict = CVAT.get_json_from_file("../interface_foodvisor.json")
images_path: list[str] = image_content_from_kili_prediction(prediction_json, directory)
API.create_user("oui", "[email protected]", "kgjhagkjlhlaegkj", "aaa", "aaaa")
# prediction_json: list[dict] = CVAT.get_json_from_file("./foodvisor_valid_12_2021_Fromages_gmd_predictions.json")
# directory: str = "data/Images/Fromages"
# interface: dict = CVAT.get_json_from_file("../interface_foodvisor.json")
# images_path: list[str] = image_content_from_kili_prediction(prediction_json, directory)
# project_id: int = API.create_project("TEST_API2", interface=interface)
# task: Task = Task("jqefhgfdqf", project_id=project_id)
# task: Task = API.get_task_by_name("qsfqsfqsf")
Expand Down

0 comments on commit 5af4a06

Please sign in to comment.