Clinical-Genomics-Lund / bonsai

Visualize and analyze resistance and outbreak of bacterial pathogen
https://bonsai-wgs.readthedocs.io/en/latest/
4 stars 1 forks source link

Added new upload script #160

Closed mhkc closed 5 months ago

mhkc commented 6 months ago

Added scripts/upload_sample.py that is more flexible and gives better error messages.

The script takes a YAML file as input with the groups a sample should be added to and the paths to the result and signature file.

group_id:  group_one
prp_result: ../api/tests/data/test_mtuberculosis_1.json
minhash_signature: ../api/tests/data/test_mtuberculosis_1.sig

The script takes username and password either as options or from the ENV variables BONSAI_USER and BONSAI_PASSWD.

Example upload command,

# getting login credentials from ENV
BONSAI_USER=admin BONSAI_PASSWD=foo  ./upload_sample.py --api http://mtlucmds2.lund.skane.se:8811 -c test_sample.yml

# getting login credentials from CLI
 ./upload_sample.py -u admin -p foo --api http://mtlucmds2.lund.skane.se:8811 -c test_sample.yml
ryanjameskennedy commented 5 months ago

I actually tried running a sample with the aforementioned command and got the following error:

UnboundLocalError: cannot access local variable 'sample_id' where it is not associated with a value
ryanjameskennedy commented 5 months ago

bcrypt version 4.1.1 is incompatible with passlib version 1.7.4. It's suggested that we use 3.2.0 but then we get this warning:

bonsai_api                | [2024-03-28 12:38:31,419] DEBUG in bcrypt: detected 'bcrypt' backend, version '3.2.0'
bonsai_api                | [2024-03-28 12:38:31,419] DEBUG in bcrypt: 'bcrypt' backend lacks $2$ support, enabling workaround
mhkc commented 5 months ago

I think this is an issue for another PR

https://github.com/Clinical-Genomics-Lund/bonsai/pull/160#issuecomment-2025004976