Skip to content

Conversation

liuzongyue6
Copy link
Collaborator

Add Toy example to test Dask distributed computing with remote worker and local PostgreSQL

Description

This PR adds a toy example test script that demonstrates the integration between local Dask scheduler and PostgreSQL and remote Dask worker in GTSFM's eagle cluster. The test verifies the following functionality:

Test Details

The test script (test_local_scheduler_remote_worker_local_postgres.py) performs the following:

  • Establishes SSH tunnel for port forwarding
  • Launches a Dask scheduler locally
  • Starts a Dask worker on a remote machine
  • Creates a PostgreSQL table for storing computation results
  • Runs simple distributed computations (squaring numbers)
  • Stores results in PostgreSQL database
  • Verifies the results through database queries

@dellaert dellaert requested a review from Copilot May 14, 2025 13:57
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a toy example test script to demonstrate the integration of a local Dask scheduler with a remote Dask worker and a local PostgreSQL database for storing computation results.

  • Establishes an SSH tunnel to forward necessary ports
  • Launches the Dask scheduler and a remote worker for distributed computations
  • Sets up and initializes a PostgreSQL table, performs computations, and verifies results via database queries

try:
p.terminate()
p.wait(timeout=5)
except:
Copy link
Preview

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using a bare 'except:' clause; specify 'except Exception:' to prevent inadvertently catching unexpected exceptions.

Suggested change
except:
except Exception:

Copilot uses AI. Check for mistakes.

'port': db_port,
'database': 'postgres',
'user': 'postgres',
'password': '0504'
Copy link
Preview

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded database credentials can pose a security risk; consider externalizing sensitive configuration data.

Suggested change
'password': '0504'
'password': os.getenv('DB_PASSWORD', 'default_password') # Use environment variable for password

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

@akshay-krishnan akshay-krishnan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some minor syle comments.

Comment on lines +12 to +13
username = "zliu890"
server = "eagle.cc.gatech.edu"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use argparse for these two?

except Exception as e:
print(f"Failed to retrieve results from database: {e}")

# 1. Establish SSH tunnel
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put all this under a if __name__ == '__main__':

@@ -0,0 +1,227 @@
import subprocess
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use a file-level docstring as well. you can find examples in other gtsfm files.
Also this file would be better located in the scripts folder instead of the tests folder. the tests folder is for unit tests. https://github.com/borglab/gtsfm/tree/master/scripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants