JanuaryDesk commited on
Commit
e235936
·
1 Parent(s): 052a6c6

Ensure .Net Setup

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +21 -66
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: JTS3DMap
3
- emoji: 📚
4
  colorFrom: red
5
  colorTo: blue
6
  sdk: gradio
 
1
  ---
2
  title: JTS3DMap
3
+ emoji: 🏞️
4
  colorFrom: red
5
  colorTo: blue
6
  sdk: gradio
app.py CHANGED
@@ -1,87 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
 
 
3
  from pythonnet import load
4
 
5
- load("coreclr", runtime_config="lib\JTSParser.runtimeconfig.json")
6
 
7
  import clr
8
  from System import Reflection
9
 
10
  import os
11
 
12
- lib_path = os.path.abspath("lib\JTSParser.dll")
13
 
14
  Reflection.Assembly.LoadFile(lib_path)
15
  import YYZ.JTS.NB
16
 
 
 
17
  import numpy as np
18
  import plotly.graph_objects as go
19
  import math
20
 
21
- """
22
- def greet(name):
23
- return "Hello " + name + "!"
24
-
25
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
26
- """
27
-
28
- def test():
29
- fig = go.Figure()
30
-
31
- fig.add_trace(go.Scatter3d(
32
- x=["2017-01-01", "2017-02-10", "2017-03-20"],
33
- y=["A", "B", "C"],
34
- z=[1, 1000, 100000],
35
- name="z",
36
- ))
37
-
38
- fig.update_layout(
39
- scene=dict(
40
- xaxis=dict(type="date"),
41
- yaxis=dict(type="category"),
42
- zaxis=dict(type="log"),
43
- annotations=[
44
- dict(
45
- showarrow=False,
46
- x="2017-01-01",
47
- y="A",
48
- z=0,
49
- text="Point 1",
50
- xanchor="left",
51
- xshift=10,
52
- opacity=0.7),
53
- dict(
54
- x="2017-02-10",
55
- y="B",
56
- z=4,
57
- text="Point 2",
58
- textangle=0,
59
- ax=0,
60
- ay=-75,
61
- font=dict(
62
- color="black",
63
- size=12
64
- ),
65
- arrowcolor="black",
66
- arrowsize=3,
67
- arrowwidth=1,
68
- arrowhead=1),
69
- dict(
70
- x="2017-03-20",
71
- y="C",
72
- z=5,
73
- ax=50,
74
- ay=0,
75
- text="Point 3",
76
- arrowhead=1,
77
- xanchor="left",
78
- yanchor="bottom"
79
- )]
80
- ),
81
- )
82
- return fig
83
-
84
-
85
  def dock(x, limit):
86
  x1 = math.floor(x)
87
  yield x1
 
1
+ # Hugging Face Hack
2
+
3
+ import subprocess
4
+ import os
5
+
6
+ try:
7
+ print(subprocess.check_output("dotnet -list-sdk"))
8
+ except:
9
+ print("Try to install .net dependency")
10
+ subprocess.run("wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh")
11
+ subprocess.run("chmod +x ./dotnet-install.sh")
12
+ subprocess.run("./dotnet-install.sh --version latest")
13
+
14
+ print(subprocess.check_output("dotnet -list-sdk"))
15
+
16
  import gradio as gr
17
 
18
+ # Setup Python.Net
19
+
20
  from pythonnet import load
21
 
22
+ load("coreclr", runtime_config="lib/JTSParser.runtimeconfig.json")
23
 
24
  import clr
25
  from System import Reflection
26
 
27
  import os
28
 
29
+ lib_path = os.path.abspath("lib/JTSParser.dll")
30
 
31
  Reflection.Assembly.LoadFile(lib_path)
32
  import YYZ.JTS.NB
33
 
34
+ # App
35
+
36
  import numpy as np
37
  import plotly.graph_objects as go
38
  import math
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  def dock(x, limit):
41
  x1 = math.floor(x)
42
  yield x1