LucaVivona commited on
Commit
86be414
1 Parent(s): b4fcff9

Non Class Decorator Updated 🧑‍🎨

Browse files
backend/src/index.py CHANGED
@@ -14,4 +14,6 @@ def Hello_World(name):
14
 
15
 
16
  if __name__ == "__main__":
17
- Greeting().run(listen=2000)
 
 
 
14
 
15
 
16
  if __name__ == "__main__":
17
+ print(Hello_World("Luca"))
18
+
19
+ # Greeting().run(listen=2000)
backend/src/resources/__pycache__/module.cpython-39.pyc CHANGED
Binary files a/backend/src/resources/__pycache__/module.cpython-39.pyc and b/backend/src/resources/__pycache__/module.cpython-39.pyc differ
 
backend/src/resources/module.py CHANGED
@@ -70,22 +70,60 @@ def tabularGradio(funcs, names, name="Tabular Temp Name", **kwargs):
70
  return
71
 
72
 
73
- def register(inputs, outputs, examples=None):
74
  def register_gradio(func):
75
- def wrap(*args, **kwargs):
76
- try:
77
- self = args[0]
78
- self.registered_gradio_functons
79
- except AttributeError:
80
- print("✨Initializing Class Functions...✨\n")
81
- self.registered_gradio_functons = dict()
82
-
83
  fn_name = func.__name__
84
- if fn_name in self.registered_gradio_functons:
85
- result = func(*args, **kwargs)
86
- return result
87
- else:
88
- self.registered_gradio_functons[fn_name] = dict(inputs=inputs, outputs=outputs, examples=examples)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  return None
90
  return wrap
91
  return register_gradio
 
70
  return
71
 
72
 
73
+ def register(inputs, outputs, examples=None, **kwargs):
74
  def register_gradio(func):
75
+ def wrap(*args, **wargs):
 
 
 
 
 
 
 
76
  fn_name = func.__name__
77
+
78
+ if 'self' in func.__code__.co_varnames and func.__name__ in dir(args[0]):
79
+
80
+ """
81
+ given the decorator is on a class then
82
+ initialize a registered_gradio_functons
83
+ if not already initialize.
84
+ """
85
+ assert len(inputs) == func.__code__.co_argcount - 1, "❌ inputs should have the same length as arguments"
86
+
87
+ try:
88
+ self = args[0]
89
+ self.registered_gradio_functons
90
+ except AttributeError:
91
+ print("✨Initializing Class Functions...✨\n")
92
+ self.registered_gradio_functons = dict()
93
+
94
+
95
+
96
+ if not fn_name in self.registered_gradio_functons:
97
+ self.registered_gradio_functons[fn_name] = dict(inputs=inputs, outputs=outputs, examples=examples)
98
+
99
+ if len(args[1:]) == (func.__code__.co_argcount - 1):
100
+ return func(*args, **wargs)
101
+ else :
102
+ """
103
+ the function is not a class function
104
+ """
105
+ assert len(inputs) == func.__code__.co_argcount, "❌ inputs should have the same length as arguments"
106
+
107
+ if len(args) == (func.__code__.co_argcount):
108
+ return func(*args, **wargs)
109
+
110
+ return gr.Interface(fn=func,
111
+ inputs=inputs,
112
+ outputs=outputs,
113
+ examples=examples,
114
+ cache_examples=kwargs['cache_examples'] if "cache_examples" in kwargs else None,
115
+ examples_per_page=kwargs['examples_per_page'] if "examples_per_page" in kwargs else 10,
116
+ interpretation=kwargs['interpretation'] if "interpretation" in kwargs else None,
117
+ num_shap=kwargs['num_shap'] if "num_shap" in kwargs else 2.0,
118
+ title=kwargs['title'] if "title" in kwargs else None,
119
+ article=kwargs['article'] if "article" in kwargs else None,
120
+ thumbnail=kwargs['thumbnail'] if "thumbnail" in kwargs else None,
121
+ css=kwargs['css'] if "css" in kwargs else None,
122
+ live=kwargs['live'] if "live" in kwargs else False,
123
+ allow_flagging=kwargs['allow_flagging'] if "allow_flagging" in kwargs else None,
124
+ theme='default',
125
+ )
126
+
127
  return None
128
  return wrap
129
  return register_gradio
frontend/src/App.js CHANGED
@@ -1,19 +1,9 @@
1
  import ReactEnviorment from './Components/ReactFlow/ReactFlowEnv'
2
- import { useState } from 'react'
3
- import { useThemeDetector } from './helper/visual'
4
-
5
-
6
 
7
  export default function App() {
8
- const [theme, setTheme] = useState(useThemeDetector)
9
  return(
10
  <>
11
-
12
- <div className=' absolute top-4 right-5 z-50' >
13
- <h1 className='text-3xl' onClick={()=> setTheme(theme === "" ? "dark" : "")}>{theme ? '🌙' : '☀️'}</h1>
14
- </div>
15
-
16
- <ReactEnviorment theme={theme ? 'dark' : ''}/>
17
  </>
18
 
19
  )
 
1
  import ReactEnviorment from './Components/ReactFlow/ReactFlowEnv'
 
 
 
 
2
 
3
  export default function App() {
 
4
  return(
5
  <>
6
+ <ReactEnviorment/>
 
 
 
 
 
7
  </>
8
 
9
  )
frontend/src/Components/ReactFlow/ReactFlowEnv.js CHANGED
@@ -7,14 +7,16 @@ import ReactFlow, { Background,
7
  ReactFlowProvider,
8
  } from 'react-flow-renderer';
9
  import React ,{ useState, useCallback, useRef } from 'react';
10
- import Navbar from '../Navagation/navbar';
11
-
 
12
  const types = {
13
  custom : CustomNodeIframe,
14
  }
15
 
16
- export default function ReactEnviorment(props) {
17
 
 
18
  const [nodes, setNodes] = useState([]);
19
  const [edges, setEdges] = useState([]);
20
  const [reactFlowInstance, setReactFlowInstance] = useState(null);
@@ -68,15 +70,20 @@ export default function ReactEnviorment(props) {
68
 
69
 
70
  return (
71
- <div className={`flex h-screen w-screen ${props.theme} transition-all`}>
72
- <Navbar/>
73
- <ReactFlowProvider>
74
- <div className="h-screen w-screen" ref={reactFlowWrapper}>
75
- <ReactFlow nodes={nodes} edges={edges} nodeTypes={types} onNodesChange={onNodesChange} onEdgesChange={onEdgesChange} onDragOver={onDragOver} onDrop={onDrop} onInit={setReactFlowInstance} fitView>
76
- <Background variant='dots' size={1} className=" bg-white dark:bg-neutral-800"/>
77
- </ReactFlow>
78
- </div>
79
- </ReactFlowProvider>
80
- </div>
 
 
 
 
 
81
  );
82
  }
 
7
  ReactFlowProvider,
8
  } from 'react-flow-renderer';
9
  import React ,{ useState, useCallback, useRef } from 'react';
10
+ import Navbar from '../Navagation/Navbar';
11
+ import { useThemeDetector } from '../../helper/visual'
12
+
13
  const types = {
14
  custom : CustomNodeIframe,
15
  }
16
 
17
+ export default function ReactEnviorment() {
18
 
19
+ const [theme, setTheme] = useState(useThemeDetector)
20
  const [nodes, setNodes] = useState([]);
21
  const [edges, setEdges] = useState([]);
22
  const [reactFlowInstance, setReactFlowInstance] = useState(null);
 
70
 
71
 
72
  return (
73
+ <>
74
+ <div className=' absolute top-4 right-5 z-50' >
75
+ <h1 className='text-3xl' onClick={()=> setTheme(theme === "" ? "dark" : "")}>{theme === "dark" ? '🌙' : '☀️'}</h1>
76
+ </div>
77
+ <div className={`flex h-screen w-screen ${theme} transition-all`}>
78
+ <Navbar/>
79
+ <ReactFlowProvider>
80
+ <div className="h-screen w-screen" ref={reactFlowWrapper}>
81
+ <ReactFlow nodes={nodes} edges={edges} nodeTypes={types} onNodesChange={onNodesChange} onEdgesChange={onEdgesChange} onDragOver={onDragOver} onDrop={onDrop} onInit={setReactFlowInstance} fitView>
82
+ <Background variant='dots' size={1} className=" bg-white dark:bg-neutral-800"/>
83
+ </ReactFlow>
84
+ </div>
85
+ </ReactFlowProvider>
86
+ </div>
87
+ </>
88
  );
89
  }