|
| 1 | + |
| 2 | +--- |
| 3 | + |
| 4 | +# MedCATtrainer Client |
| 5 | + |
| 6 | +A Python client for interacting with a MedCATTrainer web application instance. This package allows you to manage datasets, concept databases, vocabularies, model packs, users, projects, and more via Python code or the command line. |
| 7 | + |
| 8 | +## Features |
| 9 | + |
| 10 | +- Manage datasets, concept databases, vocabularies, and model packs |
| 11 | +- Create and manage users and projects |
| 12 | +- Retrieve and upload project annotations |
| 13 | +- Command-line interface (CLI) for automation |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +```sh |
| 18 | +pip install mctclient |
| 19 | +``` |
| 20 | + |
| 21 | +Or, if installing from source: |
| 22 | + |
| 23 | +```sh |
| 24 | +cd client |
| 25 | +python -m build |
| 26 | +pip install dist/*.whl |
| 27 | +``` |
| 28 | + |
| 29 | +## Python Usage |
| 30 | + |
| 31 | +```sh |
| 32 | +export MCTRAINER_USERNAME=<username> |
| 33 | +export MCTRAINER_PASSWORD=<password> |
| 34 | +``` |
| 35 | + |
| 36 | +```python |
| 37 | +from mctclient import MedCATTrainerSession, MCTDataset, MCTConceptDB, MCTVocab, MCTModelPack, MCTMetaTask, MCTRelTask, MCTUser, MCTProject |
| 38 | + |
| 39 | +# Connect to your MedCATTrainer instance |
| 40 | +session = MedCATTrainerSession(server="http://localhost:8001") |
| 41 | + |
| 42 | +# List all projects |
| 43 | +projects = session.get_projects() |
| 44 | +for project in projects: |
| 45 | + print(project) |
| 46 | + |
| 47 | +# Create a new dataset |
| 48 | +dataset = session.create_dataset(name="My Dataset", dataset_file="path/to/data.csv") |
| 49 | + |
| 50 | +# Create a new user |
| 51 | +user = session.create_user(username="newuser", password="password123") |
| 52 | + |
| 53 | +# Create a new project |
| 54 | +project = session.create_project( |
| 55 | + name="My Project", |
| 56 | + description="A new annotation project", |
| 57 | + members=[user], |
| 58 | + dataset=dataset |
| 59 | +) |
| 60 | +``` |
| 61 | + |
| 62 | +### MedCATTrainerSession Methods |
| 63 | + |
| 64 | +- `create_project(name, description, members, dataset, cuis=[], cuis_file=None, concept_db=None, vocab=None, cdb_search_filter=None, modelpack=None, meta_tasks=[], rel_tasks=[])` |
| 65 | +- `create_dataset(name, dataset_file)` |
| 66 | +- `create_user(username, password)` |
| 67 | +- `create_medcat_model(cdb, vocab)` |
| 68 | +- `create_medcat_model_pack(model_pack)` |
| 69 | +- `get_users()` |
| 70 | +- `get_models()` |
| 71 | +- `get_model_packs()` |
| 72 | +- `get_meta_tasks()` |
| 73 | +- `get_rel_tasks()` |
| 74 | +- `get_projects()` |
| 75 | +- `get_datasets()` |
| 76 | +- `get_project_annos(projects)` |
| 77 | + |
| 78 | +Each method returns the corresponding object or a list of objects. |
| 79 | + |
| 80 | +## License |
| 81 | + |
| 82 | +This project is licensed under the Apache 2.0 License. |
| 83 | + |
| 84 | +## Contributing |
| 85 | + |
| 86 | +Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change. |
| 87 | + |
| 88 | + |
0 commit comments