Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions odtp/dashboard/page_run/folder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import json
import logging
import os.path
import os
import shutil
from slugify import slugify

from nicegui import app, ui
import odtp.dashboard.utils.storage as storage
Expand Down Expand Up @@ -70,12 +73,8 @@ def ui_prepare_folder(dialog, result, workdir, current_run, folder_status):
else:
cli_output_command = None
with ui.row().classes("w-full flex items-center"):
ui.button(
"Choose existing project folder",
on_click=lambda: pick_folder(workdir, current_run),
icon="folder",
).props("flat")
project_folder_input = ui.input(
value=slugify(execution["title"]),
label="Project folder name",
placeholder="execution",
validation={
Expand All @@ -89,11 +88,6 @@ def ui_prepare_folder(dialog, result, workdir, current_run, folder_status):
on_click=lambda: create_folder(workdir, project_folder_input, current_run),
icon="add",
).props("flat ")
ui.button(
f"Reset project folder",
on_click=lambda: remove_project_folder(current_run),
icon="clear",
).props("flat")
with ui.row().classes("w-full"):
from odtp.dashboard.page_run.run import run_command
if cli_output_command:
Expand Down Expand Up @@ -131,7 +125,9 @@ def create_folder(workdir, folder_name_input, current_run):
try:
folder_name = folder_name_input.value
project_path = os.path.join(workdir, folder_name)
os.mkdir(project_path)
if os.path.exists(project_path):
shutil.rmtree(project_path)
os.makedirs(project_path)
current_run["project_path"] = project_path
current_run["stepper"] = rh.STEPPERS[rh.STEPPER_SELECT_FOLDER]
app.storage.user[storage.EXECUTION_RUN] = json.dumps(current_run)
Expand All @@ -151,19 +147,6 @@ def create_folder(workdir, folder_name_input, current_run):
ui_stepper.refresh()


def remove_project_folder(current_run) -> None:
try:
current_run["project_path"] = ""
app.storage.user[storage.EXECUTION_RUN] = json.dumps(current_run)
ui.notify("The project path been reset", type="positive")
except Exception as e:
log.exception(f"The project directory could not be reset: an exception occurred: {e}")
else:
from odtp.dashboard.page_run.main import ui_workarea, ui_stepper
ui_stepper.refresh()
ui_workarea.refresh()


def get_folder_status(execution_id, project_path):
folder_empty = odtp_env.project_folder_is_empty(project_folder=project_path)
folder_matches_execution = odtp_env.directory_folder_matches_execution(
Expand Down
30 changes: 29 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pygwalker = "^0.3.17"
streamlit-aggrid = "^0.3.4.post3"
nicegui = "1.4.24"
directory-tree = "^0.0.4"
python-slugify = "^8.0.4"

[tool.poetry.group.dev.dependencies]
pytest = "^7.2.1"
Expand Down