Skip to content

Commit

Permalink
import ConfigurationSettings as cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhsmit committed Sep 24, 2021
1 parent 101be81 commit 6e16ad2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
4 changes: 1 addition & 3 deletions pyhdx/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
from ipaddress import ip_address
from pyhdx.web import serve
from pyhdx.config import ConfigurationSettings
from pyhdx.config import cfg
from pyhdx.local_cluster import verify_cluster, default_cluster


Expand All @@ -15,8 +15,6 @@ def main():
parser.add_argument('--scheduler_address', help="Run with local cluster <ip>:<port>")
args = parser.parse_args()

cfg = ConfigurationSettings()

if args.scheduler_address:
ip, port = args.scheduler_address.split(':')
if not ip_address(ip):
Expand Down
4 changes: 1 addition & 3 deletions pyhdx/local_cluster.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from dask.distributed import LocalCluster, Client
import time
from pyhdx.config import ConfigurationSettings
from pyhdx.config import cfg
import argparse

cfg = ConfigurationSettings()

def default_client(timeout='2s'):
"""Return Dask client at scheduler adress as defined by the global config"""
scheduler_address = cfg.get('cluster', 'scheduler_address')
Expand Down
3 changes: 1 addition & 2 deletions pyhdx/web/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import logging
import panel as pn
from pyhdx.web.log import logger
from pyhdx.config import ConfigurationSettings
from pyhdx.config import cfg
from pyhdx.local_cluster import default_client

from pathlib import Path
Expand All @@ -27,7 +27,6 @@
current_dir = Path(__file__).parent
data_dir = current_dir.parent.parent / 'tests' / 'test_data'
global_opts = {'show_grid': True}
cfg = ConfigurationSettings()

@logger('pyhdx')
def main_app(client='default'):
Expand Down
4 changes: 2 additions & 2 deletions pyhdx/web/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import torch

from pyhdx.config import ConfigurationSettings
from pyhdx.config import cfg
from pyhdx.local_cluster import verify_cluster

import logging
Expand All @@ -24,7 +24,7 @@ def run_main():
np.random.seed(43)
torch.manual_seed(43)

scheduler_address = ConfigurationSettings().get('cluster', 'scheduler_address')
scheduler_address = cfg.get('cluster', 'scheduler_address')
if not verify_cluster(scheduler_address):
print(f"No valid Dask scheduler found at specified address: '{scheduler_address}'")
return
Expand Down

0 comments on commit 6e16ad2

Please sign in to comment.