Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #80 from aflorithmic/ci_update
Browse files Browse the repository at this point in the history
CircleCI config: publish new version in pip, update latest version parameter
  • Loading branch information
springcoil authored May 5, 2022
2 parents d9ef95e + 015288e commit 1bdb9ed
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 23 deletions.
86 changes: 82 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,44 @@
version: 2.1

config_blocks:
only_tags: &only_tags
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
# ---------------- SLACK CONFIG BLOCK ----------------
slack_channel: &slack_channel deployments #slack channel for notifications

slack_basic_fail: &slack_basic_fail #on fail
- slack/notify:
channel: *slack_channel
event: fail
template: basic_fail_1

slack_basic_success: &slack_basic_success #on success
- slack/notify:
channel: *slack_channel
event: pass
template: basic_success_1

slack_success_deploy: &slack_success_deploy #success tag deploy
- slack/notify:
channel: *slack_channel
event: pass
template: success_tagged_deploy_1
# -----------------------------------------------------------------

orbs:
aws-cli: circleci/[email protected]
slack: circleci/[email protected]

jobs:
semgrep-scan:
parameters:
repo_path:
type: string
default: aflorithmic/aflr_python_client
default_branch:
type: string
default: main
default: aflorithmic/apiaudio-python
semgrep_deployment_id:
type: integer
default: 283
Expand All @@ -26,9 +56,57 @@ jobs:
python -m semgrep_agent \
--publish-deployment << parameters.semgrep_deployment_id >> \
--publish-token $SEMGREP_APP_TOKEN
# It runs on every commit and probably will annoy us too much.
# - <<: *slack_basic_fail
# - <<: *slack_success_deploy

pip-publish:
docker:
- image: cimg/python:3.8
environment:
TRIGGER_TAG: << pipeline.git.tag >>
steps:
- checkout
- run:
name: publish tag that triggered the pipeline
command: |
pip3 install twine wheel
python3 setup.py sdist bdist_wheel
python3 -m twine upload --username $PIPY_USERNAME --password $PIPY_PASSWORD dist/*
- <<: *slack_basic_fail
- <<: *slack_success_deploy

update-ssm:
environment:
TRIGGER_TAG: << pipeline.git.tag >>
executor: aws-cli/default
steps:
- aws-cli/setup:
profile-name: versionUpdate
- run:
name: update SSM parameter with latest SDK version
command: |
aws ssm get-parameter --name /sdk/latest_versions > ssm.json
NEW_VALUE=$(cat ssm.json | python3 -c 'import json,sys,os;obj=json.loads(sys.stdin.read());obj=json.loads(obj["Parameter"]["Value"]);obj["python"]=os.environ["TRIGGER_TAG"];print(obj)')
echo $NEW_VALUE
aws ssm put-parameter --name /sdk/latest_versions --type "String" --value $NEW_VALUE --overwrite
- <<: *slack_basic_fail
- <<: *slack_success_deploy

workflows:
semgrep-scan:
jobs:
- semgrep-scan:
context: aws

version-update:
jobs:
- pip-publish:
context: aws
<<: *only_tags

- update-ssm:
<<: *only_tags
context: aws
requires:
- pip-publish
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Script methods are:
- `scriptText` \* [Required] (string) - Text for your script. A script can contain multiple sections and SSML tags. Learn more about scriptText details [here](https://docs.api.audio/docs/script-2)
- `projectName` (string) - The name of your project. Default value is "default"
- `moduleName` (string) - The name of your module. Default value is "default"
- `scriptName` (string) - The name of your script. Default value is "default" (max 60 characters)
- `scriptName` (string) - The name of your script. Default value is "default" (max 60 characters)
- `scriptId` (string) - Custom identifier for your script. If scriptId parameter is used, then projectName, moduleName and scriptName are required parameters.
- `versions` (dictionary) - A dictionary containing different versions of your script text, whereby the key is the version name, and its value is the associated `scriptText`. Version name `v0` is reserved as the default `scriptText`. Default value is "{}"
- Example:
Expand Down Expand Up @@ -788,7 +788,7 @@ Orchestrator methods are:
- `scriptText` \* [Required] (str) - Text to synthesize (TTS).
- `soundTemplate` (str) - Sound template to use.
- `voice` \* [Required] (str) - Name of voice to use.



- `create_three_sections()` Creates a TTS speech request with 3 sections and adds a sound template to it through mastering.
Expand Down
6 changes: 3 additions & 3 deletions apiaudio/api_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ def _expanded_raise_for_status(self, res):
def _options_request(cls, url=None):
url = url or f"{apiaudio.api_base}{cls.resource_path}"
headers = cls._build_header()

r = requests.options(url=url, headers=headers)

cls._expanded_raise_for_status(r)

return r.json()
3 changes: 1 addition & 2 deletions apiaudio/api_resources/mastering.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class Mastering(CreatableResource, RetrievableResource, DownloadableResource):

loop_status_code = 202


@classmethod
def list_presets(cls):
return cls._get_request(path_param=cls.mastering_preset_list_path)
return cls._get_request(path_param=cls.mastering_preset_list_path)
15 changes: 6 additions & 9 deletions apiaudio/api_resources/orchestrator.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from apiaudio.helper_classes import (
CreatableResource,
HelpResource
)
from apiaudio.helper_classes import CreatableResource, HelpResource


class CreateMediaWithSound(CreatableResource):
OBJECT_NAME = "orchestrator"
resource_path = "/orchestrator/media_with_sound"


class CreateAudio(CreatableResource):
OBJECT_NAME = "orchestrator"
resource_path = "/orchestrator/create_audio"


class CreateThreeSections(CreatableResource):
OBJECT_NAME = "orchestrator"
resource_path = "/orchestrator/create_three_sections"
Expand All @@ -31,10 +31,7 @@ def create_audio(cls, **args):
@classmethod
def create_three_sections(cls, **args):
return cls.download(cls, CreateThreeSections.create(**args))


def download(cls, response):
local_filename = cls._download_request(
url=response.get("url"), destination="."
)
return local_filename
local_filename = cls._download_request(url=response.get("url"), destination=".")
return local_filename
1 change: 1 addition & 0 deletions apiaudio/helper_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class HelpResource(APIRequest):
def help(cls, **params):
return cls._options_request()


class CreatableResource(APIRequest):
@classmethod
def create(cls, **params):
Expand Down
4 changes: 1 addition & 3 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ def test_script_versions():
from .assets import test_versions

script = apiaudio.Script.create(
scriptId="test_sdk",
scriptText="hello...",
versions=test_versions
scriptId="test_sdk", scriptText="hello...", versions=test_versions
)

assert script.get("availableVersions") == ["v0"] + [
Expand Down

0 comments on commit 1bdb9ed

Please sign in to comment.