Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Try this?
Browse files- src/template.py +8 -1
src/template.py
CHANGED
|
@@ -11,14 +11,21 @@
|
|
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
# See the License for the specific language governing permissions and
|
| 13 |
# limitations under the License.
|
|
|
|
| 14 |
|
| 15 |
TEMPLATES = ["initial", "initial_with_metrics", "accelerate"]
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
def get_templates() -> dict:
|
| 18 |
"""
|
| 19 |
Returns a dictionary of template type to code content
|
| 20 |
"""
|
| 21 |
return {
|
| 22 |
-
template: open(
|
| 23 |
for template in TEMPLATES
|
| 24 |
}
|
|
|
|
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
# See the License for the specific language governing permissions and
|
| 13 |
# limitations under the License.
|
| 14 |
+
import os
|
| 15 |
|
| 16 |
TEMPLATES = ["initial", "initial_with_metrics", "accelerate"]
|
| 17 |
|
| 18 |
+
def _get_filename(template: str) -> str:
|
| 19 |
+
"""
|
| 20 |
+
Takes an template and returns the respective filename relative to the cwd.
|
| 21 |
+
"""
|
| 22 |
+
return os.path.join(os.getcwd(), "code_samples", template)
|
| 23 |
+
|
| 24 |
def get_templates() -> dict:
|
| 25 |
"""
|
| 26 |
Returns a dictionary of template type to code content
|
| 27 |
"""
|
| 28 |
return {
|
| 29 |
+
template: open(_get_filename(template)).read()
|
| 30 |
for template in TEMPLATES
|
| 31 |
}
|