Skip to content

Commit

Permalink
Merge pull request #590 from FabienArcellier/67-store-writer-framewor…
Browse files Browse the repository at this point in the history
…k-ide-files-3

feat: store writer framework ide files
  • Loading branch information
ramedina86 authored Oct 14, 2024
2 parents 5380bb3 + 82dcb0b commit eb03f8f
Show file tree
Hide file tree
Showing 22 changed files with 28 additions and 29 deletions.
4 changes: 2 additions & 2 deletions alfred/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from writer import audit_and_fix, wf_project
from writer import VERSION, audit_and_fix, wf_project

import alfred

Expand Down Expand Up @@ -40,7 +40,7 @@ def apps_update(app: str = None):

if os.path.isfile(os.path.join(abs_path, "ui.json")):
print(f'{app} : migrate ui.json')
wf_project.migrate_obsolete_ui_json(abs_path)
wf_project.migrate_obsolete_ui_json(abs_path, {"writer_version": VERSION})

if not os.path.isfile(os.path.join(abs_path, ".wf", 'components-workflows_root.jsonl')):
wf_project.create_default_workflows_root(abs_path)
Expand Down
2 changes: 1 addition & 1 deletion apps/ai-starter/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion apps/default/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
{"id": "f67c98aa-3a7b-4f40-ac1f-0dd4aa06e22d", "type": "plotlygraph", "content": {"spec": "@{scatter_chart}"}, "handlers": {}, "isCodeManaged": false, "parentId": "6a490318-239e-4fe9-a56b-f0f33d628c87", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "d0298b1c-7c64-4b58-a018-db97dd49675b", "type": "separator", "content": {}, "isCodeManaged": false, "parentId": "c6392876-7cfd-4680-8725-b04f43ff294f", "position": 3}
{"id": "f1d6bc8e-a780-4ae5-8b7c-082fe8a6867d", "type": "dataframe", "content": {"dataframe": "@{main_df}", "enableDownload": "yes", "enableSearch": "yes", "showIndex": ""}, "isCodeManaged": false, "parentId": "c6392876-7cfd-4680-8725-b04f43ff294f", "position": 4}
{"id": "m1vznlnfxjzq4rde", "type": "tab", "content": {"name": "Tab Name"}, "handlers": {}, "isCodeManaged": false, "parentId": "ee919cd6-8153-4f34-8c6a-bfc1153df360", "position": 1}
{"id": "3cc9c5e9-6c77-401d-ab82-7805d9df760c", "type": "tab", "content": {"name": "Layout"}, "isCodeManaged": false, "parentId": "ee919cd6-8153-4f34-8c6a-bfc1153df360", "position": 2}
{"id": "3cc9c5e9-6c77-401d-ab82-7805d9df760c", "type": "tab", "content": {"name": "Layout"}, "isCodeManaged": false, "parentId": "ee919cd6-8153-4f34-8c6a-bfc1153df360", "position": 1}
{"id": "fb22acfc-cdb5-44b6-9e97-76c3a51a8fff", "type": "columns", "content": {}, "isCodeManaged": false, "parentId": "3cc9c5e9-6c77-401d-ab82-7805d9df760c", "position": 0}
{"id": "25dda22d-1b18-4584-aa99-aaae9f3b8edf", "type": "column", "content": {"contentVAlign": "", "isCollapsible": "yes", "title": "Markdown", "width": "1"}, "isCodeManaged": false, "parentId": "fb22acfc-cdb5-44b6-9e97-76c3a51a8fff", "position": 0}
{"id": "feedc43f-a7cf-499b-962e-8170f1032b69", "type": "text", "content": {"text": "You can use Markdown, as shown below."}, "isCodeManaged": false, "parentId": "25dda22d-1b18-4584-aa99-aaae9f3b8edf", "position": 0}
Expand All @@ -52,7 +51,7 @@
{"id": "5da5e007-d60a-4313-9d21-885deae7b37d", "type": "text", "content": {"text": "You can put other Writer Framework components inside HTML Elements."}, "isCodeManaged": false, "parentId": "a36b75bc-58e6-48ba-bdef-0824e6b21e8d", "position": 1}
{"id": "ee82e035-cfb2-4d00-95ce-ccbb9eb2dbb9", "type": "sliderinput", "binding": {"eventType": "wf-number-change", "stateRef": "hue_rotation"}, "content": {"label": "Hue rotation", "maxValue": "360", "minValue": "0", "stepSize": "1"}, "isCodeManaged": false, "parentId": "b1ee642e-f2e7-453b-a6ef-3d96eea37140", "position": 2}
{"id": "c9bb4720-d07a-4fd8-bc53-5bda8dc64046", "type": "text", "content": {"text": "As shown above, you can use _HTML Element_ components together with state references.", "useMarkdown": "yes"}, "isCodeManaged": false, "parentId": "b1ee642e-f2e7-453b-a6ef-3d96eea37140", "position": 3}
{"id": "da00a61f-0ee2-434e-acd6-228d32eae5c6", "type": "tab", "content": {"name": "Repeater"}, "isCodeManaged": false, "parentId": "ee919cd6-8153-4f34-8c6a-bfc1153df360", "position": 3}
{"id": "da00a61f-0ee2-434e-acd6-228d32eae5c6", "type": "tab", "content": {"name": "Repeater"}, "isCodeManaged": false, "parentId": "ee919cd6-8153-4f34-8c6a-bfc1153df360", "position": 2}
{"id": "de70a15a-2ff6-42d2-ab12-c7fc9c3ed4e1", "type": "heading", "content": {"alignment": "center", "headingType": "h2", "text": "Highlighted Members"}, "isCodeManaged": false, "parentId": "da00a61f-0ee2-434e-acd6-228d32eae5c6", "position": 0}
{"id": "01c33c6e-3788-4b5d-b7aa-2addaa7b503f", "type": "text", "content": {"alignment": "center", "text": "The following Hacker Pigeons have made an impressive contribution this month.\nLet's come together to recognise and celebrate this success."}, "isCodeManaged": false, "parentId": "da00a61f-0ee2-434e-acd6-228d32eae5c6", "position": 1}
{"id": "2f4969e2-e248-43ed-9e63-222fc35250e2", "type": "columns", "content": {}, "isCodeManaged": false, "parentId": "da00a61f-0ee2-434e-acd6-228d32eae5c6", "position": 2}
Expand All @@ -64,12 +63,12 @@
{"id": "e0e2391e-7bab-4c68-ad92-841942cb12fb", "type": "text", "content": {"text": "The ability @{item.name} demonstrated in @{item.specialty} has earned them this recognition.", "useMarkdown": "yes"}, "isCodeManaged": false, "parentId": "2d326b15-da90-496e-86e8-7fdd4bcbe822", "position": 2}
{"id": "4ef4655b-45ca-495c-9f8d-fa1d7ae3565e", "type": "separator", "content": {}, "isCodeManaged": false, "parentId": "2d326b15-da90-496e-86e8-7fdd4bcbe822", "position": 3}
{"id": "7ea0d29a-5dca-4b6c-a067-322ccaee5032", "type": "text", "content": {"text": "You can use a _Repeater_ component to repeat components, based on a dictionary.", "useMarkdown": "yes"}, "isCodeManaged": false, "parentId": "2d326b15-da90-496e-86e8-7fdd4bcbe822", "position": 4}
{"id": "e1ax8ctt8lrao0e4", "type": "tab", "content": {"name": "Pagination"}, "handlers": {}, "isCodeManaged": false, "parentId": "ee919cd6-8153-4f34-8c6a-bfc1153df360", "position": 4, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "e1ax8ctt8lrao0e4", "type": "tab", "content": {"name": "Pagination"}, "handlers": {}, "isCodeManaged": false, "parentId": "ee919cd6-8153-4f34-8c6a-bfc1153df360", "position": 3, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "j3jkho6tb97u0onr", "type": "repeater", "content": {"keyVariable": "itemId", "repeaterObject": "@{paginated_members}", "valueVariable": "item"}, "handlers": {}, "isCodeManaged": false, "parentId": "e1ax8ctt8lrao0e4", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "4wzaubf275w17gac", "type": "section", "content": {"containerBackgroundColor": "#F5F5F9", "title": "@{item.name} \u2b50\ufe0f"}, "handlers": {}, "isCodeManaged": false, "parentId": "j3jkho6tb97u0onr", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "19binb4yi70gesho", "type": "text", "content": {"text": "**Role:** @{item.role}\n", "useMarkdown": "yes"}, "isCodeManaged": false, "parentId": "4wzaubf275w17gac", "position": 0}
{"id": "zfp1koasiuleygmz", "type": "pagination", "content": {"jumpTo": "no", "page": "@{paginated_members_page}", "pageSize": "@{paginated_members_page_size}", "pageSizeOptions": "1,2,5", "pageSizeShowAll": "no", "totalItems": "@{paginated_members_total_items}", "urlParam": "no"}, "handlers": {"wf-change-page": "handle_paginated_members_page_change", "wf-change-page-size": "handle_paginated_members_page_size_change"}, "isCodeManaged": false, "parentId": "e1ax8ctt8lrao0e4", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "85120b55-69c6-4b50-853a-bbbf73ff8121", "type": "tab", "content": {"name": "Timer"}, "isCodeManaged": false, "parentId": "ee919cd6-8153-4f34-8c6a-bfc1153df360", "position": 5}
{"id": "85120b55-69c6-4b50-853a-bbbf73ff8121", "type": "tab", "content": {"name": "Timer"}, "isCodeManaged": false, "parentId": "ee919cd6-8153-4f34-8c6a-bfc1153df360", "position": 4}
{"id": "09ddb2da-6fa3-4157-8da3-4d5d44a6a58d", "type": "horizontalstack", "content": {"contentHAlign": "start"}, "isCodeManaged": false, "parentId": "85120b55-69c6-4b50-853a-bbbf73ff8121", "position": 0}
{"id": "50a05488-d6fe-47bf-b681-36870d04f5d7", "type": "timer", "content": {"intervalMs": "1000", "isActive": ""}, "handlers": {"wf-tick": "handle_timer_tick"}, "isCodeManaged": false, "parentId": "09ddb2da-6fa3-4157-8da3-4d5d44a6a58d", "position": 0}
{"id": "e296866a-75d2-4677-b55d-3c1456113b89", "type": "text", "content": {"text": "Refreshing automatically using a timer."}, "isCodeManaged": false, "parentId": "09ddb2da-6fa3-4157-8da3-4d5d44a6a58d", "position": 1}
Expand Down
2 changes: 1 addition & 1 deletion apps/hello/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion apps/pdg-tutorial/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion apps/quickstart/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion apps/text-demo/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion src/writer/app_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def _load_persisted_script(self) -> str:
def _load_persisted_components(self) -> Dict[str, ComponentDefinition]:
logger = logging.getLogger('writer')
if os.path.isfile(os.path.join(self.app_path, "ui.json")):
wf_project.migrate_obsolete_ui_json(self.app_path)
wf_project.migrate_obsolete_ui_json(self.app_path, metadata={"writer_version": VERSION})

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)
Expand Down
4 changes: 2 additions & 2 deletions src/writer/wf_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def read_files(app_path: str) -> Tuple[MetadataDefinition, dict[str, ComponentDe
return metadata, components


def migrate_obsolete_ui_json(app_path: str) -> None:
def migrate_obsolete_ui_json(app_path: str, metadata: MetadataDefinition) -> None:
"""
Migrates a project that uses ui.json file to the current project format
Expand All @@ -110,7 +110,7 @@ def migrate_obsolete_ui_json(app_path: str) -> None:
raise ValueError("No dictionary found in components file.")

file_payload = parsed_file
metadata = file_payload.get("metadata", {})
# metadata = file_payload.get("metadata", {})
components = file_payload.get("components", {})
write_files(app_path, metadata, components)
os.remove(os.path.join(app_path, "ui.json"))
Expand Down
4 changes: 2 additions & 2 deletions tests/backend/test_wf_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import tempfile
from typing import List

from writer import core_ui, wf_project
from writer import VERSION, core_ui, wf_project
from writer.ss_types import ComponentDefinition

from tests.backend import test_app_dir, testobsoleteapp
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_wf_project_migrate_obsolete_ui_json_should_migrate_ui_json_into_wf_dire
shutil.copytree(testobsoleteapp, tmp_app_dir, dirs_exist_ok=True)

# When
wf_project.migrate_obsolete_ui_json(tmp_app_dir)
wf_project.migrate_obsolete_ui_json(tmp_app_dir, {"writer_version": VERSION})

# Then
assert not os.path.isfile(os.path.join(tmp_app_dir, 'ui.json'))
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/testapp/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion tests/backend/testbasicauth/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion tests/backend/testmultiapp/app1/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion tests/backend/testmultiapp/app2/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion tests/e2e/presets/2columns/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion tests/e2e/presets/2pages/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion tests/e2e/presets/empty_page/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion tests/e2e/presets/jsonviewer/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion tests/e2e/presets/low_code/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion tests/e2e/presets/section/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}
2 changes: 1 addition & 1 deletion tests/e2e/presets/state/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.7.0rc2"
"writer_version": "0.8.0rc1"
}

0 comments on commit eb03f8f

Please sign in to comment.