Skip to content

Commit

Permalink
added summy logger; fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
yanchengnv committed Feb 24, 2025
1 parent cf2b7a5 commit 1d6143c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions nvflare/dashboard/application/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@
from .store import Store, inc_dl


class DummyLogger:
"""This dummy logger is used to suppress all log messages generated by the Provisioner, except for errors.
We print error messages to stdout.
"""

def info(self, msg: str):
pass

def error(self, msg: str):
print(f"ERROR: {msg}")

def debug(self, msg: str):
pass

def warning(self, msg: str):
pass


def _get_provisioner(root_dir: str, scheme, docker_image=None):
overseer_agent = {
"path": "nvflare.ha.dummy_overseer_agent.DummyOverseerAgent",
Expand Down Expand Up @@ -102,10 +120,9 @@ def _gen_kit(download_key, prepare_target_cb=None, **cb_kwargs):
if prepare_target_cb is not None:
target = prepare_target_cb(prov_project, **cb_kwargs)

ctx = provisioner.provision(prov_project)
ctx = provisioner.provision(prov_project, logger=DummyLogger())
result_dir = ctx.get_result_location()
ent_dir = os.path.join(result_dir, target.name)
print(f"{target.name} provision result: {ent_dir}")
run_args = ["zip", "-rq", "-P", download_key, "tmp.zip", "."]
subprocess.run(run_args, cwd=ent_dir)
fileobj = io.BytesIO()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_test/dashboard/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def app():
if os.path.exists(sqlite_file):
os.remove(sqlite_file)
os.environ["DATABASE_URL"] = f"sqlite:///{sqlite_file}"
os.environ["NVFL_CREDENTIAL"] = f"{TEST_USER}:{TEST_PW}"
os.environ["NVFL_CREDENTIAL"] = f"{TEST_USER}:{TEST_PW}:nvidia"
app = init_app()
app.config.update(
{
Expand Down

0 comments on commit 1d6143c

Please sign in to comment.