-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manifest is now artifactless #1530
Conversation
f4b0ace
to
504ac67
Compare
795f281
to
4b59675
Compare
47f0683
to
1304b4b
Compare
0481be2
to
a134f49
Compare
I am taking over this to address the pending comments. @MichalPysik, thanks for the effort! |
a4136fc
to
04266d8
Compare
Objects of the Manifest class no longer store the manifest data (raw binary json data) in a linked artifact. Instead, a new TextField called 'data' was added to the Manifest class itself. closes pulp#1288
ede14f3
to
6ea6a91
Compare
35bd9b7
to
76d6769
Compare
|
||
def init_manifest(self, manifest): | ||
has_initialized_data = manifest.data is not None | ||
if has_initialized_data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if manifest.data:
should suffice, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We check whether data was updated or not when returning from this method. So, we need to assess the state before updating via has_initialized_data
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has_initialized_data is not needed. you can check directly if manifest.data ( because there will whether be data or be none)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to this, I generally do not understand why you are json-loading data and parse it again for labels?
If manifest.data is not none it means on upload/sync it was already parsed and necessary data populated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has_initialized_data is not needed. you can check directly if manifest.data ( because there will whether be data or be none)
Actually, manifest.data
is updated along the way in the code; we want to assess the initial state of the things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean updated? manifest.data is its payload, it does not change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of lines below the if condition, we update the data
attribute of the manifest
object:
manifest_data, raw_bytes_data = get_content_data(manifest_artifact)
manifest.data = raw_bytes_data.decode("utf-8")
When returning from the method, we check if the object was updated (not has_initialized_data
), if so, we run the DB migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh i see that now. But if has_initialized_data
is true then there is no need to init_labels, annotations etc. so you need to update the logic there
if has_initialized_data: | ||
manifest_data = json.loads(manifest.data) | ||
else: | ||
manifest_artifact = manifest._artifacts.get() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace with .first(), artifact might be missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DoesNotExist
is raised when there is no artifact. This is caught by with suppress(ObjectDoesNotExist, JSONDecodeError)
.
d36f8a0
to
e499471
Compare
|
||
def init_manifest(self, manifest): | ||
has_initialized_data = manifest.data is not None | ||
if has_initialized_data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has_initialized_data is not needed. you can check directly if manifest.data ( because there will whether be data or be none)
|
||
def init_manifest(self, manifest): | ||
has_initialized_data = manifest.data is not None | ||
if has_initialized_data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to this, I generally do not understand why you are json-loading data and parse it again for labels?
If manifest.data is not none it means on upload/sync it was already parsed and necessary data populated.
@@ -28,47 +31,40 @@ class Command(BaseCommand): | |||
stored inside artifacts. | |||
|
|||
This command reads data from the storage backend and populates the 'annotations', 'labels', | |||
'is_bootable', and 'is_flatpak' fields on the Manifest model. | |||
'is_bootable', and 'is_flatpak' fields on the Manifest model. Note that the Redis cache will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+
moves manifest artifact into DB
@@ -20,7 +21,7 @@ class Migration(migrations.Migration): | |||
migrations.AddField( | |||
model_name="manifest", | |||
name="data", | |||
field=models.TextField(default=""), | |||
field=models.TextField(null=True), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should update respectively your queries from data=None
to data__isnull=True/False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the work, few comments that need addressing, approving ahead.
ec107c3
to
02e55c7
Compare
b0c9b12
to
b16c6ff
Compare
b16c6ff
to
067f292
Compare
Great job @lubosmj! Love to see this getting finally merged! |
Objects of the Manifest class no longer store the manifest data (raw text json data) in a linked artifact. Instead, a new TextField called 'data' was added to the Manifest class itself.
closes #1288