internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: alpa-projects/alpa

Issue:
Specify Ray instance port
**System information**
- Alpa version: 0.2.3
- Are you willing to contribute it (Yes/No): Probably not qualified

**Describe the new feature and the current behavior/state**
Currently, Apla is fixed to connecting to port 6379 of a Ray instance. This limits the number of users in a node with multiple GPUs to 1 (e.g., if there are 4 GPUs, 2 users cannot use 2 GPUs each). While it is possible to start a Ray instance listening on a different port, Alpa seems to use 6379 by default, but no 2 Ray instances can listen on the same port. Would it be possible to have this port specified in a configuration file or in the arguments, so that a 2nd user could start a Ray instance on a port different than 6379?


Discussion:
yeah, should be an easy change to make.
let me look into this and propose a quick PR.
thanks for the feedback!

Resolving patch:
diff --git a/alpa/api.py b/alpa/api.py
--- a/alpa/api.py
+++ b/alpa/api.py
@@ -23,6 +23,7 @@
 
 
 def init(cluster: str = "ray",
+         cluster_address: Optional[str] = None,
          num_nodes: Optional[int] = None,
          num_devices_per_node: Optional[int] = None,
          namespace: Optional[str] = "alpa_default_space"):
@@ -40,6 +41,12 @@ def init(cluster: str = "ray",
         Possible choices: {"local", "ray"}.
         "local" means using all local devices on a single node.
         "ray" means using all devices in a ray cluster.
+      cluster_address: Address of the distributed cluster.
+        If cluster is "ray", this parameter can be used to specify a different
+          address that will be used to initialize the ray cluster.
+          E.g., "ray://123.45.67.89:10001". If not specified, "auto" will be
+          used instead.
+        Ignored if cluster is "local".
       num_nodes: The number of nodes.
       num_devices_per_node: The number of devices per node.
     """
@@ -49,7 +56,8 @@ def init(cluster: str = "ray",
         return
     is_initialized = True
 
-    init_global_cluster(cluster, num_nodes, num_devices_per_node, namespace)
+    init_global_cluster(cluster, cluster_address, num_nodes,
+                        num_devices_per_node, namespace)
 
 
 def shutdown():
diff --git a/alpa/device_mesh.py b/alpa/device_mesh.py
--- a/alpa/device_mesh.py
+++ b/alpa/device_mesh.py
@@ -2304,6 +2304,7 @@ def profile_all(self, *args, **kwargs):
 
 
 def init_global_cluster(cluster: str,
+                        cluster_address: Optional[str] = None,
                         num_nodes: Optional[int] = None,
                         num_devices_per_node: Optional[int] = None,
                         namespace: Optional[str] = None):
@@ -2313,7 +2314,8 @@ def init_global_cluster(cluster: str,
         global_physical_mesh = LocalPhysicalDeviceMesh()
     elif cluster == "ray":
         if not ray.is_initialized():
-            ray.init(address="auto",
+            ray_addr = cluster_address if cluster_address else "auto"
+            ray.init(address=ray_addr,
                      ignore_reinit_error=True,
                      namespace=namespace)
         update_jax_platform("cpu")


Test patch:
Repository: PokemonGoF/PokemonGo-Bot

Issue:
"Exchange" not functioning
Confirming that low CP pokemon are not being exchanged at all, using the -c 200 command. 

It is doing the same thing without the -c command as well. 

Even pokemon with CP < 100 are not being exchanged. The Debug log says they are being exchanged, but they are not.



Discussion:

Resolving patch:
diff --git a/bot.py b/bot.py
--- a/bot.py
+++ b/bot.py
@@ -206,8 +206,15 @@ def getPlayerInfo(self):
 
                                     nextlvlxp = (int(playerdata['next_level_xp']) - int(playerdata['experience']))
 
-                                    print('[#] -- Level: ' + str(playerdata['level']))
-                                    print('[#] -- Experience: ' + str(playerdata['experience']))
-                                    print('[#] -- Experience until next level: ' + str(nextlvlxp))
-                                    print('[#] -- Pokemon Captured: ' + str(playerdata['pokemons_captured']))
-                                    print('[#] -- Pokestops Visited: ' + str(playerdata['poke_stop_visits']))
+                                    if 'level' in playerdata:
+                                        print('[#] -- Level: ' + str(playerdata['level']))
+
+                                    if 'experience' in playerdata:
+                                        print('[#] -- Experience: ' + str(playerdata['experience']))
+                                        print('[#] -- Experience until next level: ' + str(nextlvlxp))
+
+                                    if 'pokemons_captured' in playerdata:
+                                        print('[#] -- Pokemon Captured: ' + str(playerdata['pokemons_captured']))
+
+                                    if 'poke_stop_visits' in playerdata:
+                                        print('[#] -- Pokestops Visited: ' + str(playerdata['poke_stop_visits']))
diff --git a/cell_workers/pokemon_catch_worker.py b/cell_workers/pokemon_catch_worker.py
--- a/cell_workers/pokemon_catch_worker.py
+++ b/cell_workers/pokemon_catch_worker.py
@@ -103,6 +103,7 @@ def _execute_pokemon_transfer(self, value, pokemon):
     		print('Exchanged successfuly!{}'.format(response_dict))
 
     def transfer_pokemon(self, pid):
+        self.api.release_pokemon(pokemon_id=pid)
         response_dict = self.api.call()
         print('Exchanged successfuly!')
 


Test patch:
Repository: PokemonGoF/PokemonGo-Bot

Issue:
unicodeDEcodeError
This error showed up with the latest release.   It seems to be an issue with certain european alphabet characters öäå

File "/usr/lib/python2.7/codecs.py", line 351, in write
    data, consumed = self.encode(object, self.errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 33: ordinal not in range(128)



Discussion:
Same here

```
data, consumed = self.encode(object, self.errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 43: ordinal not in range(128)


same here.

```


Resolving patch:
diff --git a/bot.py b/bot.py
--- a/bot.py
+++ b/bot.py
@@ -201,7 +201,7 @@ def _set_starting_position(self):
         self.position = self._get_pos_by_name(self.config.location)
         self.api.set_position(*self.position)
 
-        print('[x] Address found: ' + self.config.location)
+        print('[x] Address found: ' + self.config.location.decode('utf-8'))
         print('[x] Position in-game set as: ' + str(self.position))
 
         if self.config.test:


Test patch:
Repository: PokemonGoF/PokemonGo-Bot

Issue:
Fixes UnicodeEncodeError on initial location
Short Description: 
When initial location has special characters the current version crashes with a UnicodeEncodeError: 'ascii' codec can't encode character u'\xe7' in position 14: ordinal not in range(128).

Fixes:
- UnicodeEncodeError when initial location has special characters, e.g. "Paço"



Discussion:
@vieira how well you know Python? I think better solution is to add the utf-8 shebang to all our source files. If you don't know about it, I can merge this and do the proper fix to avoid any more utf-8 problems later.

@douglascamata I might be wrong but I think that will only affect the encoding of the source code itself and any static strings defined there but not what comes in the wire as binary.

I tried putting

```
#!/usr/bin/env python
# -*- coding: utf-8 -*-
```

but it did not solve the problem. Is this what you mean?

lgtm.

Please rebase your changes so we can merge it.  Thanks!


Resolving patch:
diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py
--- a/pokemongo_bot/__init__.py
+++ b/pokemongo_bot/__init__.py
@@ -205,7 +205,7 @@ def _set_starting_position(self):
         self.position = self._get_pos_by_name(self.config.location)
         self.api.set_position(*self.position)
         print('')
-        print('[x] Address found: {}'.format(self.config.location.decode('utf-8')))
+        print(u'[x] Address found: {}'.format(self.config.location.decode('utf-8')))
         print('[x] Position in-game set as: {}'.format(self.position))
         print('')
 


Test patch:
Repository: PokemonGoF/PokemonGo-Bot

Issue:
Multiple items from pokestops
### Expected Behavior

Display the correct amount of items when a multiple of the same item is given from a pokestop.
### Actual Behavior

```
- Loot:
- 50 xp
- 1x Revive
- 1x Potion
```
### Steps to Reproduce

Run the bot wait for it to spin a pokestop and no matter how many multiple items the stop may give you the bot always says 1x (Item).



Discussion:
#236 Thanks, was too lazy to edit my post

@Klohto No Problem. Saw you're issues a few minutes before I posted this however, with it being a few hours since you posted it I decided to create a new one with more detail. If you want to you can close the issue or just copy and paste this issue into yours.

Wrong button.... _sigh_


Resolving patch:
diff --git a/pokemongo_bot/cell_workers/seen_fort_worker.py b/pokemongo_bot/cell_workers/seen_fort_worker.py
--- a/pokemongo_bot/cell_workers/seen_fort_worker.py
+++ b/pokemongo_bot/cell_workers/seen_fort_worker.py
@@ -71,7 +71,7 @@ def work(self):
                     for item_id, item_count in tmp_count_items.iteritems():
                         item_id = str(item_id)
                         item_name = self.item_list[item_id]
-                        print_green("[+] " + str(item['item_count']) + "x " + item_name)
+                        print_green("[+] " + str(item_count) + "x " + item_name)
                 else:
                     print_yellow("[#] Nothing found.")
 


Test patch:
Repository: PokemonGoF/PokemonGo-Bot

Issue:
Bot unnecessarily walks to center of Pokestops
This issue may also increase detectability since it's unlikely that users would walk to the exact center of every stop they visit.

Also, most stops are spinnable from the road or other more accessible place. Once we start following roads, this will need fixed.
### Expected Behavior

Bot should walk to anywhere within the range of the stop.
### Actual Behavior

Bot walks to exactly the center of a stop.
### Steps to Reproduce

Run the bot and observe its path.



Discussion:

Resolving patch:
diff --git a/pokemongo_bot/cell_workers/move_to_fort_worker.py b/pokemongo_bot/cell_workers/move_to_fort_worker.py
--- a/pokemongo_bot/cell_workers/move_to_fort_worker.py
+++ b/pokemongo_bot/cell_workers/move_to_fort_worker.py
@@ -1,4 +1,4 @@
-from utils import distance, format_dist
+from utils import distance, format_dist, i2f
 from pokemongo_bot.human_behaviour import sleep
 from pokemongo_bot import logger
 from pokemongo_bot.step_walker import StepWalker
@@ -38,7 +38,7 @@ def work(self):
                     position[1]
                 )
 
-                while True:
+                while distance(i2f(self.api._position_lat), i2f(self.api._position_lng), lat, lng) > 10:
                     if step_walker.step():
                         break
 


Test patch:
Repository: PokemonGoF/PokemonGo-Bot

Issue:
Berries are used for VIP pokemon even with a 100% catch rate
### Expected Behavior

A Razz Berry should not be used on VIP pokemon that have a ~100% success rate.
### Actual Behavior

With a 100% catch rate, a Razz Berry is still used on a VIP pokemon.

Logs:

```
[15:39:23]  A Wild Eevee appeared! [CP 13] [Potential 0.64]
[15:39:23] IV [Stamina/Attack/Defense] = [15/8/6]
[15:39:26]  [-] Eevee is a VIP Pokemon! [CP 13] [Potential 0.64] Nice! Try our best to catch it!
[15:39:26] Catch Rate with normal Pokeball is low (100.00%). Thinking to throw a Razz Berry... (86 left!)
[15:39:26] Threw a berry! Catch Rate with normal Pokeball has increased to 150.00%
[15:39:26] Using Pokeball (chance: 150.00%)... (18 left!)
[15:39:27]  Captured Eevee! [CP 13] [Potential 0.64] [15/8/6] [+220 exp]
```
### Other Information

OS: Mac OSX
Git Commit: 3fe8eb07c098c45c87db0d643d579ac4f7464cf6 (on dev)



Discussion:

Resolving patch:
diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py
--- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py
+++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py
@@ -87,7 +87,7 @@ def work(self):
                             berry_used = False
 
                             if flag_VIP:
-                                if(berries_count>0):
+                                if(berries_count>0 and catch_rate[pokeball-1] < 0.9):
                                     success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100)
                                     logger.log('Catch Rate with normal Pokeball is low ({}%). Thinking to throw a {}... ({} left!)'.format(success_percentage,self.item_list[str(berry_id)],berries_count-1))
                                     # Out of all pokeballs! Let's don't waste berry.


Test patch:
Repository: PokemonGoF/PokemonGo-Bot

Issue:
evolve_all "all" is not working
### Expected Behavior

Bot would try to evolve all eligible pokemon when "evolve_all": "all" is set
### Actual Behavior

Bot does not evolve anything when "evolve_all": "all" is set.  If I set it to "evolve_all": "all,Weedle" I get the following output: 

```
[19:11:08]  Starting PokemonGo Bot....
[19:11:09]  [x] Current egg hatches in 0.85 km
[19:11:10] [#] Successfully evolved Weedle with 180 CP and 0.4 IV!
[19:11:13] [#] Successfully evolved Weedle with 113 CP and 0.51 IV!
```
### Steps to Reproduce

Set "evolve_all" to all on this commit
### Other Information

OS: Ubuntu 14.04.4 LTS
Git Commit: eee7ba49c5c4e6bb1b3efefcf9f99a7c72a48671
Python Version: python 2.7.6



Discussion:
Having this bug as well.

Last working commit 86472c0a2f8aa61381bebff3022acbffc568998c


Resolving patch:
diff --git a/pokemongo_bot/cell_workers/evolve_all.py b/pokemongo_bot/cell_workers/evolve_all.py
--- a/pokemongo_bot/cell_workers/evolve_all.py
+++ b/pokemongo_bot/cell_workers/evolve_all.py
@@ -9,9 +9,10 @@ def initialize(self):
         self.evolve_speed = self.config.get('evolve_speed', 3.7)
         self.evolve_cp_min = self.config.get('evolve_cp_min', 300)
         self.use_lucky_egg = self.config.get('use_lucky_egg', False)
+        self._validate_config()
 
     def _validate_config(self):
-        if isinstance(self.evolve_all, str):
+        if isinstance(self.evolve_all, basestring):
             self.evolve_all = [str(pokemon_name) for pokemon_name in self.evolve_all.split(',')]
 
     def work(self):


Test patch:
Repository: PokemonGoF/PokemonGo-Bot

Issue:
[Dev] local variable 'unexpected_reponse_retry' referenced before assignment
There is a typo in a variable

`unexpected_reponse_retry` should be `unexpected_response_retry`
/pokemongo_bot/api_wrapper.py - line 120 



Discussion:

Resolving patch:
diff --git a/pokemongo_bot/api_wrapper.py b/pokemongo_bot/api_wrapper.py
--- a/pokemongo_bot/api_wrapper.py
+++ b/pokemongo_bot/api_wrapper.py
@@ -117,7 +117,7 @@ def call(self, max_retry=15):
                 continue # skip response checking
 
             if should_unexpected_response_retry:
-                unexpected_reponse_retry += 1
+                unexpected_response_retry += 1
                 if unexpected_response_retry >= 5:
                     logger.log('Server is not responding correctly to our requests.  Waiting for 30 seconds to reconnect.', 'red')
                     sleep(30)


Test patch:
Repository: PokemonGoF/PokemonGo-Bot

Issue:
Berries and balls count not always updated
3 berry throws and always "have 2". Last one with error.
![screenshot_2016-08-10-14-45-58](https://cloud.githubusercontent.com/assets/20733365/17546029/4b1c0876-5f0a-11e6-9d80-6d007930e96e.png)

One more haopening
![screenshot_2016-08-10-14-58-19](https://cloud.githubusercontent.com/assets/20733365/17546154/eb8f347c-5f0a-11e6-9efa-7951c6667646.png)

Same thing happens with Ultraballs. Probably, not only with Ultra- ones.
![screenshot_2016-08-10-16-42-16](https://cloud.githubusercontent.com/assets/20733365/17549281/add2d31e-5f19-11e6-8fe1-2014eacbc4a0.png)



Discussion:

Resolving patch:
diff --git a/pokemongo_bot/cell_workers/nickname_pokemon.py b/pokemongo_bot/cell_workers/nickname_pokemon.py
--- a/pokemongo_bot/cell_workers/nickname_pokemon.py
+++ b/pokemongo_bot/cell_workers/nickname_pokemon.py
@@ -1,3 +1,5 @@
+import os
+import json
 from pokemongo_bot.base_task import BaseTask
 from pokemongo_bot.human_behaviour import sleep
 from pokemongo_bot.inventory import pokemons, Pokemon, Attack
@@ -186,6 +188,13 @@ def initialize(self):
         self.template = self.config.get(
             'nickname_template', DEFAULT_TEMPLATE)
 
+        self.translate = None
+        locale = self.config.get('locale', 'en')
+        if locale != 'en':
+            fn = 'data/locales/{}.json'.format(locale)
+            if os.path.isfile(fn):
+                self.translate = json.load(open(fn))
+
     def work(self):
         """
         Iterate over all user pokemons and nickname if needed
@@ -194,6 +203,12 @@ def work(self):
             if not pokemon.is_favorite or not self.ignore_favorites:
                 self._nickname_pokemon(pokemon)
 
+    def _localize(self, string):
+        if self.translate and string in self.translate:
+            return self.translate[string]
+        else:
+            return string
+
     def _nickname_pokemon(self, pokemon):
         # type: (Pokemon) -> None
         """
@@ -305,6 +320,8 @@ def _generate_new_nickname(self, pokemon, template):
 
         moveset = pokemon.moveset
 
+        pokemon.name = self._localize(pokemon.name)
+
         #
         # Generate new nickname
         #


Test patch:
Repository: PokemonGoF/PokemonGo-Bot

Issue:
IOError: [Errno 25] Inappropriate ioctl for device
Running in a docker container based on the DockerFile:

```
Traceback (most recent call last):
  File "/usr/src/app/pokecli.py", line 530, in <module>
    main()
  File "/usr/src/app/pokecli.py", line 96, in main
    bot.tick()
  File "/usr/src/app/pokemongo_bot/__init__.py", line 472, in tick
    if worker.work() == WorkerResult.RUNNING:
  File "/usr/src/app/pokemongo_bot/cell_workers/catch_visible_pokemon.py", line 45, in work
    'expiration_timestamp_ms': pokemon['expiration_timestamp_ms'],
  File "/usr/src/app/pokemongo_bot/base_task.py", line 28, in emit_event
    data=data
  File "/usr/src/app/pokemongo_bot/event_manager.py", line 65, in emit
    handler.handle_event(event, sender, level, formatted_msg, data)
  File "/usr/src/app/pokemongo_bot/event_handlers/colored_logging_handler.py", line 130, in handle_event
    terminal_width = self._terminal_width()
  File "/usr/src/app/pokemongo_bot/event_handlers/colored_logging_handler.py", line 171, in _terminal_width
    struct.pack(str('HHHH'), 0, 0, 0, 0)))
IOError: [Errno 25] Inappropriate ioctl for device
```

Git Commit: 9ae1b785f0836d8769d011626d2bc071ed338bff

This happens after encountering a pokemon.
Looks like it is now having a problem printing colors to the screen.



Discussion:

Resolving patch:
diff --git a/pokemongo_bot/event_handlers/colored_logging_handler.py b/pokemongo_bot/event_handlers/colored_logging_handler.py
--- a/pokemongo_bot/event_handlers/colored_logging_handler.py
+++ b/pokemongo_bot/event_handlers/colored_logging_handler.py
@@ -125,7 +125,7 @@ def handle_event(self, event, sender, level, formatted_msg, data):
             message = 'Something rustles nearby!'
 
         # Truncate previous line if same event continues
-        if event in ColoredLoggingHandler.CONTINUOUS_EVENT_NAMES and self._last_event == event:
+        if event in ColoredLoggingHandler.CONTINUOUS_EVENT_NAMES and self._last_event == event and sys.stdout.isatty():
             # Filling with "' ' * terminal_width" in order to completely clear last line
             terminal_width = self._terminal_width()
             if terminal_width:


Test patch:
Repository: PokemonGoF/PokemonGo-Bot

Issue:
Enhanced sniping crash
#3277 added new config options for sniping capability
- "snipe_high_prio_only": true,
- "snipe_high_prio_threshold": 400,
### Expected Behavior

Anyone on a commit before this merge can use the bot, without adding the new config options as the code should default values for users who don't add the new config options
### Actual Behavior

Bot crashes as the config options do not default in the code
### Steps to Reproduce

git dev branch sitting at pre #3277 
git pull
python pokecli.py
Crashes when trying to snipe
http://pastebin.com/LTYCn5eQ
### Other Information

OS: Windows 8.1 x64
Git Commit: 0292c2f426b2432be70b0ca867fa62d8436cb5bf
Python Version: 2.7.12



Discussion:
@raiven66


Resolving patch:
diff --git a/pokemongo_bot/cell_workers/move_to_map_pokemon.py b/pokemongo_bot/cell_workers/move_to_map_pokemon.py
--- a/pokemongo_bot/cell_workers/move_to_map_pokemon.py
+++ b/pokemongo_bot/cell_workers/move_to_map_pokemon.py
@@ -85,6 +85,9 @@ def initialize(self):
         self.caught = []
         self.min_ball = self.config.get('min_ball', 1)
         self.map_path = self.config.get('map_path', 'raw_data')
+        self.snipe_high_prio_only = self.config.get('snipe_high_prio_only', False)
+        self.snipe_high_prio_threshold = self.config.get('snipe_high_prio_threshold', 400)
+
 
         data_file = os.path.join(_base_dir, 'map-caught-{}.json'.format(self.bot.config.username))
         if os.path.isfile(data_file):
@@ -124,9 +127,6 @@ def get_pokemon_from_map(self):
             if pokemon['name'] not in self.config['catch'] and not pokemon['is_vip']:
                 continue
 
-            if pokemon['disappear_time'] < (now + self.config['min_time']):
-                continue
-
             if self.was_caught(pokemon):
                 continue
 
@@ -142,6 +142,11 @@ def get_pokemon_from_map(self):
             if pokemon['dist'] > self.config['max_distance'] and not self.config['snipe']:
                 continue
 
+            # pokemon not reachable with mean walking speed (by config)
+            mean_walk_speed = (self.bot.config.walk_max + self.bot.config.walk_min) / 2
+            if pokemon['dist'] > ((pokemon['expire'] - now) * mean_walk_speed) and not self.config['snipe']:
+                continue
+
             pokemon_list.append(pokemon)
 
         return pokemon_list
@@ -257,8 +262,8 @@ def work(self):
             return WorkerResult.SUCCESS
 
         if self.config['snipe']:
-            if self.config['snipe_high_prio_only']:
-                if self.config['snipe_high_prio_threshold'] < pokemon['priority'] or pokemon['is_vip']:
+            if self.snipe_high_prio_only:
+                if self.snipe_high_prio_threshold < pokemon['priority'] or pokemon['is_vip']:
                     self.snipe(pokemon)
             else:
                 return self.snipe(pokemon)


Test patch: