Skip to content

Commit 8436265

Browse files
committed
load data from releases
1 parent f682b67 commit 8436265

File tree

9 files changed

+133
-728466
lines changed

9 files changed

+133
-728466
lines changed

.vscode/launch.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
{
2-
3-
"objectscript": {
4-
"conn": {
2+
"objectscript.conn": {
53
"https": false,
6-
"ns": "PYTHON",
4+
"ns": "IRISAPP",
75
"active": true,
86
"username": "_SYSTEM",
97
"password": "SYS",
108
"docker-compose": {
11-
"service": "iris",
12-
"internalPort": 52773
13-
},
9+
"service": "iris",
10+
"internalPort": 52773
11+
},
1412
"links": {
15-
"WebTerminal": "http://localhost:${port}/terminal/",
16-
"MLToolkit Demos": "http://localhost:${port}/csp/user/index.html"
13+
"WebTerminal": "http://localhost:${port}/terminal/"
1714
}
18-
}
1915
}
2016

2117
}

Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
ARG IMAGE=store/intersystems/iris-community:2020.1.0.204.0
22
ARG IMAGE=intersystemsdc/iris-community:2020.1.0.209.0-zpm
33
ARG IMAGE=intersystemsdc/iris-community:2020.2.0.196.0-zpm
4-
ARG IMAGE=intersystemscommunity/mlte:latest
5-
ARG IMAGE=intersystemscommunity/mlte:aa
4+
ARG IMAGE=intersystemsdc/iris-ml-community
65
FROM $IMAGE
76

87
USER root
@@ -21,7 +20,6 @@ SHELL ["/irissession.sh"]
2120
RUN \
2221
do $SYSTEM.OBJ.Load("Installer.cls", "ck") \
2322
set sc = ##class(App.Installer).setup() \
24-
zn "PYTHON" \
2523
zpm "install webterminal"
2624

2725
# bringing the standard shell back

Installer.cls

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,23 @@ XData setup
55
{
66
<Manifest>
77
<Default Name="SourceDir" Value="#{$system.Process.CurrentDirectory()}src"/>
8-
<Default Name="Namespace" Value="PYTHON"/>
9-
<Namespace Name="${Namespace}" Create="no">
8+
<Default Name="Namespace" Value="IRISAPP"/>
9+
<Namespace Name="${Namespace}" Create="yes" Code="${Namespace}-CODE" Data="${Namespace}-DATA">
10+
<Configuration>
11+
<Database Name="${Namespace}-CODE" Dir="/opt/irisapp/${Namespace}/code" Create="yes" Resource="%DB_${Namespace}"/>
12+
<Database Name="${Namespace}-DATA" Dir="/opt/irisapp/${Namespace}/data" Create="yes" Resource="%DB_${Namespace}"/>
13+
</Configuration>
1014
<Import File="${SourceDir}" Flags="ck" Recurse="1"/>
1115
</Namespace>
1216
<RunInstall Class="App.Installer" Method="DefaultNS"/>
13-
<Invoke Class="App.Installer" Method="BuildIndex" CheckStatus="1"/>
17+
18+
<Invoke Class="App.Installer" Method="LoadFreshData" CheckStatus="1">
19+
<Arg Value="${Namespace}"/>
20+
</Invoke>
21+
22+
<Invoke Class="App.Installer" Method="BuildIndex" CheckStatus="1">
23+
<Arg Value="${Namespace}"/>
24+
</Invoke>
1425
</Manifest>
1526
}
1627

@@ -32,13 +43,60 @@ ClassMethod DefaultNS(pVars, pLogLevel, tInstaller) As %Status
3243
Quit tSC
3344
}
3445

35-
ClassMethod BuildIndex() As %Status
46+
ClassMethod BuildIndex(NameSpace) As %Status
3647
{
37-
Zn "PYTHON"
48+
zn NameSpace
3849
Set tSC = ##class(community.post).%BuildIndices()
3950
Set tSC = ##class(community.tag).%BuildIndices()
4051
Set tSC = ##class(community.comment).%BuildIndices()
4152
Quit tSC
4253
}
4354

55+
/// Loading data from releases
56+
ClassMethod LoadFreshData(NameSpace) As %Status
57+
{
58+
w "Loading data from GitHub", !
59+
Set sc = $$$OK
60+
set $namespace = NameSpace
61+
62+
set owner = "intersystems-community"
63+
set repo = "posts-and-tags"
64+
65+
set ns = $namespace
66+
set $namespace = "%SYS"
67+
set prop("Protocols") = 24
68+
set sc = ##class(Security.SSLConfigs).Create("GitHub", .prop)
69+
set $namespace = ns
70+
71+
// Setup request config
72+
set url = "https://api.github.com/repos/"_owner_"/"_repo_"/releases/latest"
73+
set request = ##class(%Net.HttpRequest).%New()
74+
set request.SSLConfiguration = "GitHub"
75+
76+
// Get asset link
77+
do request.Get(url)
78+
set reqData = {}.%FromJSON(request.HttpResponse.Data.Read(99999999))
79+
set downloadUrl = reqData.assets.%Get(0)."browser_download_url"
80+
81+
// get asset file
82+
do request.Get(downloadUrl)
83+
set fn = "globals.gz"
84+
set s=##class(%Stream.FileBinary).%New()
85+
do s.LinkToFile(fn)
86+
do s.CopyFrom(request.HttpResponse.Data)
87+
do s.%Save()
88+
kill s
89+
90+
// Load globals
91+
set s = ##class(%Stream.FileBinaryGzip).%New()
92+
do s.LinkToFile(fn)
93+
do $SYSTEM.OBJ.LoadStream(s)
94+
kill s
95+
96+
// Delete temp file
97+
do ##class(%File).Delete(fn)
98+
99+
Return sc
100+
}
101+
44102
}

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
dockerfile: Dockerfile
88
restart: always
99
ports:
10-
- 51773:51773
11-
- 52773:52773
10+
- 51773
11+
- 52773
1212
volumes:
1313
- ./:/irisdev/app

module.xml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
<Document name="posts-and-tags.ZPM">
44
<Module>
55
<Name>posts-and-tags</Name>
6-
<Version>0.0.3</Version>
7-
<Description>Developer Community posts and tags</Description>
6+
<Version>0.1.0</Version>
7+
<Description>Developer Community posts and tags</Description>
88
<Packaging>module</Packaging>
99
<SourcesRoot>src</SourcesRoot>
10-
<Resource Name="community.PKG" Directory="cls"/>
11-
<Resource Name="community.comment.GBL" Directory="gbl"/>
12-
<Resource Name="community.post.GBL" Directory="gbl"/>
13-
<Resource Name="Community.tag.GBL" Directory="gbl"/>
10+
<Resource Name="community.PKG" Directory="cls"/>
11+
<Resource Name="Community.tag.GBL" Directory="gbl"/>
1412
</Module>
1513
</Document>
1614
</Export>

src/cls/community/deploy.cls

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/// Deployment class
2+
Class community.deploy
3+
{
4+
5+
ClassMethod Run(NameSpace) As %Status
6+
{
7+
w "Loading data from GitHub", !
8+
Set sc = $$$OK
9+
set $namespace = ""
10+
11+
set owner = "intersystems-community"
12+
set repo = "posts-and-tags"
13+
14+
set ns = $namespace
15+
set $namespace = "%SYS"
16+
if ('##class(Security.SSLConfigs).Exists("GitHub")) {
17+
set prop("Protocols") = 24
18+
set sc = ##class(Security.SSLConfigs).Create("GitHub", .prop)
19+
}
20+
set $namespace = ns
21+
22+
// Setup request config
23+
set url = "https://api.github.com/repos/"_owner_"/"_repo_"/releases/latest"
24+
set request = ##class(%Net.HttpRequest).%New()
25+
set request.SSLConfiguration = "GitHub"
26+
27+
// Get asset link
28+
do request.Get(url)
29+
set reqData = {}.%FromJSON(request.HttpResponse.Data.Read(99999999))
30+
set downloadUrl = reqData.assets.%Get(0)."browser_download_url"
31+
32+
// get asset file
33+
do request.Get(downloadUrl)
34+
set fn = "globals.gz"
35+
set s=##class(%Stream.FileBinary).%New()
36+
do s.LinkToFile(fn)
37+
do s.CopyFrom(request.HttpResponse.Data)
38+
do s.%Save()
39+
kill s
40+
41+
// Load globals
42+
set s = ##class(%Stream.FileBinaryGzip).%New()
43+
do s.LinkToFile(fn)
44+
do $SYSTEM.OBJ.LoadStream(s)
45+
kill s
46+
47+
// Delete temp file
48+
do ##class(%File).Delete(fn)
49+
50+
Set sc = ##class(community.post).%BuildIndices()
51+
Set sc = ##class(community.tag).%BuildIndices()
52+
Set sc = ##class(community.comment).%BuildIndices()
53+
54+
Return sc
55+
}
56+
57+
}

0 commit comments

Comments
 (0)