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

Task EvolvePokemon should give us a status updates so we know it is working #5570

Merged
merged 5 commits into from
Sep 26, 2016

Conversation

ch1ago
Copy link
Contributor

@ch1ago ch1ago commented Sep 20, 2016

Hey guys,
I have done some local changes on this task so I know how far it is to start evolving my pokemon.

I really like the changes locally and I think they would be good for everybody.
Could anybody take a look and show me how to reduce the logging throughput.

Thanks ❤️

@mention-bot
Copy link

@thejamespinto, thanks for your PR! By analyzing the annotation information on this pull request, we identified @achretien, @alexyaoyang and @novadev94 to be potential reviewers

@alexyaoyang
Copy link
Contributor

@thejamespinto Thanks for the PR! I can see that it will be very helpful! 👍

There's just one small question, how often does it show the status update? If it's too quick (once every second), we gotta limit it so it isn't too spammy.

Copy link
Contributor

@DBa2016 DBa2016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I don't see this as particularly useful, there is no harm in it either.

@ch1ago
Copy link
Contributor Author

ch1ago commented Sep 20, 2016

this is my first PR and I don't know how to filter the log throughput.
I used a sleep(60) locally.
What do you guys suggest?

@ghost
Copy link

ghost commented Sep 20, 2016

Should be a configurable "min_interval", imho.

@alexyaoyang
Copy link
Contributor

@thejamespinto As @acurioustale suggested or you could try using "log_interval" too :)

@Gobberwart
Copy link
Contributor

@thejamespinto using sleep(60) will halt bot execution completely for 60 seconds. We definitely don't want that.

@@ -66,12 +66,15 @@ def work(self):
pokemon_to_be_evolved = pokemon_to_be_evolved + min(candy.quantity / (pokemon.evolution_cost - 1), filtered_dict[pokemon.pokemon_id])

if pokemon_to_be_evolved >= self.min_pokemon_to_be_evolved:
self.logger.info("Checking minimum pokemon to evolve: {}/{}. Hooray!".format(pokemon_to_be_evolved, self.min_pokemon_to_be_evolved))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we REALLY need "Hooray!"?

Also... it's not "checking". It has checked.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, do we even need this? It will immediately start evolving so probably no need for another alert.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just think it's valid to state two versions of the same message so people know if something's wrong

if self.use_lucky_egg:
self._use_lucky_egg()
cache = {}
for pokemon in filtered_list:
if pokemon.can_evolve_now():
self._execute_pokemon_evolve(pokemon, cache)
else:
self.logger.info("Checking minimum pokemon to evolve: {}/{}. Not enough, gotta catch`em all (over and over again)".format(pokemon_to_be_evolved, self.min_pokemon_to_be_evolved))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, do we need humorous status messages? Not a fan.

Suggest "Not enough pokemon for evolve" would do.

@alexyaoyang
Copy link
Contributor

@Gobberwart I agree with you but chill man, cut him some slack, it's his first time contributing to us. 👍

@thejamespinto For examples of limiting throughput, take a look at base_task.py for log_interval or update_live_stats.py for min_interval.

Give some revision to the messages (this bot does lean towards more simplistic logging) + have the throughput reduced and I'll approve your PR 👍

PS: be careful when reducing the throughput so that it doesn't affect the frequency of the pokemon_evolved emit event too, we definitely want all the evolve messages to show :)

@ch1ago
Copy link
Contributor Author

ch1ago commented Sep 22, 2016

@alexyaoyang yeah, thanks for holding my back against that awful bully 😢

JK, we actually interact quite a lot on Slack and I had personally asked him to come and review this PR. 😄

I have made some deeper changes and I'll add the changes in a few 👍
I'm creating a new event named pokemon_evolve_check

@ch1ago
Copy link
Contributor Author

ch1ago commented Sep 22, 2016

@alexyaoyang I've re-patched it.

I wish my python skills were better so I could help out this project further with tests and such.

I have learned this tasks runs repeatedly every second, this extra config will make it so it only runs once every 60 seconds by default, so it doesn't flood the output.

I hope these changes turn out valuable to the community.

Botta catch`em all!

Copy link
Contributor

@alexyaoyang alexyaoyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thejamespinto Great job on the new patch! Left a few comments below. 👍

result_message = ("Gotta catch`em all!", "Gotta evolv`em all!")[has_minimum_to_evolve]
self.emit_event(
'pokemon_evolve_check',
formatted='Checking... Has {has}, needs {needs}. {message}',
Copy link
Contributor

@alexyaoyang alexyaoyang Sep 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be even more simplistic: Evolvable: {has}/{need} will be sufficient. 👍

def _should_run(self):
if not self.evolve_list or self.evolve_list[0] == 'none':
return False
return True

return self.next_update is None or datetime.now() >= self.next_update
Copy link
Contributor

@alexyaoyang alexyaoyang Sep 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the duration that user set now affects how frequent evolve pokemon task is ran. I think only the logging should be reduced, but not the task itself.

For example, if I set min_pokemon_to_be_evolved to 80, there's a chance that I might be evolving more than 80 pokemon due to evolve pokemon not running when I have exactly 80 pokemon.

While evolving more pokemon than the quota is not a big deal for me, I'm not sure if that applies to everyone else. Also if user accidentally sets interval to a huge number, that might be a bigger issue.

Copy link
Contributor Author

@ch1ago ch1ago Sep 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, but I added documentation for this and the way I see this, people should read it so as not to put a huge number there. Also, how many extra pokemon can they catch in 120 seconds?

Having said that, I can still tweak this to a log_interval if you want ¯_(ツ)_/¯

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm yes I see what you mean and I agree with you, but I'd rather not change the behavior of the task since the purpose of this PR is for giving a status update, and not to reduce frequency of evolve task.

Assuming that not all users read the documentation, we are essentially giving users the power/ability to screw up the evolve task.

IMO, if the frequency of evolve task should be reduced, it should be in another PR. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexyaoyang Hey man, chill. It's his first contribution :) :) :)

Just kidding, I agree with you. Keeping this PR to just the log message, not the task itself, would be better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gobberwart Not sure why but I found that very funny. Now people looking at me kinda weird in Starbucks. Thanks!

@@ -153,6 +153,7 @@
"type": "EvolvePokemon",
"config": {
"enabled": false,
"interval": 60,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small issue, but I'm not sure if users will be confused by interval and min_evolve_speed. Perhaps a better name is log_interval?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this number represents how often - in seconds - the task runs. I just realized I should also add that to the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexyaoyang I've added the documentation line. I have been trying this at home for 2 days now and I feel much more comfortable with 120 as the default value because we don't want this message to be spammy 😄

@ch1ago ch1ago changed the title [WIP] Task EvolvePokemon should give us a status updates so we know it is working Task EvolvePokemon should give us a status updates so we know it is working Sep 22, 2016
@alexyaoyang
Copy link
Contributor

@thejamespinto I think you missed a few of my comments :)

@ch1ago
Copy link
Contributor Author

ch1ago commented Sep 23, 2016

@alexyaoyang I did, sorry, I got caught up with the very last comment and I thought it was your only review :)

@alexyaoyang
Copy link
Contributor

@thejamespinto Still waiting on your changes :)

@ch1ago
Copy link
Contributor Author

ch1ago commented Sep 26, 2016

@alexyaoyang I'm gonna release them, just kind of caught up with life and work. :)

@ch1ago
Copy link
Contributor Author

ch1ago commented Sep 26, 2016

@alexyaoyang there we go 😄

'pokemon_evolve_check',
formatted='Evolvable: {has}/{need}',
data={'has': has, 'needs': needs}
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last question, will self._should_log_update always return false with self._compute_next_log_update above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it may return either True or False,
but I have just realized I made it impossible for self.next_log_update to be None. Nice catch. 👍

@alexyaoyang
Copy link
Contributor

alexyaoyang commented Sep 26, 2016

👍 LGTM

Approved with PullApprove

@alexyaoyang alexyaoyang merged commit c53a57e into PokemonGoF:dev Sep 26, 2016
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.

5 participants