Skip to content

Commit

Permalink
Added title, description and default fields to pytorch example schema…
Browse files Browse the repository at this point in the history
…. Added preview part to pytorch example jinja template. Removed unnecessary print statement in helpers.py.
  • Loading branch information
WyvernIXTL committed May 8, 2024
1 parent 0705ddc commit 22c2948
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 32 deletions.
16 changes: 14 additions & 2 deletions examples/pytorch/instruction_pytorch.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,37 @@ type: object
$comment: by Adam McKellar
properties:
build:
title: Build
description: Use the latest or the tested version.
anyOf:
- title: Stable (2.3.0)
const: stable
- title: Preview (Nightly)
const: preview
default: stable
os:
title: Operating System
description: The operating system you use.
anyOf:
- title: Linux
const: linux
- title: Mac
const: mac
- title: Windows
const: win
default: win
package:
title: Package Manager
description: The package manager you use.
anyOf:
- title: Conda
const: conda
- title: Pip
const: pip
computer_platform:
default: pip
compute_platform:
title: Compute Platform
description: Should your gpu or your cpu handle the task?
anyOf:
- title: CUDA 11.8
const: cu118
Expand All @@ -35,9 +46,10 @@ properties:
const: ro60
- title: CPU
const: cpu
default: cu118
required:
- build
- os
- package
- computer_platform
- compute_platform
additionalProperties: false
57 changes: 32 additions & 25 deletions examples/pytorch/instruction_pytorch.txt.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
conda install

{% if os == "mac" %}
{% if computer_platform == "cpu" %}
pytorch::pytorch torchvision torchaudio
{% if compute_platform == "cpu" %}
pytorch{{ "-nightly" if build == "preview" }}::pytorch torchvision torchaudio
{% else %}
[[ERROR]]
Mac does not support ROCm or CUDA!
Expand All @@ -13,11 +13,11 @@
{% else %}
pytorch torchvision torchaudio

{% if computer_platform == "cu118" %}
{% if compute_platform == "cu118" %}
pytorch-cuda=11.8 -c nvidia
{% elif computer_platform == "cu121" %}
{% elif compute_platform == "cu121" %}
pytorch-cuda=12.1 -c nvidia
{% elif computer_platform == "ro60" %}
{% elif compute_platform == "ro60" %}
[[ERROR]]
ROCm is currently not supported with conda on linux and not supported at all on windows!
[[ERROR]]
Expand All @@ -26,35 +26,42 @@
{% endif %}
{% endif %}

-c pytorch
-c pytorch{{ "-nightly" if build == "preview" }}

{% elif package == "pip" %}
pip3 install torch torchvision torchaudio
pip3 install {{ "--pre" if build == "preview" }} torch torchvision torchaudio

{% if os == "mac" %}
{% if computer_platform != "cpu" %}
[[ERROR]]
Mac does not support ROCm or CUDA!
[[ERROR]]
{{ "[[ERROR]] Mac does not support ROCm or CUDA! [[ERROR]]" if compute_platform != "cpu" }}
{% if build == "preview" %}
--index-url https://download.pytorch.org/whl/nightly/cpu
{% endif %}
{% else %}
{% if computer_platform == "cu118" %}
--index-url https://download.pytorch.org/whl/cu118
{% elif computer_platform == "cu121" %}
{% if os == "win" %}
--index-url https://download.pytorch.org/whl/cu121
{% endif %}
{% elif computer_platform == "ro60" %}
{% if os == "linux" %}
--index-url https://download.pytorch.org/whl/rocm6.0

{% if compute_platform == "cu118" %}
--index-url https://download.pytorch.org/whl/{{ "nightly/" if build == "preview" }}cu118

{% elif compute_platform == "cu121" %}
{% if build == "preview" %}
--index-url https://download.pytorch.org/whl/nightly/cu121
{% else %}
[[ERROR]]
Windows does not support ROCm!
[[ERROR]]
{% if os == "win" %}
--index-url https://download.pytorch.org/whl/cu121
{% endif %}
{% endif %}

{% elif compute_platform == "ro60" %}
{{ "[[ERROR]] Windows does not support ROCm! [[ERROR]]" if os != "linux" }}
--index-url https://download.pytorch.org/whl/{{ "nightly/" if build == "preview" }}rocm6.0

{# CPU #}
{% else %}
{% if os == "linux" %}
--index-url https://download.pytorch.org/whl/cpu
{% if build == "preview" %}
--index-url https://download.pytorch.org/whl/nightly/cpu
{% else %}
{% if os == "linux" %}
--index-url https://download.pytorch.org/whl/cpu
{% endif %}
{% endif %}
{% endif %}
{% endif %}
Expand Down
8 changes: 4 additions & 4 deletions examples/pytorch/potential_user_input.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build: stable
os: linux
package: conda
computer_platform: cpu
build: preview
os: win
package: pip
compute_platform: ro60
1 change: 0 additions & 1 deletion installation_instruction/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def _split_string_at_delimiter(string: str) -> tuple[str, str]:
matches = reg.search(string)
if matches is None:
raise Exception("No delimiter (------) found.")
print("HERE ", matches.group("template"))
return (
matches.group("schema"),
matches.group("template")
Expand Down

0 comments on commit 22c2948

Please sign in to comment.