Skip to content

Commit

Permalink
Code cleanup and documentation (#38)
Browse files Browse the repository at this point in the history
* Fixed carriage return issue with build.sh in each python lambda.

* Added an exports file so users can change that instead of messing with code when trying to load this onto their environment.

* Updated READMEs

* Added convinient buildall bash scripts

* Modified buildall script to include gradle and fixed getting environment variable in python functions.

* Minor Semantic Changes and README

* Added dynamic links to AWS service dependancies

* Updated README for UserConfigFunction

* Get rid of unnecessary files

* Cleaned up code

* Modified Testing and code clean up

* Update cdk-init-ts-stack.ts

Changed node 18 to node 16

* Update README.md

Added forgotten step
  • Loading branch information
kyoncal authored Jun 24, 2023
1 parent e9034d4 commit 51acb89
Show file tree
Hide file tree
Showing 30 changed files with 567 additions and 796 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ amplifyconfiguration.json
amplify-build-config.json
amplify-gradle-config.json
amplifytools.xcconfig
_pycache_
amplify/backend/function/getBlogContent/package/
amplify/backend/function/stepFunctionInvoker/package/event.json
amplify/backend/function/stepFunctionInvoker/package/
amplify/backend/function/storingTranslation/package/
amplify/backend/function/storingTranslation/storing_translation.zip
amplify/backend/function/getBlogContent/get_blog_content.zip
amplify/backend/function/stepFunctionInvoker/step_function_invoker.zip
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ Below is a brief description of each subdirectory:
- [Step Function Invoker](amplify/backend/function/stepFunctionInvoker): This is the AWS Lambda function that invokes the AWS Step Function.
- [Storing Translation](amplify/backend/function/storingTranslation): This is the AWS Lambda function that stores the translation in DynamoDB.
- [User Config Function](amplify/backend/function/UserConfigFunction): This is the AWS Lambda function processes the user's configuration and queries the Translation.
- [CDK Infrastructure as Code](cdk-init-ts/): This is code that creates all of the infrastucture for the application.

11 changes: 0 additions & 11 deletions amplify/backend/function/UserConfigFunction/Pipfile

This file was deleted.

20 changes: 0 additions & 20 deletions amplify/backend/function/UserConfigFunction/Pipfile.lock

This file was deleted.

73 changes: 73 additions & 0 deletions amplify/backend/function/UserConfigFunction/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# UserConfigFunction

This directory contains the service that is responsible for interacting with the proper translation model, and sending the result back to the AppSync in proper format, given a URL input.

## Tech Specs
This function uses Java 17 and Gradle as a package manager. It is intended to run on using AWS Lambda.

### Directory Structure

- [Handler](src/main/java/com/awsomenlp/lambda/config/): This is what is called when this lambda is invoked.
- [Objects](src/main/java/com/awsomenlp/lambda/config/objects): This is where the objects are stored.
- [Resolvers](src/main/java/com/awsomenlp/lambda/config/resolvers): This is where the resolvers are stored. Resolvers act as interfaces between different services, for example, the AppSyncResolver converts relevant data from this service into something AppSync can understand.
- [Models](src/main/java/com/awsomenlp/lambda/config/models): This is where the different translation models are stored and interfaced with.

### Building & Testing

Since this project is using Gradle, you can test it using ```$ gradle test``` and build using ```$ gradle build```.

#### Deployment

This function should be deployed automatically by CDK, however, if you'd like to deploy this manually, you can with ```$ gradle buildZip``` and uploading it to a Lambda function with the following specifications:

```
role: userConfigFunctionRole,
runtime: Runtime.JAVA_17,
handler: com.awsomenlp.lambda.config.UserConfigHandler::handleRequest,
memorySize*: 1024MB,
timeout: cdk.Duration.seconds(45)
```

*The memory size is totally optional, this can be left at default.

**input**

```
{
"arguments": {
"input": {
"url":https://aws.amazon.com/blogs/mobile/export-amplify-backends-to-cdk-and-use-with-existing-deployment-pipelines/,
"targetLanguage": {
"name": "TURKISH",
"code": "tr"
},
"sourceLanguage": {
"name": "ENGLISH",
"code": "en"
},
"translationModel": {
"type": "amazonTranslate"
}
}
}
}
```

**output**

```
{
"blogPostOriginalPostId": "10",
"blogPostLanguageCode": "tr",
"id": "100",
"title": (Translated Title),
"content": [
(Translated Paragraph),
(Translated Paragraph)
],
"authors": [
(Author 1),
(Author 2)
]
}
```

This file was deleted.

This file was deleted.

Loading

0 comments on commit 51acb89

Please sign in to comment.