[Toaster] [PATCH 1/5] toaster: implement API to get full list of deps
Michael Wood
michael.g.wood at intel.com
Fri Oct 9 10:34:26 PDT 2015
On 07/10/15 17:17, Michael Wood wrote:
> On 01/10/15 14:56, Ed Bartosh wrote:
>> Implemented Layer_Version.get_alldeps API to recursively get
>> full list of dependencies for the layer. Dependencies that are
>> already in the project are filtered out from the result.
>> Result list of Layer_Version objects is sorted by layer name
>> for UI to look consistent.
>>
>> This API is going to be used to show amount and list of
>> dependencies for the layer in the list of compatible layers
>> for the project.
>>
>> Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
>> ---
>> bitbake/lib/toaster/orm/models.py | 19 +++++++++++++++++++
>> 1 file changed, 19 insertions(+)
>>
>> diff --git a/bitbake/lib/toaster/orm/models.py
>> b/bitbake/lib/toaster/orm/models.py
>> index 5aed158..c5e256f 100644
>> --- a/bitbake/lib/toaster/orm/models.py
>> +++ b/bitbake/lib/toaster/orm/models.py
>> @@ -1177,6 +1177,25 @@ class Layer_Version(models.Model):
>> def get_detailspage_url(self, project_id):
>> return reverse('layerdetails', args=(project_id, self.pk))
>> + def get_alldeps(self, project_id):
>> + """Get full list of unique layer dependencies."""
>> + def gen_layerdeps(lver, project):
>> + for ldep in lver.dependencies.all():
>> + yield ldep.depends_on
>> + # get next level of deps recursively calling
>> gen_layerdeps
>> + for subdep in gen_layerdeps(ldep.depends_on, project):
>> + yield subdep
>> +
>> + project = Project.objects.get(pk=project_id)
>> + result = []
>> + projectlvers = [player.layercommit for player in
>> project.projectlayer_set.all()]
>> + for dep in gen_layerdeps(self, project):
>> + # filter out duplicates and layers already belonging to
>> the project
>> + if dep not in result + projectlvers:
>> + result.append(dep)
>> +
>> + return sorted(result, key=lambda x: x.layer.name)
>> +
>> def __unicode__(self):
>> return "%d %s (VCS %s, Project %s)" % (self.pk,
>> str(self.layer), self.get_vcs_reference(), self.build.project if
>> self.build is not None else "No project")
>
> Sorry for too late review, spotted a regression.
>
> This will cause a regression in the layerdetails page, the API should
> not be filtering out any layer dependencies that are already added to
> the project.
>
> - This is already done in the client side logic which is why the
> context has projectlayers in it
> - The layerdetails page is supposed to list the dependencies for the
> layer regardless as to whether they have been added or not.
>
> (btw you can do something like this
> self.dependencies.exclude(depends_on__in=prj.get_project_layer_versions())
> if you want a list of the layers it depends on but are not added,
> rather than iterate through these and create a new list)
>
> As it's been submitted would you be able to write a patch on top to
> fix this.
>
> Michael
Ah so I might be wrong here, later on in the thread Belen mentioned:
On 01/10/15 16:51, Barros Pena, Belen wrote:
> So both the 'compatible layers' table and the layer details page should
> show the fist-level dependencies for a layer
Which contradicts the bug I was looking at
https://bugzilla.yoctoproject.org/show_bug.cgi?id=8042
I'll push that bug to you Belen so you can decide what to do.
Thanks,
Michael
More information about the toaster
mailing list