Skip to content

Commit

Permalink
feat(framework) Add Exit code range (500-599) for simulation-specific…
Browse files Browse the repository at this point in the history
… exits (#4845)
  • Loading branch information
panh99 authored Jan 22, 2025
1 parent 48f1bfe commit cb67376
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
4 changes: 3 additions & 1 deletion framework/docs/source/ref-exit-codes-dir.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ Categories
(SuperNode) errors.
- **ClientApp-specific exit codes (400-499)**: Specific to ``flwr-clientapp``
(ClientApp) errors.
- **Common exit codes (500-)**: Shared across multiple components.
- **Simulation-specific exit codes (500-599)**: Specific to ``flwr-simulation``
(Simulation Engine) errors.
- **Common exit codes (600-)**: Shared across multiple components.

Indices
-------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[500] COMMON_ADDRESS_INVALID
[600] COMMON_ADDRESS_INVALID
============================

Description
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[501] COMMON_MISSING_EXTRA_REST
[601] COMMON_MISSING_EXTRA_REST
===============================

Description
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[502] COMMON_TLS_NOT_SUPPORTED
[602] COMMON_TLS_NOT_SUPPORTED
==============================

Description
Expand Down
13 changes: 8 additions & 5 deletions src/py/flwr/common/exit/exit_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ class ExitCode:

# ClientApp-specific exit codes (400-499)

# Common exit codes (500-)
COMMON_ADDRESS_INVALID = 500
COMMON_MISSING_EXTRA_REST = 501
COMMON_TLS_NOT_SUPPORTED = 502
# Simulation-specific exit codes (500-599)

# Common exit codes (600-)
COMMON_ADDRESS_INVALID = 600
COMMON_MISSING_EXTRA_REST = 601
COMMON_TLS_NOT_SUPPORTED = 602

def __new__(cls) -> ExitCode:
"""Prevent instantiation."""
Expand Down Expand Up @@ -75,7 +77,8 @@ def __new__(cls) -> ExitCode:
"file and try again."
),
# ClientApp-specific exit codes (400-499)
# Common exit codes (500-)
# Simulation-specific exit codes (500-599)
# Common exit codes (600-)
ExitCode.COMMON_ADDRESS_INVALID: (
"Please provide a valid URL, IPv4 or IPv6 address."
),
Expand Down
10 changes: 4 additions & 6 deletions src/py/flwr/simulation/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


import argparse
import sys
from logging import DEBUG, ERROR, INFO
from queue import Queue
from time import sleep
Expand All @@ -39,6 +38,7 @@
Status,
SubStatus,
)
from flwr.common.exit import ExitCode, flwr_exit
from flwr.common.logger import (
log,
mirror_output_to_queue,
Expand Down Expand Up @@ -81,12 +81,10 @@ def flwr_simulation() -> None:
log(INFO, "Starting Flower Simulation")

if not args.insecure:
log(
ERROR,
"`flwr-simulation` does not support TLS yet. "
"Please use the '--insecure' flag.",
flwr_exit(
ExitCode.COMMON_TLS_NOT_SUPPORTED,
"`flwr-simulation` does not support TLS yet. ",
)
sys.exit(1)

log(
DEBUG,
Expand Down

0 comments on commit cb67376

Please sign in to comment.