Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

inconsistent fetch of extra data in models.py#TestRun::__setattr__ #36

Open
jscook2345 opened this issue Apr 22, 2020 · 2 comments
Open

Comments

@jscook2345
Copy link
Contributor

I noticed a bunch of extra http GETs in the debug log when I was calling Squad().testruns().

I see in the code we specifically are fetching it during attribute set here:

def __setattr__(self, attr, value):

Why are we fetching the environment data each time we build a TestRun object? That seems to be the only time it's done here and seems inconsistent.

Below is what it looks like after it's been fetched. Note that all the other url-like fields are still urls, but environment is not.

Thanks!

{'url': 'https://qa-reports.linaro.org/api/testruns/2549856/',
 'id': 2549856,
 'metadata_file': 'https://qa-reports.linaro.org/api/testruns/2549856/metadata_file/',
 'log_file': 'https://qa-reports.linaro.org/api/testruns/2549856/log_file/',
 'created_at': '2020-04-08T05:10:17.551320Z',
 'completed': True,
 'datetime': '2020-04-08T05:10:17.551087Z',
 'build_url': None,
 'job_id': 'i386-745',
 'job_status': None,
 'job_url': None,
 'resubmit_url': None,
 'data_processed': True,
 'status_recorded': True,
 'build': 'https://qa-reports.linaro.org/api/builds/34782/',
 'environment': <squad_client.core.models.Environment object at 0x1039a3310>}
@jscook2345
Copy link
Contributor Author

Related: Linaro/squad#704

@chaws
Copy link
Collaborator

chaws commented May 14, 2020

Sorry for delay. The answer is that I made a small workaround when fetching TestRun objects: https://github.com/Linaro/squad-client/blob/master/squad_client/core/models.py#L340

I wanted to make a more generic __setattr__ to fetch nested objects automagically, but was afraid of hitting a recursion condition.

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

No branches or pull requests

2 participants