Edward Beeching commited on
Commit
bee7740
β€’
1 Parent(s): 02cdabc
Files changed (4) hide show
  1. README.md +5 -4
  2. app.py +52 -0
  3. packages.txt +2 -0
  4. requirements.txt +4 -0
README.md CHANGED
@@ -1,12 +1,13 @@
1
  ---
2
- title: Sw Test
3
- emoji: πŸ¦€
4
- colorFrom: green
5
- colorTo: red
6
  sdk: streamlit
7
  sdk_version: 1.10.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Scienceworld Demo
3
+ emoji: 🌍
4
+ colorFrom: blue
5
+ colorTo: blue
6
  sdk: streamlit
7
  sdk_version: 1.10.0
8
  app_file: app.py
9
  pinned: false
10
+ license: mit
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import time
3
+ import streamlit as st
4
+ from scienceworld import ScienceWorldEnv
5
+
6
+ st.title("ScienceWorld interactive demo")
7
+
8
+ hash_env = lambda _: None
9
+
10
+ import os
11
+ stream = os.popen('java -version')
12
+ output = stream.read()
13
+
14
+ st.write('output')
15
+
16
+ @st.cache(allow_output_mutation=True)
17
+ def load_env():
18
+ simplification_str = 'easy'
19
+ task_idx = None
20
+
21
+ print('Loading envs')
22
+ step_limit = 100
23
+ env = ScienceWorldEnv("", None, step_limit, 0)
24
+
25
+ if task_idx is None:
26
+ task_idx = 13
27
+ if isinstance(task_idx, int):
28
+ task_names = env.getTaskNames()
29
+ task_name = task_names[task_idx]
30
+ else:
31
+ task_name = task_idx
32
+
33
+ # Just reset to variation 0, as another call (e.g. reset_with_variation...) will setup
34
+ # an appropriate variation (train/dev/test)
35
+ env.load(task_name, 0, simplification_str)
36
+ obs, info = env.resetWithVariation(0, simplification_str)
37
+
38
+ return env, obs, info
39
+
40
+
41
+ class RandomAgent():
42
+
43
+ def act(self, info):
44
+ return np.random.choice(info['valid'])
45
+
46
+
47
+ num_episodes = 10
48
+ env, initial_obs, initial_info = load_env()
49
+ act = st.text_input('action to perform')
50
+ st.write(f'Action: {act}')
51
+ obs, reward, done, info = env.step(act)
52
+ st.write(f'Observation: {obs.strip()}')
packages.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ default-jre
2
+ default-jdk
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ numpy
2
+ py4j
3
+ scienceworld
4
+