Skip to content

Commit

Permalink
Fixed scikit-learn example mostly. Added unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
WyvernIXTL committed May 11, 2024
1 parent c250511 commit 6ceefe1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
50 changes: 24 additions & 26 deletions examples/scikit-learn/scikit-learn-instruction.schema.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,42 @@ $schema: https://json-schema.org/draft/2020-12/schema
$id: https://github.com/instructions-d-installation/installation-instruction/examples/scikit-learn/scikit-learn-instruction.schema.yml
title: Scikit-learn installation schema
description: This is a Schema to construct installation instructions for the python package scikit-learn by Timo Ege.

type: object
properties:
os:
title: Operating System
description: The operating system in which the package is installed.
enum:
- Windows
- macOS
- Linux
default: Windows
os:
title: Operating System
description: The operating system in which the package is installed.
enum:
- Windows
- macOS
- Linux
default: Windows

packager:
title: Packager
description: The package manager of your choosing.
enum:
- pip
- conda
default: pip
packager:
title: Packager
description: The package manager of your choosing.
enum:
- pip
- conda
default: pip

virtualenv:
title: Use pip virtualenv
description: Choose if you want to use a virtual environment to install the package.
type: boolean
default: false
virtualenv:
title: Use pip virtualenv
description: Choose if you want to use a virtual environment to install the package.
type: boolean
default: false

required:
- os
- packager
required:
- os
- packager

additionalProperties: false
additionalProperties: false

------

{% if package == "conda" %}
conda create -n sklearn-env -c conda-forge scikit-learn \n
conda activate sklearn-env
{% endif %}
{% else %}
{% if os == "Linux"%}
{% if virtualenv%}
Expand Down
14 changes: 14 additions & 0 deletions tests/test_installation_instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,17 @@ def test_validate_and_render_pytorch():

with raises(Exception):
install.validate_and_render(bad_user_input)


def test_validate_and_render_pytorch():
valid_user_input = {
"os": "Windows",
"packager": "pip",
"virtualenv": False
}

install = InstallationInstruction.from_file("examples/scikit-learn/scikit-learn-instruction.schema.yml.jinja")

good_installation_instruction = install.validate_and_render(valid_user_input)

assert ('pip install -U scikit-learn', False) == good_installation_instruction

0 comments on commit 6ceefe1

Please sign in to comment.