Skip to content

Commit

Permalink
[aws][fix] AWS Artifacts are referenced by arn not name (#1630)
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias committed Jun 2, 2023
1 parent b04f19a commit a59420f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
8 changes: 5 additions & 3 deletions plugins/aws/resoto_plugin_aws/resource/sagemaker.py
Expand Up @@ -827,9 +827,11 @@ def called_collect_apis(cls) -> List[AwsApiSpec]:

@classmethod
def collect(cls: Type[AwsResource], json: List[Json], builder: GraphBuilder) -> None:
# TODO don't collect Apps with status "deleted"
for app in json:
if app["UserProfileName"]:
# Don't collect Apps that are deleted
if app.get("AppStatus") == "Deleted":
continue
elif app["UserProfileName"]:
app_description = builder.client.get(
service_name,
"describe-app",
Expand Down Expand Up @@ -1922,7 +1924,7 @@ class AwsSagemakerArtifact(AwsResource):
}
api_spec: ClassVar[AwsApiSpec] = AwsApiSpec(service_name, "list-artifacts", "ArtifactSummaries")
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("ArtifactName"),
"id": S("ArtifactArn"),
"name": S("ArtifactName"),
"ctime": S("CreationTime"),
"mtime": S("LastModifiedTime"),
Expand Down
4 changes: 2 additions & 2 deletions plugins/aws/test/collector_test.py
Expand Up @@ -31,8 +31,8 @@ def count_kind(clazz: Type[AwsResource]) -> int:
# make sure all threads have been joined
assert len(threading.enumerate()) == 1
# ensure the correct number of nodes and edges
assert count_kind(AwsResource) == 204
assert len(account_collector.graph.edges) == 476
assert count_kind(AwsResource) == 205
assert len(account_collector.graph.edges) == 477
assert len(account_collector.graph.deferred_edges) == 2


Expand Down
@@ -0,0 +1,25 @@
{
"ArtifactArn": "arn:aws:sagemaker:us-east-1:test:artifact/2",
"Source": {
"SourceUri": "s3://my_account_alias-sagemaker/sagemaker/prediction/train/linear_train.data",
"SourceTypes": []
},
"ArtifactType": "DataSet",
"Properties": {},
"CreationTime": "2021-08-07T13:44:46Z",
"CreatedBy": {},
"LastModifiedTime": "2021-08-07T13:44:46Z",
"LastModifiedBy": {},
"LineageGroupArn": "arn:aws-cn:sagemaker:us-east-1:test:lineage-group/sagemaker-default-lineage-group",
"ResponseMetadata": {
"RequestId": "8340bd3f-0bf6-40e9-a93e-1940de09ce2c",
"HTTPStatusCode": 200,
"HTTPHeaders": {
"x-amzn-requestid": "8340bd3f-0bf6-40e9-a93e-1940de09ce2c",
"content-type": "application/x-amz-json-1.1",
"content-length": "487",
"date": "Thu, 01 Jun 2023 17:28:46 GMT"
},
"RetryAttempts": 0
}
}
10 changes: 10 additions & 0 deletions plugins/aws/test/resources/files/sagemaker/list-artifacts.json
Expand Up @@ -15,6 +15,16 @@
"ArtifactType": "string",
"CreationTime": "2015-01-01T00:00:00Z",
"LastModifiedTime": "2015-01-01T00:00:00Z"
},
{
"ArtifactArn": "arn:aws:sagemaker:us-east-1:test:artifact/2",
"Source": {
"SourceUri": "s3://my_account_alias-sagemaker/sagemaker/prediction/train/linear_train.data",
"SourceTypes": []
},
"ArtifactType": "DataSet",
"CreationTime": "2021-08-07T13:44:46Z",
"LastModifiedTime": "2021-08-07T13:44:46Z"
}
],
"NextToken": "string"
Expand Down
2 changes: 1 addition & 1 deletion plugins/aws/test/resources/sagemaker_test.py
Expand Up @@ -110,7 +110,7 @@ def test_image() -> None:

def test_artifact() -> None:
first, builder = round_trip_for(AwsSagemakerArtifact)
assert len(builder.resources_of(AwsSagemakerArtifact)) == 1
assert len(builder.resources_of(AwsSagemakerArtifact)) == 2


def test_user_profile() -> None:
Expand Down

0 comments on commit a59420f

Please sign in to comment.