User talk:Akandoria/Outreachy 2

From Wikidata
Jump to navigation Jump to search

Hi @Akandoria: This looks good! You can count it as complete for Outreachy. One minor comment: the code takes quite a while to run, do you know what's taking so long? It doesn't take too much time, though, so no worries if you can't spot what's causing this.

For task 3, please use Origin and loss of nebula-captured hydrogen envelopes from ‘sub’- to ‘super-Earths’ in the habitable zone of Sun-like stars (Q55967148) - you can find the bibtex for this at [1]. (Also pinging @Pigsonthewing: as co-mentor.) Thanks. Mike Peel (talk) 13:45, 16 April 2022 (UTC)[reply]

Thanks for the feedback, I'll look through the code again as soon as possible! Akandoria (talk) 18:56, 18 April 2022 (UTC)[reply]
@Mike Peel
I went through the code and here are few reasons why the code might be a little slow.
1. The print_information() function also prints all the qualifiers for a given page. If qual_print = 0 (i.e., no qualifier is to be printed), the time for the execution of this function is cut down by almost 10-15 seconds.
2. The whole code had a number of try-except blocks. While looking for qualifiers on the page, these blocks were accessed again, hence increasing execution time. I've replaced them with if-else block wherever it was possible and feasible.
3. Getting further into the code, the .get() function (used in retrieving property_label and claim_dict) take a lot of time. Since get_property_label() is used at a number of places (to get the claim label in print_information(), print_all_qualifiers() and print_qualifier()), it adds to the execution time.

I have made a few changes to my code and it is here. If these improvements are sufficient, I'd proceed further with this as my contribution to task 2, if allowed. I would also be grateful if you could let me know if I was correct or was there something I missed. Your feedback would be helpful in my improvement.Thanks! Akandoria (talk) 18:51, 19 April 2022 (UTC)[reply]
@Akandoria: Thanks, those reasons look good, particularly #3 - since that one will send a request to Wikidata and have to wait for the response, it could be particularly slow. Although it's unavoidable to have this when fetching QIDs, you could cache the property labels, since they're not going to change every time you fetch them (I actually normally just print out the P numbers!) - but that's just a thought for the future, not something you need to implement! Thanks. Mike Peel (talk) 07:57, 22 April 2022 (UTC)[reply]
@Mike Peel Thank you for the feedback! Akandoria (talk) 08:43, 22 April 2022 (UTC)[reply]