Kevin Hu
commited on
Commit
·
e7286da
1
Parent(s):
7889c99
prepare for sdk http api (#2075)
Browse files### What problem does this PR solve?
#1605
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- api/apps/__init__.py +5 -4
- api/apps/sdk/dataset.py +0 -0
api/apps/__init__.py
CHANGED
@@ -65,7 +65,7 @@ commands.register_commands(app)
|
|
65 |
|
66 |
def search_pages_path(pages_dir):
|
67 |
app_path_list = [path for path in pages_dir.glob('*_app.py') if not path.name.startswith('.')]
|
68 |
-
api_path_list = [path for path in pages_dir.glob('*
|
69 |
app_path_list.extend(api_path_list)
|
70 |
return app_path_list
|
71 |
|
@@ -73,7 +73,7 @@ def search_pages_path(pages_dir):
|
|
73 |
def register_page(page_path):
|
74 |
path = f'{page_path}'
|
75 |
|
76 |
-
page_name = page_path.stem.rstrip('
|
77 |
module_name = '.'.join(page_path.parts[page_path.parts.index('api'):-1] + (page_name,))
|
78 |
|
79 |
spec = spec_from_file_location(module_name, page_path)
|
@@ -83,7 +83,7 @@ def register_page(page_path):
|
|
83 |
sys.modules[module_name] = page
|
84 |
spec.loader.exec_module(page)
|
85 |
page_name = getattr(page, 'page_name', page_name)
|
86 |
-
url_prefix = f'/api/{API_VERSION}/{page_name}' if "
|
87 |
|
88 |
app.register_blueprint(page.manager, url_prefix=url_prefix)
|
89 |
return url_prefix
|
@@ -91,7 +91,8 @@ def register_page(page_path):
|
|
91 |
|
92 |
pages_dir = [
|
93 |
Path(__file__).parent,
|
94 |
-
Path(__file__).parent.parent / 'api' / 'apps',
|
|
|
95 |
]
|
96 |
|
97 |
client_urls_prefix = [
|
|
|
65 |
|
66 |
def search_pages_path(pages_dir):
|
67 |
app_path_list = [path for path in pages_dir.glob('*_app.py') if not path.name.startswith('.')]
|
68 |
+
api_path_list = [path for path in pages_dir.glob('*sdk/*.py') if not path.name.startswith('.')]
|
69 |
app_path_list.extend(api_path_list)
|
70 |
return app_path_list
|
71 |
|
|
|
73 |
def register_page(page_path):
|
74 |
path = f'{page_path}'
|
75 |
|
76 |
+
page_name = page_path.stem.rstrip('_app')
|
77 |
module_name = '.'.join(page_path.parts[page_path.parts.index('api'):-1] + (page_name,))
|
78 |
|
79 |
spec = spec_from_file_location(module_name, page_path)
|
|
|
83 |
sys.modules[module_name] = page
|
84 |
spec.loader.exec_module(page)
|
85 |
page_name = getattr(page, 'page_name', page_name)
|
86 |
+
url_prefix = f'/api/{API_VERSION}/{page_name}' if "/sdk/" in path else f'/{API_VERSION}/{page_name}'
|
87 |
|
88 |
app.register_blueprint(page.manager, url_prefix=url_prefix)
|
89 |
return url_prefix
|
|
|
91 |
|
92 |
pages_dir = [
|
93 |
Path(__file__).parent,
|
94 |
+
Path(__file__).parent.parent / 'api' / 'apps',
|
95 |
+
Path(__file__).parent.parent / 'api' / 'apps' / 'sdk',
|
96 |
]
|
97 |
|
98 |
client_urls_prefix = [
|
api/apps/sdk/dataset.py
ADDED
File without changes
|