# dolby-atmos-packager-alpha

This process is meant to serve as a quick to build system to automate a slow manual process. This is temporary process that should be discontinued once a full featured one can be researched and developed.

See this [planning document](https://docs.google.com/document/d/1BRF4VCfd2qXhthfQj-VHHGIvIgn8mgEuz_vQJq8pIUQ/edit?pli=1) for more details.

### Running Locally

#### Setup environment

1. create `.env` file that will pass variables to container
```
$ cp .env.shadow .env
```

2. fill in any secret values in `.env`
4. ensure [ECR access](https://www.notion.so/AWS-Access-f841b9dd815d4443a80e96a86c92cd2f?pvs=4#7a6624c58c6642abaecd804e5f25c820) is setup
5. enable AWS access to the **prod** account using [awsume](https://www.notion.so/AWS-Access-f841b9dd815d4443a80e96a86c92cd2f?pvs=4#beaec95488ad4473899a26a2b8cf603f)
6. confirm you are a member of the `vector` application family to access input and output buckets in QA
7. confirm you are a member of the `assets` application family to access mezzanine artwork bucket in QA

:warning: You can setup the application to talk to input/output buckets in **dev** but you will be unable to download artwork that exists in the **prod** AWS account and will need to work around that. If this becomes a common problem we will create a documented process to run the application with more limited access.

#### Run application

```
$ docker compose up --build packager
```

##### Ready to Test Products
These product pairs have the stereo product's artwork copied into QA according to [this process](https://www.notion.so/Encoding-Workers-4614a8e498034b4984eba275c3709c21?pvs=4#29f557cb44d54182809cd3a332a43e04) and spatial audio tracks have been uploaded into [qa-dolby-atmos-packager-alpha-input](https://s3.console.aws.amazon.com/s3/buckets/qa-dolby-atmos-packager-alpha-input?region=us-east-1&bucketType=general&tab=objects). Switch config values in `.env` to test different products.

| stereo UPC  | spatial upc | spatial / stereo tracks | spatial audio size | notes |
| ------------- | ------------- | ------------- | ------------- | ------------- |
| 197190622188  | 197190684056  |1 / 22 | 133.7 KB| file trimmed to reduce size for speed |
| 197190137897  | 197190157253  |22 / 22| 19 GB| full unmodified files (except track 17 is trimmed) |


### Debugging

After starting a container and hitting a breakpoint, you can attach and enter into the python debugger normally.

```
$ docker attach $(docker ps -f name="dolby-atmos-packager-alpha-packager" -q)
```


#### Run linting and tests

```
$ docker compose up --build lint-and-test --exit-code-from lint-and-test
```

### Adding a new DMS

#### Setup Packager Logic
1. Create a new file and class in `src/packagers/` that inherits from `AbstractPackager` or one of it's children.
2. Set the `dms_id` property to the integer value from `customer_master_master.customer_master_master_id` in `art_relations` database
3. Perform overrides if necessary
	* `transform_xml()` how metadata XML file is generated
	* `output_*()` how resulting output files are named and organized
	* `transform_image()` how artwork image is modified

#### Configure Kickoff Script

1. Edit `DMS_MAP` in `kickoff/main.py`, adding the mapping for new DMS, matching integer ID in packager class

#### Configure Jenkins

1. Edit [this job](https://scheduler.theorchard.io/job/dolby-atmos-packager-alpha/)
2. Add new "Boolean Parameter"
    * must be named `DMS_<INTEGER_ID>` matching integer ID in packager class
    * add human readable DMS name in "description" field
