Skip to content

Commit

Permalink
* use ip instead of hostname in examples
Browse files Browse the repository at this point in the history
* decrease default budget to 1
  • Loading branch information
shadeofblue committed Apr 12, 2024
1 parent fb40c9f commit d9d6a34
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion examples/outbound_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@

ray.init()

def get_own_ip():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("192.168.0.1", 1))
return s.getsockname()[0]

@dataclass
class UrlResult:
Expand All @@ -54,7 +58,7 @@ def exc_causes(e: BaseException):

@ray.remote
def get_url_len(url: str, num_attempts: int, timeout: int, keep_alive: bool) -> UrlResult:
node_ip = socket.gethostbyname(socket.gethostname())
node_ip = get_own_ip()
start = datetime.now()

def seconds():
Expand Down
7 changes: 6 additions & 1 deletion examples/simple-actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

ray.init()

def get_own_ip():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("192.168.0.1", 1))
return s.getsockname()[0]


@ray.remote
class CounterActor:
Expand All @@ -17,7 +22,7 @@ def increment(self):
time.sleep(0.5)
self.value += 1

node_ip = socket.gethostname()
node_ip = get_own_ip()
self.node_ips.append(node_ip)

return node_ip
Expand Down
6 changes: 5 additions & 1 deletion examples/simple-task.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

ray.init()

def get_own_ip():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("192.168.0.1", 1))
return s.getsockname()[0]

def output_cluster_info():
print(
Expand All @@ -28,7 +32,7 @@ def output_cluster_info():
def f():
time.sleep(0.5)

return socket.gethostname()
return get_own_ip()


# get the number of remote calls from the command line
Expand Down
2 changes: 1 addition & 1 deletion golem-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ provider:
#payment_network: "polygon"

# Maximum amount of GLMs that's going to be spent for the whole cluster
total_budget: 5
total_budget: 1

# Common parameters for all node types. Can be overridden in available_node_types
node_config:
Expand Down

0 comments on commit d9d6a34

Please sign in to comment.