Skip to content

Commit

Permalink
Make client runnable from anywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
IsraMekki0 committed Mar 8, 2024
1 parent cf51bfe commit 1f0654b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/client/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include dcp_client/*.cfg
57 changes: 41 additions & 16 deletions src/client/dcp_client/main.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,62 @@
import argparse
import sys
import warnings
from os import path
from PyQt5.QtWidgets import QApplication

from dcp_client.app import Application
from dcp_client.gui.welcome_window import WelcomeWindow
from dcp_client.utils import settings
from dcp_client.utils.fsimagestorage import FilesystemImageStorage
from dcp_client.utils.bentoml_model import BentomlModel
from dcp_client.utils.fsimagestorage import FilesystemImageStorage
from dcp_client.utils.sync_src_dst import DataRSync
from dcp_client.utils.utils import read_config
from dcp_client.app import Application
from dcp_client.gui.welcome_window import WelcomeWindow
from PyQt5.QtWidgets import QApplication

import warnings
warnings.simplefilter('ignore')
warnings.simplefilter("ignore")


def main():

settings.init()
dir_name = path.dirname(path.abspath(sys.argv[0]))
server_config = read_config('server', config_path = path.join(dir_name, 'config.cfg'))
dir_name = path.dirname(path.abspath(__file__))

parser = argparse.ArgumentParser()
parser.add_argument(
"-m",
"--mode",
choices=["local", "remote"],
required=True,
help="Choose mode: local or remote",
)
args = parser.parse_args()

if args.mode == "local":
server_config = read_config(
"server", config_path=path.join(dir_name, "config.cfg")
)
elif args.mode == "remote":
server_config = read_config(
"server", config_path=path.join(dir_name, "config_remote.cfg")
)

image_storage = FilesystemImageStorage()
ml_model = BentomlModel()
data_sync = DataRSync(user_name=server_config["user"],
host_name=server_config["host"],
server_repo_path=server_config["data-path"])
welcome_app = Application(ml_model=ml_model,
syncer=data_sync,
image_storage=image_storage,
server_ip=server_config["ip"],
server_port=server_config["port"])
data_sync = DataRSync(
user_name=server_config["user"],
host_name=server_config["host"],
server_repo_path=server_config["data-path"],
)
welcome_app = Application(
ml_model=ml_model,
syncer=data_sync,
image_storage=image_storage,
server_ip=server_config["ip"],
server_port=server_config["port"],
)
app = QApplication(sys.argv)
window = WelcomeWindow(welcome_app)
sys.exit(app.exec())


if __name__ == "__main__":
main()

0 comments on commit 1f0654b

Please sign in to comment.