superset 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/CHANGELOG.md +3 -3
- data/doc/migrating_dashboards_across_environments.md +4 -4
- data/lib/superset/dashboard/import.rb +74 -25
- data/lib/superset/version.rb +1 -1
- data/superset.gemspec +2 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddf012f64fba5d3e1fe7584f41fc5ddcbdf9b20dea686efca47ae99e9e228c58
|
4
|
+
data.tar.gz: 9295923ac58ea7f24d92e978f94d8bbcbb6c06dd4cc821de4d67c3b57ebd08d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 563f5e16113862396196f5b0bbfe8fc96b2edce69d14089e464592f3770a9da156d50ebacc2098e6b4fc1a7766c568571d25a33507db86c2641d92ac5f518ea7
|
7
|
+
data.tar.gz: 8a02610f9d42328bff42753363ddb651924af87da82abfcd9311a16dd8ab9293e1f035d4f6e60e097e7f82c1b28165d5a009dfae4de0b1c0b1d8b16a2f00f704
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
## Change Log
|
2
2
|
|
3
|
+
## 0.2.6 - 2025-08-05
|
4
|
+
* Bump terminal-table from 1.8.0 to 4.0.0
|
5
|
+
|
3
6
|
## 0.2.5 - 2025-05-22
|
4
7
|
* add refresh dataset call in `Superset::Dataset::Refresh.call(id)`
|
5
8
|
|
@@ -79,6 +82,3 @@
|
|
79
82
|
- add security/user endpoints
|
80
83
|
- add security/role endpoints
|
81
84
|
- add security/role/permission endpoints
|
82
|
-
|
83
|
-
|
84
|
-
|
@@ -20,12 +20,12 @@ Assuming your API env for ruby is setup for your target superset environment.
|
|
20
20
|
|
21
21
|
new_import_zip = Superset::Services::ImportDashboardAcrossEnvironments.new(
|
22
22
|
dashboard_export_zip: 'path_to/dashboard_101_export_20241010.zip',
|
23
|
-
target_database_yaml_file: 'path_to/env2_db_config.yaml',
|
24
|
-
target_database_schema: 'acme',
|
23
|
+
target_database_yaml_file: 'path_to/env2_db_config.yaml',
|
24
|
+
target_database_schema: 'acme',
|
25
25
|
).perform
|
26
26
|
|
27
27
|
# now import the adjusted zip to the target superset env
|
28
|
-
Superset::Dashboard::Import.new(
|
28
|
+
Superset::Dashboard::Import.new(source: new_import_file).perform
|
29
29
|
|
30
30
|
```
|
31
31
|
|
@@ -170,4 +170,4 @@ It will attempt to update the same dashboard as the UUID for the dashboard has n
|
|
170
170
|
|
171
171
|
Some helpful references relating to cross-environment workflows:
|
172
172
|
- [Managing Content Across Workspaces](https://docs.preset.io/docs/managing-content-across-workspaces)
|
173
|
-
- [Superset Slack AI Explanation](https://apache-superset.slack.com/archives/C072KSLBTC1/p1722382347022689)
|
173
|
+
- [Superset Slack AI Explanation](https://apache-superset.slack.com/archives/C072KSLBTC1/p1722382347022689)
|
@@ -1,29 +1,32 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Import the provided Dashboard zip file or directory (aka source)
|
2
4
|
# In the context of this API import process, assumption is that the database.yaml file details will match
|
3
5
|
# an existing database in the Target Superset Environment.
|
4
6
|
|
5
7
|
# Scenario 1: Export from Env1 -- Import to Env1 into the SAME Environment
|
6
|
-
# Will result in updating/over writing the dashboard with the contents of the
|
8
|
+
# Will result in updating/over writing the dashboard with the contents of the source
|
7
9
|
|
8
10
|
# Scenario 2: Export from Env1 -- Import to Env2 into a DIFFERENT Environment
|
9
|
-
# Assumption is that the database.yaml will match a database configuration in the target env.
|
10
|
-
# Initial import will result in creating a new dashboard with the contents of the
|
11
|
-
# Subsequent imports will result in updating/over writing the previous imported dashboard with the contents of the
|
11
|
+
# Assumption is that the database.yaml will match a database configuration in the target env.
|
12
|
+
# Initial import will result in creating a new dashboard with the contents of the source.
|
13
|
+
# Subsequent imports will result in updating/over writing the previous imported dashboard with the contents of the source.
|
12
14
|
|
13
15
|
# the overwrite flag will determine if the dashboard will be updated or created new
|
14
16
|
# overwrite: false .. will result in an error if a dashboard with the same UUID already exists
|
15
17
|
|
16
18
|
# Usage
|
17
|
-
# Superset::Dashboard::Import.new(
|
19
|
+
# Superset::Dashboard::Import.new(source: '/tmp/dashboard.zip').perform
|
20
|
+
# Superset::Dashboard::Import.new(source: '/tmp/dashboard').perform
|
18
21
|
#
|
19
22
|
|
20
23
|
module Superset
|
21
24
|
module Dashboard
|
22
25
|
class Import < Request
|
23
|
-
attr_reader :
|
26
|
+
attr_reader :source, :overwrite
|
24
27
|
|
25
|
-
def initialize(
|
26
|
-
@
|
28
|
+
def initialize(source:, overwrite: true)
|
29
|
+
@source = source
|
27
30
|
@overwrite = overwrite
|
28
31
|
end
|
29
32
|
|
@@ -42,16 +45,20 @@ module Superset
|
|
42
45
|
private
|
43
46
|
|
44
47
|
def validate_params
|
45
|
-
raise ArgumentError,
|
46
|
-
raise ArgumentError,
|
47
|
-
raise ArgumentError,
|
48
|
-
raise ArgumentError,
|
49
|
-
|
48
|
+
raise ArgumentError, "source is required" if source.nil?
|
49
|
+
raise ArgumentError, "source does not exist" unless File.exist?(source)
|
50
|
+
raise ArgumentError, "source is not a zip file or directory" unless zip? || directory?
|
51
|
+
raise ArgumentError, "overwrite must be a boolean" unless [true, false].include?(overwrite)
|
52
|
+
|
53
|
+
return unless database_config_not_found_in_superset.present?
|
54
|
+
|
55
|
+
raise ArgumentError,
|
56
|
+
"target database does not exist: #{database_config_not_found_in_superset}"
|
50
57
|
end
|
51
58
|
|
52
59
|
def payload
|
53
60
|
{
|
54
|
-
formData: Faraday::UploadIO.new(source_zip_file,
|
61
|
+
formData: Faraday::UploadIO.new(source_zip_file, "application/zip"),
|
55
62
|
overwrite: overwrite.to_s
|
56
63
|
}
|
57
64
|
end
|
@@ -60,24 +67,66 @@ module Superset
|
|
60
67
|
"dashboard/import/"
|
61
68
|
end
|
62
69
|
|
63
|
-
def
|
64
|
-
|
70
|
+
def zip?
|
71
|
+
File.extname(source) == ".zip"
|
65
72
|
end
|
66
73
|
|
67
|
-
def
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
74
|
+
def directory?
|
75
|
+
File.directory?(source)
|
76
|
+
end
|
77
|
+
|
78
|
+
def source_zip_file
|
79
|
+
return source if zip?
|
80
|
+
|
81
|
+
Zip::File.open(new_zip_file, Zip::File::CREATE) do |zipfile|
|
82
|
+
Dir[File.join(source, "**", "**")].each do |file|
|
83
|
+
next unless File.file?(file)
|
84
|
+
|
85
|
+
# add a base folder to the relative path: "dashboard_import_#{timestamp}"
|
86
|
+
zipfile.add(File.join("dashboard_import_#{timestamp}", relative_path(file)), file)
|
87
|
+
end
|
72
88
|
end
|
89
|
+
new_zip_file
|
90
|
+
end
|
91
|
+
|
92
|
+
def relative_path(file)
|
93
|
+
Pathname.new(file).relative_path_from(Pathname.new(source)).to_s
|
94
|
+
end
|
95
|
+
|
96
|
+
def new_zip_file
|
97
|
+
File.join(source, "dashboard_import_#{timestamp}.zip")
|
73
98
|
end
|
74
99
|
|
75
|
-
def
|
76
|
-
|
100
|
+
def timestamp
|
101
|
+
@timestamp ||= Time.now.strftime("%Y%m%d%H%M%S")
|
102
|
+
end
|
103
|
+
|
104
|
+
def database_config_not_found_in_superset
|
105
|
+
databases_details.reject { |s| superset_database_uuids_found.include?(s[:uuid]) }
|
106
|
+
end
|
107
|
+
|
108
|
+
def superset_database_uuids_found
|
109
|
+
@superset_database_uuids_found ||= databases_details.map { |i| i[:uuid] }.map do |uuid|
|
110
|
+
uuid if Superset::Database::List.new(uuid_equals: uuid).result.present?
|
111
|
+
end.compact
|
112
|
+
end
|
113
|
+
|
114
|
+
def databases_details
|
115
|
+
dashboard_config[:databases].map { |d| { uuid: d[:content][:uuid], name: d[:content][:database_name] } }
|
116
|
+
end
|
117
|
+
|
118
|
+
def dashboard_config
|
119
|
+
@dashboard_config ||= zip? ? zip_dashboard_config : directory_dashboard_config
|
77
120
|
end
|
78
121
|
|
79
122
|
def zip_dashboard_config
|
80
|
-
|
123
|
+
Superset::Services::DashboardLoader.new(dashboard_export_zip: source).perform
|
124
|
+
end
|
125
|
+
|
126
|
+
def directory_dashboard_config
|
127
|
+
Superset::Services::DashboardLoader::DashboardConfig.new(
|
128
|
+
dashboard_export_zip: "", tmp_uniq_dashboard_path: source
|
129
|
+
).config
|
81
130
|
end
|
82
131
|
end
|
83
132
|
end
|
data/lib/superset/version.rb
CHANGED
data/superset.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = "A Ruby Client for Apache Superset API"
|
12
12
|
spec.homepage = "https://github.com/rdytech/superset-client"
|
13
13
|
spec.license = "MIT"
|
14
|
-
spec.required_ruby_version = ">= 2.
|
14
|
+
spec.required_ruby_version = ">= 2.7.8"
|
15
15
|
|
16
16
|
#spec.metadata["allowed_push_host"] = ""
|
17
17
|
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
# Uncomment to register a new dependency of your gem
|
38
38
|
spec.add_dependency "dotenv", "~> 2.7"
|
39
39
|
spec.add_dependency "json", "~> 2.6"
|
40
|
-
spec.add_dependency "terminal-table", "~>
|
40
|
+
spec.add_dependency "terminal-table", "~> 4.0"
|
41
41
|
spec.add_dependency "rake", "~> 13.0"
|
42
42
|
spec.add_dependency "rollbar", "~> 3.4"
|
43
43
|
spec.add_dependency "require_all", "~> 3.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superset
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jbat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '4.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '4.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -202,6 +202,7 @@ files:
|
|
202
202
|
- ".buildkite/pipeline.yml"
|
203
203
|
- ".rspec"
|
204
204
|
- ".rubocop.yml"
|
205
|
+
- ".ruby-version"
|
205
206
|
- CHANGELOG.md
|
206
207
|
- Dockerfile
|
207
208
|
- LICENSE
|
@@ -299,14 +300,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
299
300
|
requirements:
|
300
301
|
- - ">="
|
301
302
|
- !ruby/object:Gem::Version
|
302
|
-
version: 2.
|
303
|
+
version: 2.7.8
|
303
304
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
304
305
|
requirements:
|
305
306
|
- - ">="
|
306
307
|
- !ruby/object:Gem::Version
|
307
308
|
version: '0'
|
308
309
|
requirements: []
|
309
|
-
rubygems_version: 3.
|
310
|
+
rubygems_version: 3.1.6
|
310
311
|
signing_key:
|
311
312
|
specification_version: 4
|
312
313
|
summary: A Ruby Client for Apache Superset API
|