Skip to content
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

Fixed protein upload_all script #185

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/src/api/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def login(body: LoginBody):

# Generates the token and returns
token = generateAuthToken(email, admin)
log.warn("Giving token:", token)
return LoginResponse(token=token, error="")

except Exception as e:
Expand Down
22 changes: 19 additions & 3 deletions galaxy/upload_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,21 @@ def remove_box():
os.system(f"rm -rf {DIR}")


def upload_protein_file(path, name, species_name, content="", refs="", desc=""):
def get_login_token():
info = {
"email": "test",
"password": "test"
}
res = requests.post("http://localhost:8000/users/login", json=info)
if res.json()['error']:
print("Login error:", res.json()['error'])
exit()
return res.json()['token']


def upload_protein_file(path, name, species_name, content="", refs="", desc="", token=""):
with open(path, "r") as f:
pdb_file_str = f.read()

payload = {
"name": name,
"species_name": species_name,
Expand All @@ -26,11 +37,15 @@ def upload_protein_file(path, name, species_name, content="", refs="", desc=""):
"pdb_file_str": pdb_file_str,
"description": desc,
}
out = requests.post("http://localhost:8000/protein/upload", json=payload)
out = requests.post("http://localhost:8000/protein/upload", json=payload, headers={

"authorization":"Bearer {}".format(token)
})
return out


def upload_all():
token=get_login_token()
unzip_box()
available_species = {
"Gh": "ganaspis hookeri",
Expand All @@ -50,6 +65,7 @@ def upload_all():
content=CONTENT,
refs=REFS,
desc="from the venom lab at osu",
token=token,
)
print("uploaded", full_path, name, species_name)
remove_box()
Expand Down
Loading