Skip to content

Commit

Permalink
Fixed formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhellander committed Oct 24, 2023
1 parent 5ae0cff commit 5d70451
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 25 deletions.
2 changes: 1 addition & 1 deletion fedn/cli/run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def run_cmd(ctx):
@click.option('--heartbeat-interval', required=False, default=2)
@click.option('--reconnect-after-missed-heartbeat', required=False, default=30)
@click.option('--verbosity', required=False, default='INFO', type=click.Choice(['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'], case_sensitive=False))
@click.option('--theme', required=False, default='default', type=click.Choice(['dark', 'light', 'vibrant', 'default'], case_sensitive=False))
@click.option('--theme', required=False, default='default', type=click.Choice(['dark', 'light', 'default'], case_sensitive=False))
@click.pass_context
def client_cmd(ctx, discoverhost, discoverport, token, name, client_id, local_package, force_ssl, dry_run, secure, preshared_cert,
verify, preferred_combiner, validator, trainer, init, logfile, heartbeat_interval, reconnect_after_missed_heartbeat,
Expand Down
12 changes: 1 addition & 11 deletions fedn/fedn/common/color_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ class ColorizingStreamHandler(logging.StreamHandler):
'CRITICAL': 'red',
}

vibrant_theme = {
'DEBUG': 'cyan',
'INFO': 'green',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'red',
}

def __init__(self, theme='dark'):
super().__init__()
self.set_theme(theme)
Expand All @@ -36,8 +28,6 @@ def set_theme(self, theme):
self.color_map = self.dark_theme
elif theme == 'light':
self.color_map = self.light_theme
elif theme == 'vibrant':
self.color_map = self.vibrant_theme
elif theme == 'default':
self.color_map = {} # No color applied
else:
Expand All @@ -55,4 +45,4 @@ def emit(self, record):
self.stream.write(message + "\n")
self.flush()
except Exception:
self.handleError(record)
self.handleError(record)
2 changes: 1 addition & 1 deletion fedn/fedn/common/log_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def set_theme_from_string(theme_str):
Set the logging color theme based on a string input.
"""
# Check if the theme string is valid
valid_themes = ['dark', 'light', 'vibrant', 'default']
valid_themes = ['dark', 'light', 'default']
if theme_str.lower() not in valid_themes:
raise ValueError(f"Invalid theme: {theme_str}. Valid themes are: {', '.join(valid_themes)}")

Expand Down
17 changes: 5 additions & 12 deletions fedn/fedn/network/clients/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

import fedn.common.net.grpc.fedn_pb2 as fedn
import fedn.common.net.grpc.fedn_pb2_grpc as rpc
from fedn.common.log_config import logger, set_log_level_from_string, set_theme_from_string
from fedn.common.log_config import (logger, set_log_level_from_string,
set_theme_from_string)
from fedn.network.clients.connect import ConnectorClient, Status
from fedn.network.clients.package import PackageRuntime
from fedn.network.clients.state import ClientState, ClientStateToString
from fedn.utils.dispatcher import Dispatcher
from fedn.utils.helpers import get_helper


CHUNK_SIZE = 1024 * 1024
VALID_NAME_REGEX = '^[a-zA-Z0-9_-]*$'

Expand All @@ -50,13 +50,6 @@ class Client:

def __init__(self, config):
"""Initialize the client."""
print(""" _____ _ _ ______ ______ _____
/ ____| | | | | | ____| ____| __ \
| (___ ___ __ _| | ___ ___ _ _| |_ | |__ | |__ | | | |_ __
\___ \ / __/ _` | |/ _ \/ _ \| | | | __| | __| | __| | | | | '_ \
____) | (_| (_| | | __/ (_) | |_| | |_ | | | |____| |__| | | | |
|_____/ \___\__,_|_|\___|\___/ \__,_|\__| |_| |______|_____/|_| |_|
""")
self.state = None
self.error_state = False
self._attached = False
Expand Down Expand Up @@ -100,7 +93,7 @@ def __init__(self, config):

self._initialize_helper(client_config)
if not self.helper:
logger.warning("Failed to retrive helper class settings: {}".format(
logger.warning("Failed to retrieve helper class settings: {}".format(
client_config))

self._subscribe_to_combiner(config)
Expand All @@ -125,10 +118,10 @@ def _assign(self):
client_config = response
break
if status == Status.UnAuthorized:
logger.warning(response)
logger.critical(response)
sys.exit("Exiting: Unauthorized")
if status == Status.UnMatchedConfig:
logger.warning(response)
logger.critical(response)
sys.exit("Exiting: UnMatchedConfig")
time.sleep(5)

Expand Down

0 comments on commit 5d70451

Please sign in to comment.