Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

fix cli tool #225

Merged
merged 1 commit into from
Nov 19, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def request_update_proj(self, update_pro_info, list_file_s3, gen_id,task_id):
})
print("[DEBUG] Log Request Update Upload : {}\n".format(info))

# update_project_output = requests.post('https://yf6ayuvru1.execute-api.us-east-2.amazonaws.com/dev/projects/upload_update',json=info)
update_project_output = self.invokeUploadUpdateFunc(info)
print("[DEBUG] Request Update Upload: {}\n".format(update_project_output))

Expand Down
3 changes: 3 additions & 0 deletions daita-app/core-service/core_service_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ Resources:
Environment:
Variables:
T_GEN_DAITA_UPLOAD_TOKEN: !Ref TableGenerateDaitaUploadToken
LAMBDA_UPDATE_CHECK: !Ref ProjectUpdateCheckFunction
CreatePresignUrlFunction:
Type: AWS::Serverless::Function
Properties:
Expand All @@ -501,6 +502,8 @@ Resources:
Variables:
T_GEN_DAITA_UPLOAD_TOKEN: !Ref TableGenerateDaitaUploadToken
TABLE_PROJECT_SUMMARY: !Ref TableProjectSumName
LAMBDA_UPLOAD_UPDATE: !Ref FuncProjectUploadUpdateArn
LAMBDA_UPLOAD_CHECK: !Ref ProjectUpdateCheckFunction
GenertateTokenUploadProjectFunction:
Type: AWS::Serverless::Function
Properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
def invokeUploadUpdateFunc(info):
lambdaInvokeClient = boto3.client('lambda')
lambdaInvokeReq = lambdaInvokeClient.invoke(
FunctionName='staging-project-upload-check',
FunctionName=os.environ['LAMBDA_UPDATE_CHECK'],
Payload=json.dumps({'body': info}),
InvocationType="RequestResponse",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
def invokeUploadUpdateFunc(info):
lambdaInvokeClient = boto3.client('lambda')
lambdaInvokeReq = lambdaInvokeClient.invoke(
FunctionName='staging-project-upload-update',
FunctionName=os.environ['LAMBDA_UPLOAD_UPDATE'],
Payload=json.dumps({'body': info}),
InvocationType="RequestResponse",
)
Expand All @@ -30,7 +30,7 @@ def invokeUploadUpdateFunc(info):
def invokeUploadCheck(info):
lambdaInvokeClient = boto3.client('lambda')
lambdaInvokeReq = lambdaInvokeClient.invoke(
FunctionName='staging-project-upload-check',
FunctionName=os.environ['LAMBDA_UPLOAD_CHECK'],
Payload=json.dumps({'body': info}),
InvocationType="RequestResponse",
)
Expand Down Expand Up @@ -83,7 +83,7 @@ def lambda_handler(event, context):
error=True)

countSumAllPrj = int(prjSumAllResp['count'])
if countSumAllPrj + len(filenames) >= 1000:
if countSumAllPrj + len(filenames) >= 5000:
return generate_response(
message="Limited",
data={},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,27 @@ def delete_reference_images(db_resource,identity_id,project_id,deletedfilename):
)
with table_project.batch_writer() as batch:
for each in queryResponse['Items']:
reference_images = each['reference_images']
new_reference_image = {}
for k , v in reference_images.items():
if not deletedfilename in v :
new_reference_image[k] = v

resp = table_project.update_item(
Key={
'project_name': each['project_name'],
'identity_id': identity_id ,
},
ExpressionAttributeNames= {
'#r': 'reference_images',
},
ExpressionAttributeValues = {
':r': new_reference_image
},
UpdateExpression = 'SET #r = :r'
)
print(resp)
if 'reference_images' in each:
reference_images = each['reference_images']
new_reference_image = {}
for k , v in reference_images.items():
if not deletedfilename in v :
new_reference_image[k] = v

resp = table_project.update_item(
Key={
'project_name': each['project_name'],
'identity_id': identity_id ,
},
ExpressionAttributeNames= {
'#r': 'reference_images',
},
ExpressionAttributeValues = {
':r': new_reference_image
},
UpdateExpression = 'SET #r = :r'
)
print(resp)


def lambda_handler(event, context):
Expand Down Expand Up @@ -116,11 +117,12 @@ def lambda_handler(event, context):
'project_id': project_id,
'filename': request['filename']
})
print(f'log debug delete {item}')
try:
delete_reference_images(db_resource=db_resource,identity_id=identity_id,project_id=project_id,deletedfilename=request['filename'])
except Exception as e:
print(e)
if ('healthcheck_id' in item['Item']) and (not item['Item']['healthcheck_id'] is None or isinstance(item['Item']['healthcheck_id'],str)):
if 'Item' in item and ('healthcheck_id' in item['Item']) and (not item['Item']['healthcheck_id'] is None or isinstance(item['Item']['healthcheck_id'],str)):
delete_image_healthycheck_info(db_resource=db_resource,project_id=project_id,healthcheck_id=item['Item']['healthcheck_id'])

table.delete_item(Key={
Expand Down