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 Oct 4, 2024
1 parent 9b211ab commit d6563e1
Show file tree
Hide file tree
Showing 20 changed files with 1,043 additions and 552 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Changed
^^^^^^^

- The Globus Compute self-diagnostic is now available as a stand-alone console
script installed as part of the globus-compute-sdk package, instead of only
as the ``self-diagnostic`` sub-command of the globus-compute-endpoint CLI.

For more information, see ``globus-compute-diagnostic --help``

52 changes: 14 additions & 38 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,7 @@
import sys
import textwrap
import uuid
from datetime import datetime
import warnings

import click
from click import ClickException
Expand All @@ -27,11 +25,11 @@
)
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.auth.auth_client import ComputeAuthClient
from globus_compute_sdk.sdk.auth.globus_app import get_globus_app
from globus_compute_sdk.sdk.auth.whoami import print_whoami_info
from globus_compute_sdk.sdk.compute_dir import ensure_compute_dir
from globus_compute_sdk.sdk.diagnostic import do_diagnostic_base
from globus_compute_sdk.sdk.web_client import WebClient
from globus_sdk import MISSING, AuthClient, GlobusAPIError, MissingType
from globus_sdk.experimental.globus_app import GlobusApp
Expand Down Expand Up @@ -848,41 +846,19 @@ 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.
def self_diagnostic(compress: bool, log_kb: int, endpoint_uuid: str):
"""
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}")
Note that this functionality has been migrated to the SDK, leaving only
a redirect here.
"""
warnings.warn(
"This endpoint specific self-diagnostic command has been deprecated.\n"
"Please use the `globus-compute-diagnostic` command from the SDK instead.",
DeprecationWarning,
stacklevel=2,
)
print(f"Arguments: {sys.argv}")
do_diagnostic_base(sys.argv[2:])


@app.command(
Expand Down
187 changes: 0 additions & 187 deletions compute_endpoint/globus_compute_endpoint/self_diagnostic.py

This file was deleted.

Loading

0 comments on commit d6563e1

Please sign in to comment.