Skip to content

Update commands to work for AB2D-5860 #10

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
112 changes: 30 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This script will not overwrite already existing export files.

```
Usage:
python job-cli.py (-prod | -sandbox) --auth <authfile.base64> [--directory <dir>] [--since <since>] --fhir (R4 | STU3)
python3 job-cli.py (-prod | -sandbox) --auth <authfile.base64> [--directory <dir>] [--since <since>] --fhir (R4 | STU3)
[(--only_start|--only_monitor|--only_download)]

Help (for an explanation of the arguments):
Expand All @@ -54,7 +54,7 @@ Arguments:

### Help

Run `python job-cli.py --help` to get a full list of arguments and explanations.
Run `python3 job-cli.py --help` to get a full list of arguments and explanations.

### Since Parameter

Expand Down Expand Up @@ -90,7 +90,7 @@ If you want to:
1. And save all results for this job to the directory /opt/foo

Then run the following command:
`python job-cli.py -prod --auth auth-credentials.base64 --directory /opt/foo`
`python3 job-cli.py -prod --auth auth-credentials.base64 --directory /opt/foo`

## Install or verify python 3, pip, and required pip modules

Expand All @@ -112,7 +112,11 @@ Then run the following command:

### Install or verify python 3, pip, and required pip modules on Mac

> *** TO DO ***
Python and pip come pre-installed on MacOS. You can verify this with:
```ShellSession
python3 --version
pip3 --version
```

### Install or verify python 3, pip, and required pip modules on Windows

Expand Down Expand Up @@ -221,7 +225,7 @@ Then run the following command:
1. Check the python3 version

```ShellSession
python --version
python3 --version
```

1. Verify that the version of python that you installed is displayed
Expand All @@ -235,31 +239,31 @@ Then run the following command:
1. Check the python3 version

```ShellSession
pip --version
pip3 --version
```

1. Verify that the version of python that you installed is displayed

*Format:*

```
pip {version} from {installation directory}\pip (python 3.{version}
pip3 {version} from {installation directory}\pip (python 3.{version}
```

#### Install required pip modules on Windows

1. Install the "requests" pip module

```ShellSession
pip install requests
pip3 install requests
```

1. Verify that the requests module installed correctly

1. Show the request pip module

```ShellSession
pip show requests
pip3 show requests
```

1. Verify that a description of the "requests" module is displayed
Expand All @@ -278,53 +282,38 @@ Then run the following command:

[Running All Stages](#running-all-stages)

### Running Stages Individually

1. Set the AUTH_FILE value
### Authorization Files

*On Mac or Linux:*
This repo contains authorization files for the four sandbox datasets. The file with Z0000 in the name is the smallest dataset and should be used for initial experimentation. If you want to use a different dataset then set AUTH_FILE to the corresponding authorization file. If you want to see how authorization files are created, look at make_creds_files.sh

```bash
AUTH_FILE=<auth credentials file>
```

*On Windows from command prompt:*

```ShellSession
SET AUTH_FILE=<auth credentials file>
```
### Running Stages Individually

1. Write the credentials to the auth file
1. Set the AUTH_FILE value

*On Mac or Linux:*

```bash
echo -n "${OKTA_CLIENT_ID}:${OKTA_CLIENT_PASSWORD}" | base64 > $AUTH_FILE
AUTH_FILE=credentials_Z0000.base64
```

*On Windows from command prompt:*

```ShellSession
$BASE64_ENCODED_ID_PASSWORD='{Base64-encoded id:password}'
Set-Content -Path $AUTH_FILE $BASE64_ENCODED_ID_PASSWORD
SET AUTH_FILE=credentials_Z0000.base64
```

1. Exit your current terminal and open a new terminal

1. Repeat setting the AUTH_FILE value

1. Set a variable with today's date

*Example on Mac or Linux:*

```bash
TODAYS_DATE=2020-10-30
TODAYS_DATE=2024-01-31
```

*Example on Windows from command prompt:*

```ShellSession
SET TODAYS_DATE=2020-10-30
SET TODAYS_DATE=2024-01-31
```

1. Create a directory for downloading export files
Expand All @@ -348,13 +337,13 @@ Then run the following command:
*On Mac or Linux:*

```bash
python job-cli.py -sandbox --auth $AUTH_FILE --directory $TARGET_DIR --only_start --fhir R4
python3 job-cli.py -sandbox --auth $AUTH_FILE --directory $TARGET_DIR --only_start --fhir R4
```

*On Windows from command prompt:*

```ShellSession
python job-cli.py -sandbox --auth %AUTH_FILE% --directory %TARGET_DIR% --only_start --fhir R4
python3 job-cli.py -sandbox --auth %AUTH_FILE% --directory %TARGET_DIR% --only_start --fhir R4
```

1. Verify that a job id was created
Expand All @@ -376,13 +365,13 @@ Then run the following command:
*On Mac or Linux:*

```bash
python job-cli.py -sandbox --auth $AUTH --directory $TARGET_DIR --only_monitor
python3 job-cli.py -sandbox --auth $AUTH_FILE --directory $TARGET_DIR --only_monitor --fhir R4
```

*On Windows from command prompt:*

```ShellSession
python job-cli.py -sandbox --auth %AUTH% --directory %TARGET_DIR% --only_monitor
python job-cli.py -sandbox --auth %AUTH_FILE% --directory %TARGET_DIR% --only_monitor --fhir R4
```

1. Verify that a job completed by verifying the list of files in the response
Expand All @@ -406,13 +395,13 @@ Then run the following command:
*On Mac or Linux:*

```bash
python job-cli.py -sandbox --auth $AUTH --directory $TARGET_DIR --only_download
python3 job-cli.py -sandbox --auth $AUTH_FILE --directory $TARGET_DIR --only_download --fhir R4
```

*On Windows from command prompt:*

```ShellSession
python job-cli.py -sandbox --auth %AUTH% --directory %TARGET_DIR% --only_download
python3 job-cli.py -sandbox --auth %AUTH_FILE% --directory %TARGET_DIR% --only_download
```

1. List the files that you have downloaded
Expand All @@ -438,13 +427,13 @@ Then run the following command:
*On Mac or Linux:*

```bash
AUTH=<auth value>
AUTH_FILE=credentials_Z0000.base64
```

*On Windows from command prompt:*

```ShellSession
SET AUTH=<auth value>
SET AUTH_FILE=credentials_Z0000.base64
```

1. Set a variable with today's date
Expand Down Expand Up @@ -482,7 +471,7 @@ Then run the following command:
*On Mac or Linux:*

```bash
python job-cli.py -sandbox --auth $AUTH_FILE --directory $TARGET_DIR --fhir R4
python3 job-cli.py -sandbox --auth $AUTH_FILE --directory $TARGET_DIR --fhir R4
```

*On Windows from command prompt:*
Expand All @@ -506,44 +495,3 @@ Then run the following command:
```

1. Stop here, you have completed the file download

## Bundling Python and Script

### Build Python in Source

1. Download the latest version of Python as a tar file
1. Unpack the tar file `tar -xvf python-tar`
1. Change directory to the folder created `cd python-tar`
1. Configure the installer `./configurer --prefix /path/to/ab2d/examples/python/python --with-openssl=$(brew --prefix openssl)`
1. Run `make`
1. Run `make install`
1. Check that the following directories exist in `/path/to/ab2d/examples/python/python`:
`bin, lib, share, include`

### Setup Virtual Environment

Before zipping up Python we need to create a virtual environment. This part assumes access to IntelliJ or PyCharm.

In IntelliJ these are the steps

1. Go to File -> Project Structure
1. Look for Platform Settings -> SDKs and click on it
1. Add a new Python SDK, set the python interpreter as `ab2d/examples/python/python/bin/python3`,
and set the `venv` home as `examples/python/venv`
1. Open a terminal in IntelliJ and in that terminal change directories to `ab2d/examples/python/`
1. Then install the `requests` library by running `venv/bin/pip3 install requests`

### Zip

1. Change directory `cd examples`
1. `zip -r client.zip python`

### Unzip and Run

**When developing move `/path/to/ab2d/examples/python/python` and `/path/to/ab2d/examples/python/venv` to different
directories to check that no symbolic links**

1. Unzip `unzip client.zip`
1. Change directory to the python directory
1. Export the path to the python folder `PYTHONPATH=./python`
1. Run a job by using `/venv/bin/python3 job-cli.py ...`
1 change: 1 addition & 0 deletions credentials_Z0000.base64
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MG9hMnQwbHNyZFp3NXVXUngyOTc6SEhkdVdHNkxvZ0l2RElRdVdncDNabG85T1lNVmFsVHRINU9CY3VIdw==
1 change: 1 addition & 0 deletions credentials_Z0010.base64
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MG9hMnQwbG05cW9BdEpIcUMyOTc6eWJSNjBKbXRjcFJ0NlNBZUxtdmJxNmwtM1lEUkNaUC1XTjFBdDZ0Xw==
1 change: 1 addition & 0 deletions credentials_Z1001.base64
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MG9hOWp5eDJ3OVowQW50TEUyOTc6aHNrYlB1LVlvV2ZHRFkxZ2NRcTM0QmZJRXlNVnVheXU4N3pXRGxpRw==
1 change: 1 addition & 0 deletions credentials_Z1002.base64
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MG9hOWp6MGUxZHlOZlJNbTYyOTc6c2huRzZOR2tIY3UyOXB0RHNLS1JXNnE1dUZKU1NwSXBkbF9LNWZWVw==
28 changes: 28 additions & 0 deletions make_creds_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

#For Sponsor PDP-100
CLIENT_CONTRACT1='Z0000'
CLIENT_ID1='0oa2t0lsrdZw5uWRx297'
CLIENT_PASSWORD1='HHduWG6LogIvDIQuWgp3Zlo9OYMValTtH5OBcuHw'
echo -n "${CLIENT_ID1}:${CLIENT_PASSWORD1}" | base64 > "credentials_${CLIENT_CONTRACT1}.base64"

#For Sponsor PDP-100000
CLIENT_CONTRACT2='Z0010'
CLIENT_ID2='0oa2t0lm9qoAtJHqC297'
CLIENT_PASSWORD2='ybR60JmtcpRt6SAeLmvbq6l-3YDRCZP-WN1At6t_'
echo -n "${CLIENT_ID2}:${CLIENT_PASSWORD2}" | base64 > "credentials_${CLIENT_CONTRACT2}.base64"

#For Sponsor PDP-1001
CLIENT_CONTRACT3='Z1001'
CLIENT_ID3='0oa9jyx2w9Z0AntLE297'
CLIENT_PASSWORD3='hskbPu-YoWfGDY1gcQq34BfIEyMVuayu87zWDliG'
echo -n "${CLIENT_ID3}:${CLIENT_PASSWORD3}" | base64 > "credentials_${CLIENT_CONTRACT3}.base64"

#For Sponsor PDP-1002
CLIENT_CONTRACT4='Z1002'
CLIENT_ID4='0oa9jz0e1dyNfRMm6297'
CLIENT_PASSWORD4='shnG6NGkHcu29ptDsKKRW6q5uFJSSpIpdl_K5fVW'
echo -n "${CLIENT_ID4}:${CLIENT_PASSWORD4}" | base64 > "credentials_${CLIENT_CONTRACT4}.base64"