Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Add ResolveContentFutures() #321

Merged
merged 1 commit into from
Apr 2, 2019
Merged

Conversation

ipanova
Copy link
Member

@ipanova ipanova commented Mar 7, 2019

No description provided.

@pep8speaks
Copy link

pep8speaks commented Mar 7, 2019

Hello @ipanova! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-04-02 10:32:52 UTC

pb.increment()

with ProgressBar(message='Creating Download requests for Tags') as pb:
# could use total of len(tag_list) but if schema1 is present done will be < total
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is just creating download requests, even schema1 tags will be downloaded the number will be len(tag_list)

pb.increment()

with ProgressBar(message='Parsing SchemaV2 Tags') as pb:
while to_download:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you go with this pattern rather than asyncio.as_completed(to_download)? This seems fine, just curious.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think there was any particular reason, i can change it to as_completed for the sake of readability

@ipanova ipanova force-pushed the docker-futures-2 branch 7 times, most recently from b1520c3 to 990817f Compare March 14, 2019 18:39
@ipanova ipanova force-pushed the docker-futures-2 branch 5 times, most recently from 8f49e99 to 5f88d68 Compare March 26, 2019 16:22
@dkliban
Copy link
Member

dkliban commented Mar 26, 2019

@ipanova I fixed some things, but now your branch needs to be rebased.

@ipanova ipanova force-pushed the docker-futures-2 branch 2 times, most recently from a559955 to 0509280 Compare March 27, 2019 10:35
@@ -1,11 +1,12 @@
import json
import logging
import asyncio
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: move to alphabetical order

raw = content_file.read()
results.artifact_attributes['file'] = results.path
try:
saved_artifact = Artifact(**results.artifact_attributes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line should be moved out of the try/except.

pb.increment()

else:
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment here? It's sort of surprising that no mediatype means schema1.

raise Exception(msg)

async def create_and_process_tagged_manifest_list(self, tag_dc, manifest_list_data):
def create_and_process_tagged_manifest_list(self, tag_dc, manifest_list_data):
"""
Create a ManifestList and nested ImageManifests from the Tag artifact.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer creates nested ImageManifests


return list_dc

def create_and_process_tagged_manifest(self, tag_dc, manifest_data):
"""
Create a Manifest and nested ManifestBlobs from the Tag artifact.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer creates nested ManifestBlobs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, this is what I meant by "process", so maybe the name of the function should be changed too.

try:
thru.save()
except IntegrityError:
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment here why IntegrityError is ok

ResolveContentFutures,
QueryExistingArtifacts,
QueryExistingContents,
ContentSaver,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alpha order pls

@asmacdo
Copy link
Contributor

asmacdo commented Mar 27, 2019

Took a first pass, nothing but nits, looking great! I'll do a more thorough review with some manual testing after you make the changes we discussed earlier today.

@ipanova ipanova force-pushed the docker-futures-2 branch 4 times, most recently from e10b2af to 8ec95d3 Compare April 1, 2019 15:45
Copy link
Contributor

@asmacdo asmacdo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not hand tested, but if travis is passing, I am ok to merge. I would rather merge now (even if there are problems) than hand test a lot-- this will help us to build more helpful functional tests and get the current version out to the community.



class TagListStage(Stage):
class DockerFirstStage(Stage):
"""
The first stage of a pulp_docker sync pipeline.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be good to add a second paragraph that explains the steps that take place since this is an unusually heavy first stage.

man_dcs = {}
total_blobs = []

with ProgressBar(message='Downloading tag list for the repo', total=1) as pb:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/for the repo//

to_download.append(downloader.run(extra_data={'headers': V2_ACCEPT_HEADERS}))
pb.increment()

pb1 = ProgressBar(message='Parsed SchemaV2 Tags', state='running')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Parsed/Parsing/ to be consistent with the others.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parsed_s2_tags if we plan to do s1. If not parsed_tags.

pb1 = ProgressBar(message='Parsed SchemaV2 Tags', state='running')
pb2 = ProgressBar(message='Parsing Manifest List Tags', state='running')
pb3 = ProgressBar(message='Parsing Manifests Tags', state='running')
global pb4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do some but not others need to be global? Perhaps a comment would be helpful.

await self.put(tag_dc)
pb1.increment()
else:
# in case it a schema1 continue to the next tag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a DEBUG log message would be good here also.

pb3 = ProgressBar(message='Parsing Manifests Tags', state='running')
global pb4
pb4 = ProgressBar(message='Parsing Blobs', state='running')
pb5 = ProgressBar(message='Parsing Manifests', state='running')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how you did these progress bars. It nicely separates the workflow we need to follow from the workflow the user would want to see.

pb4 = ProgressBar(message='Parsing Blobs', state='running')
pb5 = ProgressBar(message='Parsing Manifests', state='running')
while to_download:
done, to_download = await asyncio.wait(to_download,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you use the as_completed loop below, it would be more readable if both loops are the same. (Ignore if this works better for some reason)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed this to as_completed, i also moved the saving of the Artifact after we check the mediatype, so we do not save Artifact of schema1

async def create_and_process_tagged_manifest_list(self, tag_dc, manifest_list_data):
"""
Create a ManifestList and nested ImageManifests from the Tag artifact.
Create a ManifestList from the Tag artifact.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/from the Tag artifact//. Since we don't read the artifact here.

"""
Create a pending manifest from manifest data in a ManifestList.
Create a Manifest from manifest data in a ManifestList.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More generally, since this data is coming in, it doesn't matter where its from to this code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wanted to stress that this manifest is not tagged and when creating it, we rely on some information provided from ML

self.relate_manifest_to_list(dc)
elif dc.extra_data.get('blob_relation'):
self.relate_blob(dc)
elif dc.extra_data.get('config_relation'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can a single unit have relations to multiple types of other objects? If so, I think these need to be ifs, not elifs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my thinking was to create a singe relation type per unit, so elif is correct here

to_download.append(downloader.run(extra_data={'headers': V2_ACCEPT_HEADERS}))
pb.increment()

pb1 = ProgressBar(message='Parsed SchemaV2 Tags', state='running')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parsed_s2_tags if we plan to do s1. If not parsed_tags.

pb.increment()

pb1 = ProgressBar(message='Parsed SchemaV2 Tags', state='running')
pb2 = ProgressBar(message='Parsing Manifest List Tags', state='running')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parsed_manifest_list_tags


pb1 = ProgressBar(message='Parsed SchemaV2 Tags', state='running')
pb2 = ProgressBar(message='Parsing Manifest List Tags', state='running')
pb3 = ProgressBar(message='Parsing Manifests Tags', state='running')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parsed_manifest_tags

@ipanova ipanova merged commit 34a7c62 into pulp:master Apr 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants