Skip to content

Commit

Permalink
Connect (#11)
Browse files Browse the repository at this point in the history
* fix the connect

* add instructions to connect
  • Loading branch information
tsaie79 authored Oct 10, 2024
1 parent 71ee980 commit f619662
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion fw-lpad/FireWorks/jrm_launcher/gen_wf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def connect(self, connect_type, port=None, nodename=None, mapped_port=None, cust
raise ValueError("Invalid connect type specified.")

# Save the port-nodename table after any connection
self.ssh.ssh_instance.port_nodename_table.save_table()
self.ssh.port_nodename_table.save_table()

def print_site_config(self):
print("Site Configuration:")
Expand Down
37 changes: 23 additions & 14 deletions fw-lpad/FireWorks/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

# Define a function to display help
function display_help {
echo "Usage: ./launch-jrms.sh [command] [options]"
echo "Usage: ./main.sh [command] [options]"
echo "Commands:"
echo " add_wf Add a workflow to the launchpad. Requires the site-specific configuration file to be set."
echo " get_wf Get workflows from the launchpad."
echo " delete_wf Delete workflows from the launchpad. Requires one or more workflow IDs."
echo " delete_ports Delete ports from the launchpad. Requires additional arguments for the start and end ports."
echo " connect Establish a connection (db, apiserver, metrics, custom_metrics)."
echo " connect Establish a connection. Usage: ./main.sh connect <connection_type> <config_file> [options]"
echo " Connection types:"
echo " db - Connect to the database"
echo " apiserver - Connect to the API server"
echo " metrics - Connect to the metrics server"
echo " custom_metrics - Connect to the custom metrics server"
echo " shell Open an IPython shell and initialize LaunchPad and LOG_PATH."
echo " print_config Print the site configuration. Requires the site-specific configuration file to be set."
exit 0
Expand All @@ -30,7 +35,7 @@ fi
case "$1" in
add_wf)
if [ -z "$2" ]; then
echo "Please provide a site-specific configuration file to add a workflow. Example: ./launch-jrms.sh add_wf /path/to/site_config.yaml"
echo "Please provide a site-specific configuration file to add a workflow. Example: ./main.sh add_wf /path/to/site_config.yaml"
exit 1
fi
python /fw/jrm_launcher/gen_wf.py add_wf --site_config_file "$2"
Expand All @@ -40,7 +45,7 @@ case "$1" in
;;
delete_wf)
if [ -z "$2" ]; then
echo "Please provide one or more Firework IDs to delete. Example: ./launch-jrms.sh delete_wf 1 2 3"
echo "Please provide one or more Firework IDs to delete. Example: ./main.sh delete_wf 1 2 3"
exit 1
fi
# Loop through all provided Firework IDs and delete each one
Expand All @@ -50,37 +55,41 @@ case "$1" in
;;
delete_ports)
if [ -z "$2" ] || [ -z "$3" ]; then
echo "Please provide start and end ports to delete. Example: ./launch-jrms.sh delete_ports 10000 20000"
echo "Please provide start and end ports to delete. Example: ./main.sh delete_ports 10000 20000"
exit 1
fi
python /fw/jrm_launcher/gen_wf.py delete_ports --start "$2" --end "$3"
;;
connect)
if [ -z "$2" ] || [ -z "$3" ]; then
echo "Please provide a connect type and site-specific configuration file. Example: ./launch-jrms.sh connect db /path/to/site_config.yaml"
if [ -z "$2" ]; then
echo "Please provide a connect type: db, apiserver, metrics, custom_metrics"
exit 1
fi
case "$2" in
db)
if [ -z "$3" ]; then
echo "Please provide a site-specific configuration file. Example: ./main.sh connect db /path/to/site_config.yaml"
exit 1
fi
python /fw/jrm_launcher/gen_wf.py connect --site_config_file "$3" --connect_type db
;;
apiserver)
if [ -z "$4" ]; then
echo "Please provide a port number for the apiserver connection. Example: ./launch-jrms.sh connect apiserver /path/to/site_config.yaml 35679"
if [ -z "$3" ]; then
echo "Please provide a port number for the apiserver connection. Example: ./main.sh connect apiserver /path/to/site_config.yaml 35679"
exit 1
fi
python /fw/jrm_launcher/gen_wf.py connect --site_config_file "$3" --connect_type apiserver --port "$4"
;;
metrics)
if [ -z "$4" ] || [ -z "$5" ]; then
echo "Please provide a port number and nodename for the metrics connection. Example: ./launch-jrms.sh connect metrics /path/to/site_config.yaml 10001 nodename"
if [ -z "$3" ]; then
echo "Please provide a port number and nodename for the metrics connection. Example: ./main.sh connect metrics /path/to/site_config.yaml 10001 nodename"
exit 1
fi
python /fw/jrm_launcher/gen_wf.py connect --site_config_file "$3" --connect_type metrics --port "$4" --nodename "$5"
;;
custom_metrics)
if [ -z "$4" ] || [ -z "$5" ] || [ -z "$6" ]; then
echo "Please provide a mapped port, custom metrics port, and nodename for the custom metrics connection. Example: ./launch-jrms.sh connect custom_metrics /path/to/site_config.yaml 8000 8100 nodename"
if [ -z "$3" ] || [ -z "$4" ] || [ -z "$5" ]; then
echo "Please provide a mapped port, custom metrics port, and nodename for the custom metrics connection. Example: ./main.sh connect custom_metrics /path/to/site_config.yaml 8000 8100 nodename"
exit 1
fi
python /fw/jrm_launcher/gen_wf.py connect --site_config_file "$3" --connect_type custom_metrics --mapped_port "$4" --custom_metrics_port "$5" --nodename "$6"
Expand All @@ -99,7 +108,7 @@ case "$1" in
;;
print_config)
if [ -z "$2" ]; then
echo "Please provide a site-specific configuration file to print. Example: ./launch-jrms.sh print_config /path/to/site_config.yaml"
echo "Please provide a site-specific configuration file to print. Example: ./main.sh print_config /path/to/site_config.yaml"
exit 1
fi
python /fw/jrm_launcher/gen_wf.py print_config --site_config_file "$2"
Expand Down

0 comments on commit f619662

Please sign in to comment.