from multiprocessing import Process
import os
import requests
import unittest

import uvicorn

import conf.server

# run server in subprocess

host = '127.0.0.1'
port = 5000
server_process = Process(
    target=uvicorn.run,
    args=('api:app', ),
    kwargs={'host': host, 'port': port, 'log_level': 'debug'},
    daemon=True
)
uri = f'http://{host}:{port}/'
server_process.start()

# configure and validate folders etc.
paths = conf.server.paths
paths['automic_watch_folder'] = paths['images']['inbound']
paths['test_source_files'] = ''

# load models by API

# prompt user start AutoMic loop

# move files from one folder to another
def copy_one_input_image_files(copy=True):
    pattern = ''
    os.listdir(paths['test_source_files'])

    # order by increaseing alpha order?  timestamp?


    if copy:
        # copy image from test source files to automic watch folder
    else:
        # move them

    # recursive repeat until nothign is left

# point to server session logs


# shut down server
server_process.terminate()


# do something with the data?