Closed NanzhongHE closed 3 months ago
If you use pip install to install the package, you could probably just run it directly without python -m
.
Does it work for you if you did this?
pip install grafana-dashboard-manager
grafana-dashboard-manager -h
Same error with grafana-dashboard-manager -h
$ grafana-dashboard-manager -h Traceback (most recent call last): File "
", line 198, in _run_module_as_main File " ", line 88, in _run_code File "C:\Users\nanzhong.he\AppData\Roaming\Python\Python312\Scripts\grafana-dashboard-manager.exe__main.py", line 7, in File "C:\Users\nanzhong.he\AppData\Roaming\Python\Python312\site-packages\grafana_dashboard_manager\ main__.py", line 19, in app pyproject = parse_pyproject() ^^^^^^^^^^^^^^^^^ File "C:\Users\nanzhong.he\AppData\Roaming\Python\Python312\site-packages\grafana_dashboard_manager\utils.py", line 44, in parse_pyproject with open("pyproject.toml") as file: ^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'pyproject.toml'
Same error here with Python 3.12.3 :(
Then once I create a dummy pyproject.toml in the folder i run the command, I have the following errors
[00:04:24] INFO Logging level is set to INFO utils.py:36
INFO Using Bearer token header auth grafana_api.py:59
Destination directory is not empty. Confirm overwrite? [y/n]: y
[00:04:26] INFO Pulling all dashboards into .... dashboard_download.py:36
┌─────────────────────────────── Traceback (most recent call last) ────────────────────────────────┐
│ in _run_module_as_main:198 │
│ in _run_code:88 │
│ │
│ in <module>:7 │
│ │
│ C:\Users\33614\AppData\Local\Programs\Python\Python312\Lib\site-packages\grafana_dashboard_manag │
│ er\__main__.py:94 in app │
│ │
│ 91 │ ) │
│ 92 │ │
│ 93 │ # Run the desired command │
│ > 94 │ config.func(config, client) │
│ 95 │
│ 96 │
│ 97 if __name__ == "__main__": │
│ │
│ C:\Users\33614\AppData\Local\Programs\Python\Python312\Lib\site-packages\grafana_dashboard_manag │
│ er\commands\dashboard_download.py:39 in download_dashboards │
│ │
│ 36 │ logger.info(f"Pulling all dashboards into {destination_dir}...") │
│ 37 │ │
│ 38 │ # Get the folders to replicate locally in the destination_dir │
│ > 39 │ folders = client.folders.all_folders() │
│ 40 │ │
│ 41 │ # Keeps track of folders and the dashboards they contain │
│ 42 │ folder_dashboards: dict[str, DashboardFolderLookup] = { │
│ │
│ C:\Users\33614\AppData\Local\Programs\Python\Python312\Lib\site-packages\grafana_dashboard_manag │
│ er\handlers\api_folders.py:33 in all_folders │
│ │
│ 30 │ │ """Get a list of all folders""" │
│ 31 │ │ response = self.api.get("folders") │
│ 32 │ │ body = response.json() │
│ > 33 │ │ return [Folder.model_validate(folder) for folder in body] │
│ 34 │ │
│ 35 │ def dashboards_in_folder(self, folder_id: int) -> list[DashboardSearchResult]: │
│ 36 │ │ """Get a list of all dashboards within a given folder""" │
│ │
│ C:\Users\33614\AppData\Local\Programs\Python\Python312\Lib\site-packages\pydantic\main.py:551 in │
│ model_validate │
│ │
│ 548 │ │ """ │
│ 549 │ │ # `__tracebackhide__` tells pytest and some other tools to omit this function fr │
│ 550 │ │ __tracebackhide__ = True │
│ > 551 │ │ return cls.__pydantic_validator__.validate_python( │
│ 552 │ │ │ obj, strict=strict, from_attributes=from_attributes, context=context │
│ 553 │ │ ) │
│ 554 │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
ValidationError: 1 validation error for Folder
Input should be a valid dictionary or instance of Folder [type=model_type, input_value='extra', input_type=str]
For further information visit https://errors.pydantic.dev/2.7/v/model_type
I created a Cloud Access Policy on Grafana Cloud with scope stack-dashboards: read
@NanzhongHE @nvuillam
Thanks for your reports - the issue has been fixed in the new release, v0.2.10.
Then once I create a dummy pyproject.toml in the folder i run the command, I have the following errors
[00:04:24] INFO Logging level is set to INFO utils.py:36 INFO Using Bearer token header auth grafana_api.py:59 Destination directory is not empty. Confirm overwrite? [y/n]: y [00:04:26] INFO Pulling all dashboards into .... dashboard_download.py:36 ┌─────────────────────────────── Traceback (most recent call last) ────────────────────────────────┐ │ in _run_module_as_main:198 │ │ in _run_code:88 │ │ │ │ in <module>:7 │ │ │ │ C:\Users\33614\AppData\Local\Programs\Python\Python312\Lib\site-packages\grafana_dashboard_manag │ │ er\__main__.py:94 in app │ │ │ │ 91 │ ) │ │ 92 │ │ │ 93 │ # Run the desired command │ │ > 94 │ config.func(config, client) │ │ 95 │ │ 96 │ │ 97 if __name__ == "__main__": │ │ │ │ C:\Users\33614\AppData\Local\Programs\Python\Python312\Lib\site-packages\grafana_dashboard_manag │ │ er\commands\dashboard_download.py:39 in download_dashboards │ │ │ │ 36 │ logger.info(f"Pulling all dashboards into {destination_dir}...") │ │ 37 │ │ │ 38 │ # Get the folders to replicate locally in the destination_dir │ │ > 39 │ folders = client.folders.all_folders() │ │ 40 │ │ │ 41 │ # Keeps track of folders and the dashboards they contain │ │ 42 │ folder_dashboards: dict[str, DashboardFolderLookup] = { │ │ │ │ C:\Users\33614\AppData\Local\Programs\Python\Python312\Lib\site-packages\grafana_dashboard_manag │ │ er\handlers\api_folders.py:33 in all_folders │ │ │ │ 30 │ │ """Get a list of all folders""" │ │ 31 │ │ response = self.api.get("folders") │ │ 32 │ │ body = response.json() │ │ > 33 │ │ return [Folder.model_validate(folder) for folder in body] │ │ 34 │ │ │ 35 │ def dashboards_in_folder(self, folder_id: int) -> list[DashboardSearchResult]: │ │ 36 │ │ """Get a list of all dashboards within a given folder""" │ │ │ │ C:\Users\33614\AppData\Local\Programs\Python\Python312\Lib\site-packages\pydantic\main.py:551 in │ │ model_validate │ │ │ │ 548 │ │ """ │ │ 549 │ │ # `__tracebackhide__` tells pytest and some other tools to omit this function fr │ │ 550 │ │ __tracebackhide__ = True │ │ > 551 │ │ return cls.__pydantic_validator__.validate_python( │ │ 552 │ │ │ obj, strict=strict, from_attributes=from_attributes, context=context │ │ 553 │ │ ) │ │ 554 │ └──────────────────────────────────────────────────────────────────────────────────────────────────┘ ValidationError: 1 validation error for Folder Input should be a valid dictionary or instance of Folder [type=model_type, input_value='extra', input_type=str] For further information visit https://errors.pydantic.dev/2.7/v/model_type
I created a Cloud Access Policy on Grafana Cloud with scope stack-dashboards: read
I've created a separate issue to track this
Version:
Description: I have installed this package with
pip install grafana-dashboard-manager
, and run it withpython -m grafana-dashboard-manager -h
.And I have this error: