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

Dependent calculations within partitioned sample #1870

Closed
toropok opened this issue Nov 6, 2021 · 2 comments
Closed

Dependent calculations within partitioned sample #1870

toropok opened this issue Nov 6, 2021 · 2 comments

Comments

@toropok
Copy link
Contributor

toropok commented Nov 6, 2021

Let's say we need to perform 2 different tests against same sample and have third analysis service which result calculated from those 2 tests.

Currently everything works fine if all test in the same sample (AR). But if you partitioning sample (create sub samples) calculation stops working because analysis in sub sample can't find dependent services from the parent sample.

We've fixed that by adding following code to abstractroutineanalisys.py:


@security.public                                                                                                                                   
def getDependents(self, with_retests=False, recursive=False):                                                                                      
    request = self.getRequest()                                                                                                                    
    **if request.isPartition():                                                                                                                      
        siblings = request.getParentAnalysisRequest().getAnalyses(full_objects=True)                                                               
    else:                                                                                                                                          
        siblings = self.getSiblings(with_retests=with_retests)**                                                                                     
                                                                                                                                                                                                                                              
    dependents = filter(lambda sib: is_dependent(sib), siblings)         

This code just checks if current sample is partition and if so check parent object for siblings.

@ramonski this works for me, but I'm not sure it's best solution for this. If it's ok I will create PR for this or if rework required hint will be appreciated :)

@ramonski
Copy link
Contributor

ramonski commented Nov 6, 2021

Hi @toropok, that looks good to me 👍

It would be cool if you could create a PR for this and maybe write a test for it, maybe here:
https://github.com/senaite/senaite.core/blob/2.x/src/senaite/core/tests/doctests/ARAnalysesFieldWithPartitions.rst

Thanks and regards
Ramon

@toropok
Copy link
Contributor Author

toropok commented Nov 10, 2021

Hi @ramonski

added PR and test

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

No branches or pull requests

2 participants