数据切片工具,用于从一个transmart读取数据并将其上载到另一个transmart
transmart-hyper-dicer的Python项目详细描述
transmart hyper dicer是一个数据切片工具,它从一个TranSMART实例读取数据并将其上载到另一个实例。
注:这是一个非常初步的版本,仍在开发中。 可在https://github.com/thehyve/transmart-hyper-dicer/issues报告问题。
配置
通过设置下面的环境变量,可以配置到keypolt身份提供程序和transmart的连接:
Variable | Description |
---|---|
TRANSMART_URL | URL of the TranSMART back-end application e.g. https://transmart.example.com |
KEYCLOAK_SERVER_URL | URL of the Keycloak identity provider e.g. https://keycloak.example.com |
KEYCLOAK_REALM | Keycloak realm, e.g. dev |
KEYCLOAK_CLIENT_ID | Keycloak client ID, e.g. transmart-client |
OFFLINE_TOKEN | An offline token used used as a refresh token in order to communicate with TranSMART |
VERIFY_CERT | Either a boolean, in which case it controls whether the server’s TLS certificate is verified, or a string, in which case it must be a path to a CA bundle to use. Defaults to True. |
为了为USERNAME用户生成脱机令牌,可以使用以下curl命令。 要获取令牌,用户需要具有领域级别的角色映射:offline_access。 在使用该命令之前,必须用正确的大写单词替换。
curl \ -d 'client_id=KEYCLOAK_CLIENT_ID'\ -d 'username=USERNAME'\ -d 'password=PASSWORD'\ -d 'grant_type=password'\ -d 'scope=offline_access'\ 'https://KEYCLOAK_SERVER_URL/auth/realms/KEYCLOAK_REALM/protocol/openid-connect/token'
响应中的refresh_token字段的值是脱机令牌。
所有变量都可以在.env文件中指定为键值对。启动应用程序时,它们将自动设置为环境变量。.env文件的示例:
KEYCLOAK_CLIENT_ID=transmart-client KEYCLOAK_SERVER_URL=https://keycloak.example.com KEYCLOAK_REALM=dev OFFLINE_TOKEN=<refresh_token value from the curl response> TRANSMART_URL=https://transmart.example.com
安装
这个包需要Python3.6+。
要安装transmart-hyper-dicer,请执行以下操作:
pip install transmart-hyper-dicer
或来源:
git clone https://github.com/thehyve/transmart-hyper-dicer.git
cd transmart-hyper-dicer
pip install .
使用以下命令运行测试(包括覆盖率):
python setup.py test
用法
基于输入json文件中指定的约束,从配置的transmart实例读取数据子集 并以transmart-copy格式将输出写到/path/to/output。 输出目录应该是空的不存在的(然后将被创建)。
输入约束必须是valid tranSMART constraint。<;input.json>;文件内容示例:
{"type":"study_name","studyId":"EHR"}
运行:
transmart-hyper-dicer <input.json> /path/to/output
这将在output目录中生成目录i2b2metadata和i2b2demodata。 生成的数据可以使用transmart-copy:
# Download transmart-copy: curl -f -L https://repo.thehyve.nl/service/local/repositories/releases/content/org/transmartproject/transmart-copy/17.1-HYVE-6.2/transmart-copy-17.1-HYVE-6.2.jar -o transmart-copy.jar # Load data PGUSER=tm_cz PGPASSWORD=tm_cz java -jar transmart-copy.jar -d output
包管理和依赖关系
这个项目使用pip来安装依赖项和包管理。
- 依赖项应添加到安装要求列表中的setup.py中。