Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALCF Update #28

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion orchestration/globus/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def start_transfer(
relative_path = item.relative_to(source_path.parent)
tdata.add_item(str(item), os.path.join(dest_path, str(relative_path)))
else:
tdata.add_item(source_path, dest_path)
tdata.add_item(str(source_path), dest_path)
logger.info(
f"starting transfer {source_endpoint.uri}:{source_path} to {dest_endpoint.uri}:{dest_path}"
)
Expand Down
30 changes: 15 additions & 15 deletions scripts/check_globus_compute.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
from dotenv import load_dotenv
import typer
from typing import Optional

from globus_compute_sdk.sdk.login_manager import LoginManager
Expand All @@ -8,6 +8,8 @@

load_dotenv()

app = typer.Typer()


@task
def get_login_manager(environment: Optional[str] = None) -> LoginManager:
Expand Down Expand Up @@ -58,28 +60,26 @@ def check_globus_compute_status(endpoint_id: str) -> bool:
return False


def main() -> None:
@app.command()
def main(endpoint_id: str) -> None:
"""
Main function to parse command-line arguments and check the Globus Compute endpoint status.
Check the status of a Globus Compute endpoint by providing the endpoint_id.

Example usage:
python check_globus_compute.py --endpoint_id "your-uuid-here"
python check_globus_compute.py --endpoint-id "your-uuid-here"

IMPORTANT:
Ensure you are logged into Globus Compute
Ensure you are logged into Globus Compute and have set the environment variables for the client credentials:
export GLOBUS_COMPUTE_CLIENT_ID="your-client-id" & export GLOBUS_COMPUTE_CLIENT_SECRET="your-client-secret"
:return: None
"""
parser = argparse.ArgumentParser(description="Check the status of a Globus Compute endpoint.")
parser.add_argument('--endpoint_id', type=str, required=True, help="The UUID of the Globus Compute endpoint.")

args = parser.parse_args()

online = check_globus_compute_status(args.endpoint_id)
:param endpoint_id: The UUID of the Globus Compute endpoint.
"""
online = check_globus_compute_status(endpoint_id)
if online:
print(f"Endpoint {args.endpoint_id} is online.")
typer.echo(f"Endpoint {endpoint_id} is online.")
else:
print(f"Endpoint {args.endpoint_id} is not online.")
typer.echo(f"Endpoint {endpoint_id} is not online.")


if __name__ == "__main__":
main()
app()
47 changes: 22 additions & 25 deletions scripts/check_globus_transfer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
from dotenv import load_dotenv
import os
import time
import typer

import globus_sdk
from prefect import flow, task, get_run_logger
Expand All @@ -14,6 +14,8 @@
CLIENT_SECRET: Optional[str] = os.getenv('GLOBUS_CLIENT_SECRET')
SCOPES: str = "urn:globus:auth:scope:transfer.api.globus.org:all"

app = typer.Typer()


@task
def initialize_transfer_client() -> Tuple[Optional[globus_sdk.TransferClient], bool]:
Expand Down Expand Up @@ -215,41 +217,36 @@ def check_globus_transfer_permissions(endpoint_id: str,
logger.info(f"list_directory (after creating {directory_name}) successful: {success_list_directory_after}")


def main() -> None:
@app.command()
def main(endpoint_id: str,
transfer_client: Optional[globus_sdk.TransferClient],
list_contents: bool = True,
create_test_directory: bool = True,
delete_test_directory: bool = True,
directory_name: str = "test_directory/") -> None:
"""
Main function to parse command-line arguments and run the check_globus_transfer_permissions flow.

Run from the command line:
python check_globus_transfer.py --endpoint_id "your-endpoint-id" --directory_name "your-directory-name"

Command-line arguments:
--endpoint_id (str): The UUID of the endpoint to operate on.
--list_contents (bool): Whether to list directory contents. Default is True.
--create_test_directory (bool): Whether to create a directory. Default is True.
--delete_test_directory (bool): Whether to delete the directory. Default is True.
--directory_name (str): The name of the directory to create or delete. Default is "test_directory".
Args:
endpoint_id (str): The UUID of the Globus endpoint.
list_contents (bool): Whether to list directory contents. Default is True.
create_test_directory (bool): Whether to create a directory. Default is True.
delete_test_directory (bool): Whether to delete the directory. Default is True.
directory_name (str): The name of the directory to create or delete. Default is "test_directory/".
"""
parser = argparse.ArgumentParser(description="Run Globus transfer operations on a specified endpoint.")
parser.add_argument('--endpoint_id', type=str, required=True, help="The UUID of the Globus endpoint.")
parser.add_argument('--list_contents', type=bool, default=True, help="Whether to list directory contents.")
parser.add_argument('--create_test_directory', type=bool, default=True,
help="Whether to create a directory.")
parser.add_argument('--delete_test_directory', type=bool, default=True,
help="Whether to delete the directory.")
parser.add_argument('--directory_name', type=str, default="test_directory/",
help="The name of the directory to create or delete.")

args = parser.parse_args()

check_globus_transfer_permissions(
endpoint_id=args.endpoint_id,
endpoint_id=endpoint_id,
transfer_client=None,
list_contents=args.list_contents,
create_test_directory=args.create_test_directory,
delete_test_directory=args.delete_test_directory,
directory_name=args.directory_name
list_contents=list_contents,
create_test_directory=create_test_directory,
delete_test_directory=delete_test_directory,
directory_name=directory_name
)


if __name__ == "__main__":
main()
app()
Loading