Skip to content

Commit 4ef8eb4

Browse files
committed
initial commit
1 parent d05c401 commit 4ef8eb4

File tree

10 files changed

+963
-47
lines changed

10 files changed

+963
-47
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"username": "_SYSTEM",
2929
"password": "SYS"
3030
}
31-
]
31+
],
32+
"python.pythonPath": "/usr/local/bin/python3"
3233

3334
}

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ARG IMAGE=intersystemsdc/irishealth-community:2020.3.0.200.0-zpm
55
ARG IMAGE=intersystemsdc/iris-community:2020.3.0.200.0-zpm
66
ARG IMAGE=intersystemsdc/iris-community:2020.3.0.221.0-zpm
77
ARG IMAGE=intersystemsdc/iris-community:2020.4.0.524.0-zpm
8+
ARG IMAGE=intersystemsdc/iris-ml-community:2020.3.0.302.0-zpm
89
FROM $IMAGE
910

1011
USER root
@@ -14,6 +15,7 @@ RUN chown ${ISC_PACKAGE_MGRUSER}:${ISC_PACKAGE_IRISGROUP} /opt/irisbuild
1415
USER ${ISC_PACKAGE_MGRUSER}
1516

1617
#COPY Installer.cls .
18+
COPY python python
1719
COPY src src
1820
COPY module.xml module.xml
1921
COPY iris.script iris.script

data/titanic.csv

Lines changed: 892 additions & 0 deletions
Large diffs are not rendered by default.

dev.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ zn "%SYS" \
5858

5959
zw ##class(community.csvgen).GenerateFromURL("https://github.com/h2oai/h2o-tutorials/raw/master/h2o-world-2017/automl/data/product_backorders.csv")
6060

61+
d ##class(dc.python.test).TitanicMeanAge()

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
restart: always
88
ports:
99
- 1972
10-
- 52773
10+
- 55037:52773
1111
- 53773
1212
volumes:
1313
- ./:/irisrun/repo

module.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Export generator="Cache" version="25">
3-
<Document name="objectscript-template.ZPM">
3+
<Document name="iris-python-template.ZPM">
44
<Module>
5-
<Name>objectscript-template</Name>
6-
<Version>1.1.2</Version>
5+
<Name>iris-python-template</Name>
6+
<Version>0.0.1</Version>
77
<Packaging>module</Packaging>
88
<SourcesRoot>src</SourcesRoot>
9-
<Resource Name="dc.PackageSample.PKG"/>
9+
<Resource Name="dc.python.PKG"/>
10+
<FileCopy Name="python/" Target="${mgrdir}python/"/>
1011
</Module>
1112
</Document>
1213
</Export>

python/sample.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import numpy as np
2+
import pandas as pd
3+
4+
def hello():
5+
return "world"
6+
7+
def meanage(filename="titanic.csv"):
8+
# Read data
9+
titanic = pd.read_csv(filename,",")
10+
11+
# Set passenger ages to a NumPy array
12+
passenger_ages = titanic['Age']
13+
#print(passenger_ages)
14+
15+
# Use numpy to calculate the mean age of passengers
16+
mean_age = np.nanmean(passenger_ages)
17+
18+
#print(mean_age)
19+
20+
return str(mean_age)
21+
22+
#print(meanage())

src/dc/PackageSample/ObjectScript.cls

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

src/dc/PackageSample/PersistentClass.cls

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

src/dc/python/test.cls

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Class dc.python.test
2+
{
3+
4+
ClassMethod HelloWorld() As %Status
5+
{
6+
Set sc = $$$OK
7+
Set b = ##class(%SYS.Python).Import("builtins")
8+
Do b.print("Hello world")
9+
Return sc
10+
}
11+
12+
ClassMethod Today() As %Status
13+
{
14+
Set sc = $$$OK
15+
Set dt = ##class(%SYS.Python).Import("datetime")
16+
write dt.date.today().isoformat()
17+
Return sc
18+
}
19+
20+
ClassMethod Hello() As %Status
21+
{
22+
Set sc = $$$OK
23+
Set sm = ##class(%SYS.Python).Import("sample")
24+
write sm.hello()
25+
Return sc
26+
}
27+
28+
/// Titanic
29+
ClassMethod TitanicMeanAge() As %Status
30+
{
31+
Set sc = $$$OK
32+
set tt=##class(%SYS.Python).Import("sample")
33+
set mean=tt.meanage("/irisrun/repo/data/titanic.csv")
34+
write "mean age="_mean
35+
Return sc
36+
}
37+
38+
}

0 commit comments

Comments
 (0)