Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions test/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def test_xray(self):
)

_ = gr.components.Textbox()

print(xray_blocks.get_config_file())

self.assertEqual(XRAY_CONFIG, xray_blocks.get_config_file())

Expand Down
367 changes: 219 additions & 148 deletions test/test_data/blocks_configs.py
Original file line number Diff line number Diff line change
@@ -1,149 +1,220 @@
XRAY_CONFIG = {
"mode": "blocks",
"components": [
{
"id": 1,
"type": "markdown",
"props": {
"default_value": "<pre><code># Detect Disease From Scan\nWith this model you can lorem ipsum\n- ipsum 1\n- ipsum 2\n</code></pre>\n",
"name": "markdown",
"label": None,
"css": {},
},
},
{
"id": 2,
"type": "checkboxgroup",
"props": {
"choices": ["Covid", "Malaria", "Lung Cancer"],
"default_value": [],
"name": "checkboxgroup",
"label": "Disease to Scan For",
"css": {},
},
},
{"id": 3, "type": "tabs", "props": {"css": {}}},
{"id": 4, "type": "tabitem", "props": {"label": "X-ray", "css": {}}},
{"id": 5, "type": "tabitem", "props": {"label": "X-ray", "css": {}}},
{"id": 6, "type": "row", "props": {"type": "row", "css": {}}},
{
"id": 7,
"type": "image",
"props": {
"image_mode": "RGB",
"shape": None,
"source": "upload",
"tool": "editor",
"default_value": None,
"name": "image",
"label": None,
"css": {},
},
},
{
"id": 8,
"type": "json",
"props": {"default_value": '""', "name": "json", "label": None, "css": {}},
},
{
"id": 9,
"type": "button",
"props": {
"default_value": "Run",
"name": "button",
"label": None,
"css": {"background-color": "red", "--hover-color": "orange"},
},
},
{"id": 10, "type": "tabitem", "props": {"label": "CT Scan", "css": {}}},
{"id": 11, "type": "tabitem", "props": {"label": "CT Scan", "css": {}}},
{"id": 12, "type": "row", "props": {"type": "row", "css": {}}},
{
"id": 13,
"type": "image",
"props": {
"image_mode": "RGB",
"shape": None,
"source": "upload",
"tool": "editor",
"default_value": None,
"name": "image",
"label": None,
"css": {},
},
},
{
"id": 14,
"type": "json",
"props": {"default_value": '""', "name": "json", "label": None, "css": {}},
},
{
"id": 15,
"type": "button",
"props": {
"default_value": "Run",
"name": "button",
"label": None,
"css": {},
},
},
{
"id": 16,
"type": "textbox",
"props": {
"lines": 1,
"placeholder": None,
"default_value": "",
"name": "textbox",
"label": None,
"css": {},
},
},
],
"theme": "default",
"layout": {
"id": 0,
"children": [
{"id": 1},
{"id": 2},
{
"id": 3,
"children": [
{
"id": 5,
"children": [
{"id": 6, "children": [{"id": 7}, {"id": 8}]},
{"id": 9},
],
},
{
"id": 5,
"children": [
{"id": 6, "children": [{"id": 7}, {"id": 8}]},
{"id": 9},
],
},
{
"id": 11,
"children": [
{"id": 12, "children": [{"id": 13}, {"id": 14}]},
{"id": 15},
],
},
{
"id": 11,
"children": [
{"id": 12, "children": [{"id": 13}, {"id": 14}]},
{"id": 15},
],
},
],
},
{"id": 16},
],
},
"dependencies": [
{"targets": [9], "trigger": "click", "inputs": [2, 7], "outputs": [8]},
{"targets": [15], "trigger": "click", "inputs": [2, 13], "outputs": [14]},
],
}
'mode': 'blocks',
'components': [{
'id': 1,
'type': 'markdown',
'props': {
'default_value': '<pre><code> # Detect Disease From Scan\n With this model you can lorem ipsum\n - ipsum 1\n - ipsum 2\n</code></pre>\n',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got the config from from terminal with print(xray_blocks.get_config_file()), not sure why it does not comply with the test.
Thanks for the fix!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same lol

'name': 'markdown',
'label': None,
'css': {}
}
}, {
'id': 2,
'type': 'checkboxgroup',
'props': {
'choices': ['Covid', 'Malaria', 'Lung Cancer'],
'default_value': [],
'name': 'checkboxgroup',
'label': 'Disease to Scan For',
'css': {}
}
}, {
'id': 3,
'type': 'tabs',
'props': {
'css': {}
}
}, {
'id': 4,
'type': 'tabitem',
'props': {
'label': 'X-ray',
'css': {}
}
}, {
'id': 5,
'type': 'tabitem',
'props': {
'label': 'X-ray',
'css': {}
}
}, {
'id': 6,
'type': 'row',
'props': {
'type': 'row',
'css': {}
}
}, {
'id': 7,
'type': 'image',
'props': {
'image_mode': 'RGB',
'shape': None,
'source': 'upload',
'tool': 'editor',
'default_value': None,
'name': 'image',
'label': None,
'css': {}
}
}, {
'id': 8,
'type': 'json',
'props': {
'default_value': '""',
'name': 'json',
'label': None,
'css': {}
}
}, {
'id': 9,
'type': 'button',
'props': {
'default_value': 'Run',
'name': 'button',
'label': None,
'css': {
'background-color': 'red',
'--hover-color': 'orange'
}
}
}, {
'id': 10,
'type': 'tabitem',
'props': {
'label': 'CT Scan',
'css': {}
}
}, {
'id': 11,
'type': 'tabitem',
'props': {
'label': 'CT Scan',
'css': {}
}
}, {
'id': 12,
'type': 'row',
'props': {
'type': 'row',
'css': {}
}
}, {
'id': 13,
'type': 'image',
'props': {
'image_mode': 'RGB',
'shape': None,
'source': 'upload',
'tool': 'editor',
'default_value': None,
'name': 'image',
'label': None,
'css': {}
}
}, {
'id': 14,
'type': 'json',
'props': {
'default_value': '""',
'name': 'json',
'label': None,
'css': {}
}
}, {
'id': 15,
'type': 'button',
'props': {
'default_value': 'Run',
'name': 'button',
'label': None,
'css': {}
}
}, {
'id': 16,
'type': 'textbox',
'props': {
'lines': 1,
'placeholder': None,
'default_value': '',
'name': 'textbox',
'label': None,
'css': {}
}
}],
'theme': 'default',
'layout': {
'id': 0,
'children': [{
'id': 1
}, {
'id': 2
}, {
'id': 3,
'children': [{
'id': 5,
'children': [{
'id': 6,
'children': [{
'id': 7
}, {
'id': 8
}]
}, {
'id': 9
}]
}, {
'id': 5,
'children': [{
'id': 6,
'children': [{
'id': 7
}, {
'id': 8
}]
}, {
'id': 9
}]
}, {
'id': 11,
'children': [{
'id': 12,
'children': [{
'id': 13
}, {
'id': 14
}]
}, {
'id': 15
}]
}, {
'id': 11,
'children': [{
'id': 12,
'children': [{
'id': 13
}, {
'id': 14
}]
}, {
'id': 15
}]
}]
}, {
'id': 16
}]
},
'dependencies': [{
'targets': [9],
'trigger': 'click',
'inputs': [2, 7],
'outputs': [8]
}, {
'targets': [15],
'trigger': 'click',
'inputs': [2, 13],
'outputs': [14]
}]
}