Skip to content

Commit

Permalink
feat: prevent workflows tree to be sent during run mode
Browse files Browse the repository at this point in the history
* create default create_default_workflows_root
* migrate e2e:presets
  • Loading branch information
FabienArcellier committed Oct 8, 2024
1 parent 9ce9fed commit a0a7008
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 0 deletions.
10 changes: 10 additions & 0 deletions alfred/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ def apps_update(app: str = None):
'tests/backend/testbasicauth',
'tests/backend/testmultiapp/app1',
'tests/backend/testmultiapp/app2',
'tests/e2e/presets/2columns',
'tests/e2e/presets/2pages',
'tests/e2e/presets/empty_page',
'tests/e2e/presets/jsonviewer',
'tests/e2e/presets/low_code',
'tests/e2e/presets/section',
'tests/e2e/presets/state',
]

for app in apps:
Expand All @@ -35,6 +42,9 @@ def apps_update(app: str = None):
print(f'{app} : migrate ui.json')
wf_project.migrate_obsolete_ui_json(abs_path)

if not os.path.isfile(os.path.join(abs_path, ".wf", 'components-workflows_root.jsonl')):
wf_project.create_default_workflows_root(abs_path)

metadata, components = wf_project.read_files(abs_path)
if metadata.get('writer_version') == writer.VERSION:
print("The app is already up to date")
Expand Down
1 change: 1 addition & 0 deletions apps/ai-starter/.wf/components-workflows_root.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
1 change: 1 addition & 0 deletions apps/hello/.wf/components-workflows_root.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
1 change: 1 addition & 0 deletions apps/pdg-tutorial/.wf/components-workflows_root.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
1 change: 1 addition & 0 deletions apps/quickstart/.wf/components-workflows_root.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
1 change: 1 addition & 0 deletions apps/text-demo/.wf/components-workflows_root.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
1 change: 1 addition & 0 deletions src/ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<link rel="icon" type="image/png" href="./static/favicon.png?2" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Writer Framework</title>
<!-- {{ opengraph_tags}} -->
<style>
* {
box-sizing: border-box;
Expand Down
3 changes: 3 additions & 0 deletions src/writer/app_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,9 @@ def _load_persisted_components(self) -> Dict[str, ComponentDefinition]:
if os.path.isfile(os.path.join(self.app_path, "ui.json")):
wf_project.migrate_obsolete_ui_json(self.app_path)

if not os.path.isfile(os.path.join(self.app_path, ".wf", 'components-workflows_root.jsonl')):
wf_project.create_default_workflows_root(self.app_path)

if not os.path.isdir(os.path.join(self.app_path, ".wf")):
logger.error("Couldn't find .wf in the path provided: %s.", self.app_path)
sys.exit(1)
Expand Down
6 changes: 6 additions & 0 deletions src/writer/wf_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,9 @@ def migrate_obsolete_ui_json(app_path: str) -> None:
os.remove(os.path.join(app_path, "ui.json"))
logger.warning('project format has changed and has been migrated with success. ui.json file has been removed.')


def create_default_workflows_root(abs_path: str) -> None:
with io.open(os.path.join(abs_path, '.wf', 'components-workflows_root.jsonl'), 'w') as f:
f.write('{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}')
logger = logging.getLogger('writer')
logger.warning('project format has changed and has been migrated with success. components-workflows_root.jsonl has been added.')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": {"expression": true, "binding": "", "reversed": false}}

0 comments on commit a0a7008

Please sign in to comment.