Skip to content

Commit

Permalink
Spacy Example Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
KanushkaGupta committed May 12, 2024
1 parent 6830bfc commit ffc5db5
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/spacy/instruction_spacy.md.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{# Kanushka's code #}
# Spacy Installation Instruction
{% if os == 'Windows' %}
{% if platform == 'x86' %}
{% if package_manager == 'pip' %}
{% if hardware == 'CPU' %}
{% if configuration == 'virtual env' %}
{% if pipeline == 'efficiency' %}
`pip install -U spacy`
{% else %}
> [!IMPORTANT]
> Error!
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% else %}
{% if package_manager == 'conda' %}
{% if hardware == 'CPU' %}
{% if configuration == 'virtual env' %}
{% if pipeline == 'efficiency' %}
`conda install -c conda-forge spacy`
53 changes: 53 additions & 0 deletions examples/spacy/instruction_spacy.schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
$schema: https://json-schema.org/draft/2020-12/schema
$id: https://github.com/instructions-d-installation/installation-instruction/examples/spacy/schema_spacy.yml
title: Spacy Install Schema
description: This is a schema which is used for constructing interactive installation instructions.
type: object
$comment: by Kanushka Gupta
properties:
os:
enum:
- macOs/OSX
- Windows
- Linux
platform:
enum:
- x86
- ARM/M1
package_manager:
enum:
- pip
- conda
- from source
hardware:
enum:
- CPU
- GPU
enum:
- CUDA 8.0
- CUDA 9.0
- CUDA 9.1
- CUDA 9.2
- CUDA 10.0
- CUDA 10.1
- CUDA 10.2
- CUDA 11.0
- CUDA 11.1
- CUDA 11.2 - 11.x
- CUDA 12.x
configuration:
enum:
- virtual env
- train models
pipeline:
enum:
- efficiency
- accuracy

required:
- os
- platform
- package_manager
- hardware
- configuration
- pipeline
6 changes: 6 additions & 0 deletions examples/spacy/user_input.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
os: Windows
platform: x86
package_manager: pip
hardware: CPU
configuration: virtual env
pipeline: efficiency
6 changes: 6 additions & 0 deletions examples/spacy/user_input_2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
os: Windows
platform: x86
package_manager: conda
hardware: GPU
configuration: virtual env
pipeline: efficiency
40 changes: 40 additions & 0 deletions examples/spacy/validate_user_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
try:
from yaml import CLoader as Loader, CDumper as Dumper, load
except ImportError:
from yaml import Loader, Dumper

from jsonschema import validate

from jinja2 import Template



def load_yml(path: str) -> dict:
with open(path, 'r') as file:
input_str = file.read()

return load(input_str, Loader=Loader)

def load_template(path: str) -> Template:
with open(path, 'r') as file:
template_str = file.read()

return Template(template_str)




schema = load_yml('instruction_spacy.schema.yml')
input = load_yml('user_input_2.yml')


print("Test valid input.")
validate(input, schema)
print("It worked!")



template = load_template("instruction_spacy.md.jinja")

instructions = template.render(input)
print(instructions)

0 comments on commit ffc5db5

Please sign in to comment.