Skip to content
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

Merged
merged 2 commits into from
May 6, 2024
Merged

Conversation

MichalPysik
Copy link
Member

@MichalPysik MichalPysik commented Mar 1, 2024

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

@MichalPysik MichalPysik force-pushed the artifactless_manifest branch 2 times, most recently from f4b0ace to 504ac67 Compare March 4, 2024 12:42
@MichalPysik MichalPysik force-pushed the artifactless_manifest branch 15 times, most recently from 795f281 to 4b59675 Compare March 11, 2024 12:52
@MichalPysik MichalPysik force-pushed the artifactless_manifest branch 5 times, most recently from 47f0683 to 1304b4b Compare March 12, 2024 15:54
@MichalPysik MichalPysik force-pushed the artifactless_manifest branch 7 times, most recently from 0481be2 to a134f49 Compare March 25, 2024 10:36
@lubosmj lubosmj marked this pull request as draft May 2, 2024 07:59
@lubosmj
Copy link
Member

lubosmj commented May 2, 2024

I am taking over this to address the pending comments. @MichalPysik, thanks for the effort!

@lubosmj lubosmj self-assigned this May 2, 2024
@lubosmj lubosmj force-pushed the artifactless_manifest branch from a4136fc to 04266d8 Compare May 2, 2024 12:26
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
@git-hyagi git-hyagi force-pushed the artifactless_manifest branch from ede14f3 to 6ea6a91 Compare May 2, 2024 18:16
@lubosmj lubosmj force-pushed the artifactless_manifest branch 2 times, most recently from 35bd9b7 to 76d6769 Compare May 3, 2024 14:38

def init_manifest(self, manifest):
has_initialized_data = manifest.data is not None
if has_initialized_data:
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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)

Copy link
Member

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.

Copy link
Member

@lubosmj lubosmj May 6, 2024

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.

Copy link
Member

@ipanova ipanova May 6, 2024

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

Copy link
Member

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.

Copy link
Member

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()
Copy link
Member

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

Copy link
Member

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).

@lubosmj lubosmj force-pushed the artifactless_manifest branch 2 times, most recently from d36f8a0 to e499471 Compare May 3, 2024 18:04
@lubosmj lubosmj marked this pull request as ready for review May 3, 2024 18:05

def init_manifest(self, manifest):
has_initialized_data = manifest.data is not None
if has_initialized_data:
Copy link
Member

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:
Copy link
Member

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
Copy link
Member

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),
Copy link
Member

@ipanova ipanova May 6, 2024

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

Copy link
Member

@ipanova ipanova left a 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.

@lubosmj lubosmj force-pushed the artifactless_manifest branch 3 times, most recently from ec107c3 to 02e55c7 Compare May 6, 2024 11:27
@lubosmj lubosmj marked this pull request as draft May 6, 2024 12:15
@lubosmj lubosmj force-pushed the artifactless_manifest branch 2 times, most recently from b0c9b12 to b16c6ff Compare May 6, 2024 12:45
@lubosmj lubosmj force-pushed the artifactless_manifest branch from b16c6ff to 067f292 Compare May 6, 2024 12:47
@lubosmj lubosmj marked this pull request as ready for review May 6, 2024 12:50
@lubosmj lubosmj merged commit 13bf171 into pulp:main May 6, 2024
16 checks passed
@MichalPysik
Copy link
Member Author

Great job @lubosmj! Love to see this getting finally merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make Manifest content type artifactless
3 participants