madhavanvenkatesh commited on
Commit
748f48a
1 Parent(s): 6caf480

Config head node runtime via IP

Browse files
examples/hyperparam_optimiz_for_disease_classifier.py CHANGED
@@ -18,10 +18,42 @@ import ray
18
  from ray import tune
19
  from ray.tune import ExperimentAnalysis
20
  from ray.tune.suggest.hyperopt import HyperOptSearch
 
21
  runtime_env = {"conda": "base",
22
  "env_vars": {"LD_LIBRARY_PATH": "/path/to/miniconda3/lib:/path/to/sw/lib:/path/to/sw/lib"}}
23
  ray.init(runtime_env=runtime_env)
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  import datetime
26
  import numpy as np
27
  import pandas as pd
@@ -30,7 +62,7 @@ import seaborn as sns; sns.set()
30
  from collections import Counter
31
  from datasets import load_from_disk
32
  from scipy.stats import ranksums
33
- from sklearn.metrics import accuracy_score
34
  from transformers import BertForSequenceClassification
35
  from transformers import Trainer
36
  from transformers.training_args import TrainingArguments
 
18
  from ray import tune
19
  from ray.tune import ExperimentAnalysis
20
  from ray.tune.suggest.hyperopt import HyperOptSearch
21
+ ray.shutdown() #engage new ray session
22
  runtime_env = {"conda": "base",
23
  "env_vars": {"LD_LIBRARY_PATH": "/path/to/miniconda3/lib:/path/to/sw/lib:/path/to/sw/lib"}}
24
  ray.init(runtime_env=runtime_env)
25
 
26
+ def initialize_ray_with_check(ip_address):
27
+ """
28
+ Initialize Ray with a specified IP address and check its status and accessibility.
29
+
30
+ Args:
31
+ - ip_address (str): The IP address (with port) to initialize Ray.
32
+
33
+ Returns:
34
+ - bool: True if initialization was successful and dashboard is accessible, False otherwise.
35
+ """
36
+ try:
37
+ ray.init(address=ip_address)
38
+ print(ray.nodes())
39
+
40
+ services = ray.get_webui_url()
41
+ if not services:
42
+ raise RuntimeError("Ray dashboard is not accessible.")
43
+ else:
44
+ print(f"Ray dashboard is accessible at: {services}")
45
+ return True
46
+ except Exception as e:
47
+ print(f"Error initializing Ray: {e}")
48
+ return False
49
+
50
+ # Usage:
51
+ ip = 'your_ip:xxxx' # Replace with your actual IP address and port
52
+ if initialize_ray_with_check(ip):
53
+ print("Ray initialized successfully!")
54
+ else:
55
+ print("Error during Ray initialization.")
56
+
57
  import datetime
58
  import numpy as np
59
  import pandas as pd
 
62
  from collections import Counter
63
  from datasets import load_from_disk
64
  from scipy.stats import ranksums
65
+ from sklearn.metrics import accuracy_score, f1_score
66
  from transformers import BertForSequenceClassification
67
  from transformers import Trainer
68
  from transformers.training_args import TrainingArguments