Skip to content

Commit

Permalink
Move self diagnostic mostly to the SDK side and add more compatibilit…
Browse files Browse the repository at this point in the history
…y for multiple platforms
  • Loading branch information
LeiGlobus committed Sep 4, 2024
1 parent e8f51c6 commit 30a4aa8
Show file tree
Hide file tree
Showing 21 changed files with 1,046 additions and 598 deletions.
46 changes: 6 additions & 40 deletions compute_endpoint/globus_compute_endpoint/cli.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

import contextlib
import difflib
import gzip
import json
import logging
import os
Expand All @@ -12,7 +10,6 @@
import sys
import textwrap
import uuid
from datetime import datetime

import click
from click import ClickException
Expand All @@ -27,10 +24,9 @@
)
from globus_compute_endpoint.exception_handling import handle_auth_errors
from globus_compute_endpoint.logging_config import setup_logging
from globus_compute_endpoint.self_diagnostic import run_self_diagnostic
from globus_compute_sdk.sdk._environments import ensure_compute_dir
from globus_compute_sdk.sdk.login_manager import LoginManager
from globus_compute_sdk.sdk.login_manager.client_login import is_client_login
from globus_compute_sdk.sdk.login_manager.tokenstore import ensure_compute_dir
from globus_compute_sdk.sdk.login_manager.whoami import print_whoami_info
from globus_sdk import MISSING, AuthClient, GlobusAPIError, MissingType

Expand Down Expand Up @@ -864,41 +860,11 @@ def delete_endpoint(


@app.command("self-diagnostic")
@click.option(
"-z",
"--gzip",
"compress",
default=False,
is_flag=True,
help="Save the output to a Gzip-compressed file.",
)
@click.option(
"--log-kb",
default=5120,
help=(
"Specify the number of kilobytes (KB) to read from log files."
" Defaults to 5,120 KB (5 MB)."
),
)
@click.help_option("-h", "--help")
def self_diagnostic(compress: bool, log_kb: int):
"""Run several diagnostic commands to help identify issues.
This may produce a large amount of output.
"""
log_bytes = log_kb * 1024

if not compress:
run_self_diagnostic(log_bytes=log_bytes)
else:
current_date = datetime.now().strftime("%Y-%m-%d")
filename = f"globus_compute_diagnostic_{current_date}.txt.gz"

with gzip.open(filename, "wb") as f:
with contextlib.redirect_stdout(f): # type: ignore[type-var]
run_self_diagnostic(log_bytes=log_bytes)

click.echo(f"Successfully created {filename}")
def self_diagnostic():
print(
"The endpoint specific self-diagnostic command has been deprecated.\n"
"Please use the `globus-compute-diagnostic` command instead."
)


@app.command(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import globus_compute_sdk as GC
from cachetools import TTLCache
from globus_compute_endpoint.endpoint.identity_mapper import PosixIdentityMapper
from globus_compute_sdk.sdk._environments import ensure_compute_dir

try:
import pyprctl
Expand Down Expand Up @@ -971,7 +972,7 @@ def cmd_start_endpoint(
startup_proc_title = f"Endpoint starting up for {uname} [{args_title}]"
setproctitle.setproctitle(startup_proc_title)

gc_dir: pathlib.Path = GC.sdk.login_manager.tokenstore.ensure_compute_dir()
gc_dir: pathlib.Path = ensure_compute_dir()
ep_dir = gc_dir / ep_name
ep_dir.mkdir(mode=0o700, parents=True, exist_ok=True)
ep_log = ep_dir / "endpoint.log"
Expand Down
187 changes: 0 additions & 187 deletions compute_endpoint/globus_compute_endpoint/self_diagnostic.py

This file was deleted.

2 changes: 2 additions & 0 deletions compute_endpoint/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
"=globus_compute_endpoint.engines.high_throughput.manager:cli_run",
"globus-compute-worker"
"=globus_compute_endpoint.engines.high_throughput.worker:cli_run",
# "globus-compute-diagnostic"
# "=globus_compute_sdk.sdk.diagnostic:run_diagnostic",
]
},
include_package_data=True,
Expand Down
Loading

0 comments on commit 30a4aa8

Please sign in to comment.