Skip to content

Commit

Permalink
* use ip instead of hostname in examples (#230)
Browse files Browse the repository at this point in the history
* decrease default budget to 1
  • Loading branch information
shadeofblue authored Apr 12, 2024
1 parent fb40c9f commit 363db99
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
8 changes: 7 additions & 1 deletion examples/outbound_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
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:
node_ip: str
Expand All @@ -54,7 +60,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
8 changes: 7 additions & 1 deletion examples/simple-actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
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:
def __init__(self):
Expand All @@ -17,7 +23,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
8 changes: 7 additions & 1 deletion examples/simple-task.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
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(
"""This cluster consists of
Expand All @@ -28,7 +34,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 363db99

Please sign in to comment.