Я пытаюсь загрузить свою функцию Lambda с помощью Amplify, и в настоящее время у меня возникла ошибка. Я уже тестировал функцию в самой Lambda, и она отлично работает, у меня просто возникают проблемы, когда я пытаюсь запустить тест (усиление фиктивной функции) или когда я пытаюсь отправить sh в облако.
Я получаю следующую ошибку:
Starting execution...
ChipAMP2 failed with the following error:
Error: Command failed: pipenv install
Traceback (most recent call last):
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/project.py", line 527, in _parse_pipfile
return tomlkit.parse(contents)
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/tomlkit/api.py", line 49, in parse
return Parser(string).parse()
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/tomlkit/parser.py", line 146, in parse
key, value = self._parse_table()
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/tomlkit/parser.py", line 958, in _parse_table
item = self._parse_item()
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/tomlkit/parser.py", line 270, in _parse_item
return self._parse_key_value(True)
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/tomlkit/parser.py", line 355, in _parse_key_value
val = self._parse_value()
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/tomlkit/parser.py", line 542, in _parse_value
raise self.parse_error(UnexpectedCharError, c)
tomlkit.exceptions.UnexpectedCharError: Unexpected character: 'd' at line 14 col 16
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/toml/decoder.py", line 455, in loads
ret = decoder.load_line(line, currentlevel, multikey,
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/toml/decoder.py", line 678, in load_line
raise ValueError("Invalid date or number")
ValueError: Invalid date or number
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/bin/pipenv", line 8, in <module>
sys.exit(cli())
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/cli/command.py", line 235, in install
retcode = do_install(
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/core.py", line 1734, in do_install
ensure_project(
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/core.py", line 578, in ensure_project
if project.required_python_version:
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/project.py", line 243, in required_python_version
required = self.parsed_pipfile.get("requires", {}).get(
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/project.py", line 509, in parsed_pipfile
parsed = self._parse_pipfile(contents)
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/project.py", line 531, in _parse_pipfile
return toml.loads(contents)
File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/toml/decoder.py", line 458, in loads
raise TomlDecodeError(str(err), original, pos)
toml.decoder.TomlDecodeError: Invalid date or number (line 14 column 1 char 151)
at ChildProcess.exithandler (child_process.js:303:12)
at ChildProcess.emit (events.js:321:20)
at ChildProcess.EventEmitter.emit (domain.js:485:12)
at maybeClose (internal/child_process.js:1026:16)
at Socket.<anonymous> (internal/child_process.js:441:11)
at Socket.emit (events.js:321:20)
at Socket.EventEmitter.emit (domain.js:485:12)
at Pipe.<anonymous> (net.js:668:12) {
killed: false,
code: 1,
signal: null,
cmd: 'pipenv install',
stdout: '',
stderr: 'Traceback (most recent call last):\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/project.py", line 527, in _parse_pipfile\n' +
' return tomlkit.parse(contents)\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/tomlkit/api.py", line 49, in parse\n' +
' return Parser(string).parse()\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/tomlkit/parser.py", line 146, in parse\n' +
' key, value = self._parse_table()\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/tomlkit/parser.py", line 958, in _parse_table\n' +
' item = self._parse_item()\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/tomlkit/parser.py", line 270, in _parse_item\n' +
' return self._parse_key_value(True)\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/tomlkit/parser.py", line 355, in _parse_key_value\n' +
' val = self._parse_value()\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/tomlkit/parser.py", line 542, in _parse_value\n' +
' raise self.parse_error(UnexpectedCharError, c)\n' +
"tomlkit.exceptions.UnexpectedCharError: Unexpected character: 'd' at line 14 col 16\n" +
'\n' +
'During handling of the above exception, another exception occurred:\n' +
'\n' +
'Traceback (most recent call last):\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/toml/decoder.py", line 455, in loads\n' +
' ret = decoder.load_line(line, currentlevel, multikey,\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/toml/decoder.py", line 678, in load_line\n' +
' raise ValueError("Invalid date or number")\n' +
'ValueError: Invalid date or number\n' +
'\n' +
'During handling of the above exception, another exception occurred:\n' +
'\n' +
'Traceback (most recent call last):\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/bin/pipenv", line 8, in <module>\n' +
' sys.exit(cli())\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 764, in __call__\n' +
' return self.main(*args, **kwargs)\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 717, in main\n' +
' rv = self.invoke(ctx)\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke\n' +
' return _process_result(sub_ctx.command.invoke(sub_ctx))\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 956, in invoke\n' +
' return ctx.invoke(self.callback, **ctx.params)\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 555, in invoke\n' +
' return callback(*args, **kwargs)\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func\n' +
' return ctx.invoke(f, obj, *args, **kwargs)\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 555, in invoke\n' +
' return callback(*args, **kwargs)\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func\n' +
' return f(get_current_context(), *args, **kwargs)\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/cli/command.py", line 235, in install\n' +
' retcode = do_install(\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/core.py", line 1734, in do_install\n' +
' ensure_project(\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/core.py", line 578, in ensure_project\n' +
' if project.required_python_version:\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/project.py", line 243, in required_python_version\n' +
' required = self.parsed_pipfile.get("requires", {}).get(\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/project.py", line 509, in parsed_pipfile\n' +
' parsed = self._parse_pipfile(contents)\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/project.py", line 531, in _parse_pipfile\n' +
' return toml.loads(contents)\n' +
' File "/usr/local/Cellar/pipenv/2018.11.26_4/libexec/lib/python3.8/site-packages/pipenv/vendor/toml/decoder.py", line 458, in loads\n' +
' raise TomlDecodeError(str(err), original, pos)\n' +
'toml.decoder.TomlDecodeError: Invalid date or number (line 14 column 1 char 151)\n'
}
Finished execution.
Это мой следующий код, который я пытаюсь загрузить, обратите внимание, что он работает нормально в самой Lambda и требует роли IAM для доступа к двум базам данных DynamoDB:
from __future__ import print_function # Python 2/3 compatibility
import boto3
import json
from decimal import Decimal
from boto3.dynamodb.conditions import Key, Attr
dynamodb = boto3.resource('dynamodb')
RatingTable = dynamodb.Table('RatingsTable')
ChipRatingTable = dynamodb.Table('ChipRatingTable')
def lambda_handler(event, context):
response = RatingTable.scan(
FilterExpression=Attr('id').exists()
)
items = response['Items']
def parseData(items): #Used to turn the DynamoDB scan into a 2D array
parsed_item_list = {}
for item in items:
assetId = str(item.get('assetId'))
rating = int(item.get('rating'))
if assetId not in parsed_item_list:
parsed_item_list[assetId] = []
parsed_item_list[assetId].append(rating)
return parsed_item_list
data = parseData(items)
def updateChipRating(asset, averageRating, RateCount, rating5, rating4, rating3, rating2, rating1) :
updateItem = ChipRatingTable.update_item(
Key={
'id': asset
},
ExpressionAttributeValues={
':a': Decimal(str(averageRating)),
':r': RateCount,
':r5': rating5,
':r4': rating4,
':r3': rating3,
':r2': rating2,
':r1': rating1
},
UpdateExpression="SET ratingCount = :r, averageRating = :a, rating5 = :r5, rating4 = :r4, rating3 = :r3, rating2 = :r2, rating1 = :r1",
ReturnValues="UPDATED_NEW"
)
#Makes the calculation
for x in data :
rating5 = int(0)
rating4 = int(0)
rating3 = int(0)
rating2 = int(0)
rating1 = int(0)
sum = 0
for y in range(len(data[x])) :
sum += data[x][y]
if data[x][y] == 5 :
rating5 = rating5 + 1
elif data[x][y] == 4 :
rating4 = rating4 + 1
elif data[x][y] == 3 :
rating3 = rating3 + 1
elif data[x][y] == 2 :
rating2 = rating2 + 1
elif data[x][y] == 1 :
rating1 = rating1 + 1
print(x)
print(rating5,rating4,rating3,rating2,rating1)
#Average caluclation
average = sum / len(data[x])
averageRating = round(average, 1)
RateCount = len(data[x])
updateChipRating(x, averageRating, RateCount, rating5, rating4, rating3, rating2, rating1)
Любая помощь будет принята с благодарностью! Спасибо!