File size: 1,634 Bytes
64e0d0d
 
2dcbc67
 
 
 
 
ab0aa92
 
2dcbc67
 
64e0d0d
 
1bf71b8
 
13c17fc
2dcbc67
13c17fc
 
1bf71b8
438bec4
 
 
64e0d0d
2dcbc67
438bec4
2dcbc67
 
1bf71b8
2dcbc67
7aa3345
2dcbc67
438bec4
1bf71b8
 
7aa3345
64e0d0d
2dcbc67
64e0d0d
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import argparse
import subprocess
import os


report = '''\n⚠️⚠️⚠️\n
Try installing latest version of the library by running the following command:
    pip install -u medvqa
If it still cannot solve the problem, don't hesitate to add an issue at https://github.com/SushantGautam/MedVQA/issues with the log above! We will try to solve the problem ASAP. Can also interact with us on Discord: https://discord.gg/22V9huwc3R.\n
⚠️⚠️⚠️'''


def main():
    parser = argparse.ArgumentParser(
        description='MedVQA CLI', allow_abbrev=False)
    parser.add_argument('--competition', type=str, required=True,
                        help='Name of the competition (e.g., gi-2025)')
    parser.add_argument('--task', type=str, required=True,
                        help='Task number (1 or 2)')
    args, unknown = parser.parse_known_args()

    # Dynamically find the base directory of the MedVQA library
    base_dir = os.path.dirname(os.path.abspath(__file__))

    # Check if competition directory exists
    competition_dir = os.path.join(base_dir, 'competitions', args.competition)
    if not os.path.isdir(competition_dir):
        raise FileNotFoundError(
            f"Competition '{args.competition}' does not exist! Need to update library?"+report)
    # Check if task file exists
    task_file = os.path.join(competition_dir, f'task_{args.task}.py')
    if not os.path.isfile(task_file):
        raise FileNotFoundError(
            f"Task '{args.task}' does not exist! Need to update library?"+report)
    subprocess.run(
        ['python', task_file] + unknown)


if __name__ == '__main__':
    main()