mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Add additional pre-commit hooks (#245)
* Add and run end-of-file-fixer * Add and run trailing-whitespace * Add and run check-yaml * Add and run check-json * Add and run pretty-format-yaml * Fix comment indentation
This commit is contained in:
76
.github/workflows/build.yml
vendored
76
.github/workflows/build.yml
vendored
@@ -1,46 +1,46 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push: # Only run on merges into master that modify files under pyscriptjs/
|
||||
branches: main
|
||||
paths:
|
||||
- pyscriptjs/**
|
||||
- .github/workflows/** # Test that workflows work when changed
|
||||
push: # Only run on merges into master that modify files under pyscriptjs/
|
||||
branches: main
|
||||
paths:
|
||||
- pyscriptjs/**
|
||||
- .github/workflows/** # Test that workflows work when changed
|
||||
|
||||
pull_request: # Run on any PR that modifies files in pyscriptjs/
|
||||
paths:
|
||||
- pyscriptjs/**
|
||||
- .github/workflows/**
|
||||
pull_request: # Run on any PR that modifies files in pyscriptjs/
|
||||
paths:
|
||||
- pyscriptjs/**
|
||||
- .github/workflows/**
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest # Will be self hosted soon
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./pyscriptjs
|
||||
build:
|
||||
runs-on: ubuntu-latest # Will be self hosted soon
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./pyscriptjs
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '12.x'
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: cache-node-modules
|
||||
with:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 12.x
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: cache-node-modules
|
||||
with:
|
||||
# npm cache files are stored in `~/.npm` on Linux/macOS
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||
${{ runner.os }}-build-
|
||||
${{ runner.os }}-
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
npm install
|
||||
- name: Build pyscript
|
||||
run: |
|
||||
npm run build
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||
${{ runner.os }}-build-
|
||||
${{ runner.os }}-
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
npm install
|
||||
- name: Build pyscript
|
||||
run: |
|
||||
npm run build
|
||||
|
||||
67
.github/workflows/lint.yml
vendored
67
.github/workflows/lint.yml
vendored
@@ -1,41 +1,40 @@
|
||||
name: Lint
|
||||
|
||||
on:
|
||||
push: # Only run on merges into master that modify files under pyscriptjs/
|
||||
branches:
|
||||
- main
|
||||
|
||||
push: # Only run on merges into master that modify files under pyscriptjs/
|
||||
branches:
|
||||
- main
|
||||
|
||||
pull_request: # Run on any PR that modifies files in pyscriptjs/
|
||||
pull_request: # Run on any PR that modifies files in pyscriptjs/
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./pyscriptjs
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '12.x'
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: cache-node-modules
|
||||
with:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./pyscriptjs
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 12.x
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: cache-node-modules
|
||||
with:
|
||||
# npm cache files are stored in `~/.npm` on Linux/macOS
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||
${{ runner.os }}-build-
|
||||
${{ runner.os }}-
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
npm install
|
||||
- name: Run linter
|
||||
run: |
|
||||
npm run lint
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||
${{ runner.os }}-build-
|
||||
${{ runner.os }}-
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
npm install
|
||||
- name: Run linter
|
||||
run: |
|
||||
npm run lint
|
||||
|
||||
@@ -1,12 +1,29 @@
|
||||
# This is the configuration for pre-commit, a local framework for managing pre-commit hooks
|
||||
# Check out the docs at: https://pre-commit.com/
|
||||
|
||||
default_stages: [commit]
|
||||
repos:
|
||||
- repo: https://github.com/psf/black
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.2.0
|
||||
hooks:
|
||||
- id: end-of-file-fixer
|
||||
exclude: \.min\.js$
|
||||
- id: trailing-whitespace
|
||||
- id: check-json
|
||||
exclude: tsconfig.json
|
||||
- id: check-yaml
|
||||
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
|
||||
rev: v2.3.0
|
||||
hooks:
|
||||
- id: pretty-format-yaml
|
||||
args: [--autofix, --indent, '4']
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.3.0
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/pycqa/isort
|
||||
- id: black
|
||||
- repo: https://github.com/pycqa/isort
|
||||
rev: 5.10.1
|
||||
hooks:
|
||||
- id: isort
|
||||
- id: isort
|
||||
name: isort (python)
|
||||
args: [--profile, black]
|
||||
|
||||
@@ -124,7 +124,7 @@ HTML head. You can also link to `.whl` files directly on disk like in our [toga
|
||||
</py-env>
|
||||
```
|
||||
|
||||
If your `.whl` is not a pure Python wheel, then open a PR or issue with [pyodide](https://github.com/pyodide/pyodide) to get it added [here](https://github.com/pyodide/pyodide/tree/main/packages).
|
||||
If your `.whl` is not a pure Python wheel, then open a PR or issue with [pyodide](https://github.com/pyodide/pyodide) to get it added [here](https://github.com/pyodide/pyodide/tree/main/packages).
|
||||
If there's enough popular demand the pyodide team will likely work on supporting your package, regardless things will likely move faster if you make the PR and consult with the team to get unblocked.
|
||||
|
||||
For example, NumPy and Matplotlib are available. Notice here we're using `<py-script output="plot">`
|
||||
@@ -208,4 +208,3 @@ fig
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
|
||||
@@ -43,4 +43,4 @@ module.exports = {
|
||||
'@typescript-eslint/restrict-plus-operands': 'warn',
|
||||
'@typescript-eslint/no-empty-function': 'warn',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,4 +3,4 @@ node_modules
|
||||
|
||||
|
||||
# Ignore all HTML files
|
||||
*.html
|
||||
*.html
|
||||
|
||||
@@ -10,4 +10,4 @@ module.exports = {
|
||||
svelteIndentScriptAndStyle: true,
|
||||
tabWidth: 4,
|
||||
trailingComma: 'all',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
channels:
|
||||
- defaults
|
||||
- conda-forge
|
||||
- defaults
|
||||
- conda-forge
|
||||
dependencies:
|
||||
- python=3.9
|
||||
- pip=20.2.2
|
||||
- pytest=7
|
||||
- nodejs=16
|
||||
- black
|
||||
- isort
|
||||
- codespell
|
||||
- pre-commit
|
||||
- python=3.9
|
||||
- pip=20.2.2
|
||||
- pytest=7
|
||||
- nodejs=16
|
||||
- black
|
||||
- isort
|
||||
- codespell
|
||||
- pre-commit
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
Bokeh.set_log_level("info");
|
||||
</script>
|
||||
<link rel="stylesheet" href="../build/pyscript.css" />
|
||||
|
||||
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<py-env>
|
||||
@@ -23,7 +23,7 @@
|
||||
</py-env>
|
||||
<h1>Bokeh Example</h1>
|
||||
<div id="myplot"></div>
|
||||
|
||||
|
||||
<py-script id="main">
|
||||
import json
|
||||
import pyodide
|
||||
@@ -43,6 +43,6 @@ p_json = json.dumps(json_item(p, "myplot"))
|
||||
|
||||
Bokeh.embed.embed_item(JSON.parse(p_json))
|
||||
</py-script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
Bokeh.set_log_level("info");
|
||||
</script>
|
||||
<link rel="stylesheet" href="../build/pyscript.css" />
|
||||
|
||||
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<py-env>
|
||||
@@ -23,7 +23,7 @@
|
||||
</py-env>
|
||||
<h1>Bokeh Example</h1>
|
||||
<div id="myplot"></div>
|
||||
|
||||
|
||||
<py-script id="main">
|
||||
import asyncio
|
||||
import json
|
||||
@@ -93,6 +93,6 @@ async def show(plot, target):
|
||||
|
||||
await show(row, 'myplot')
|
||||
</py-script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import folium
|
||||
import json
|
||||
import pandas as pd
|
||||
|
||||
|
||||
from pyodide.http import open_url
|
||||
|
||||
url = (
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<link rel="stylesheet" href="../../build/pyscript.css" />
|
||||
|
||||
|
||||
<script defer src="../../build/pyscript.js"></script>
|
||||
</head>
|
||||
|
||||
@@ -40,7 +40,7 @@ def toggle_video(evt):
|
||||
handTrack.stopVideo(video.element)
|
||||
isVideo = False
|
||||
update_note.write("Video stopped")
|
||||
|
||||
|
||||
async def start_video():
|
||||
global isVideo
|
||||
update_note.write("Inside sstart video")
|
||||
@@ -61,9 +61,9 @@ async def run_detection():
|
||||
console.log("in RUN DETECTION: ");
|
||||
global model
|
||||
global isVideo
|
||||
|
||||
|
||||
console.log("...1")
|
||||
|
||||
|
||||
predictions = await model.detect(video.element)
|
||||
console.log("done...1")
|
||||
console.log("Predictions: ", predictions);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<link rel="stylesheet" href="../build/pyscript.css" />
|
||||
|
||||
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
</head>
|
||||
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
Surrogate.prototype = superclass.prototype;
|
||||
subclass.prototype = new Surrogate();
|
||||
}
|
||||
})()
|
||||
})()
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<link rel="icon" type="image/png" href="../favicon.png" />
|
||||
<link rel="stylesheet" href="../../build/pyscript.css" />
|
||||
|
||||
|
||||
<script defer src="../../build/pyscript.js"></script>
|
||||
</head>
|
||||
|
||||
@@ -69,7 +69,7 @@ def toggle_video(evt):
|
||||
handTrack.stopVideo(video.element)
|
||||
isVideo = False
|
||||
update_note.write("Video stopped")
|
||||
|
||||
|
||||
async def start_video():
|
||||
global isVideo
|
||||
update_note.write("Inside sstart video")
|
||||
@@ -91,7 +91,7 @@ async def run_detection():
|
||||
global isVideo
|
||||
global last_position
|
||||
global direction
|
||||
|
||||
|
||||
predictions = await model.detect(video.element)
|
||||
model.renderPredictions(predictions, canvas.element, context, video.element);
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
|
||||
<link rel="stylesheet" href="../build/pyscript.css" />
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
|
||||
|
||||
<py-env>
|
||||
- micrograd
|
||||
- numpy
|
||||
- matplotlib
|
||||
</py-env>
|
||||
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
|
||||
</head>
|
||||
|
||||
@@ -22,25 +22,25 @@
|
||||
<h1>Micrograd - A tiny Autograd engine (with a bite! :))</h1><br>
|
||||
<div>
|
||||
<p>
|
||||
<a href="https://github.com/karpathy/micrograd">Micrograd</a> is a tiny Autograd engine created
|
||||
by <a href="https://twitter.com/karpathy">Andrej Karpathy</a>. This app recreates the
|
||||
<a href="https://github.com/karpathy/micrograd/blob/master/demo.ipynb">demo</a>
|
||||
he prepared for this package using pyscript to train a basic model, written in Python, natively in
|
||||
<a href="https://github.com/karpathy/micrograd">Micrograd</a> is a tiny Autograd engine created
|
||||
by <a href="https://twitter.com/karpathy">Andrej Karpathy</a>. This app recreates the
|
||||
<a href="https://github.com/karpathy/micrograd/blob/master/demo.ipynb">demo</a>
|
||||
he prepared for this package using pyscript to train a basic model, written in Python, natively in
|
||||
the browser. <br>
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<p>
|
||||
You may run each Python REPL cell interactively by pressing (Shift + Enter) or (Ctrl + Enter).
|
||||
You may run each Python REPL cell interactively by pressing (Shift + Enter) or (Ctrl + Enter).
|
||||
You can also modify the code directly as you wish. If you want to run all the code at once,
|
||||
not each cell individually, you may instead click the 'Run All' button. Training the model
|
||||
not each cell individually, you may instead click the 'Run All' button. Training the model
|
||||
takes between 1-2 min if you decide to 'Run All' at once. 'Run All' is your only option if
|
||||
you are running this on a mobile device where you cannot press (Shift + Enter). After the
|
||||
model is trained, a plot image should be displayed depicting the model's ability to
|
||||
you are running this on a mobile device where you cannot press (Shift + Enter). After the
|
||||
model is trained, a plot image should be displayed depicting the model's ability to
|
||||
classify the data. <br>
|
||||
</p>
|
||||
<p>
|
||||
Currently the <code>></code> symbol is being imported incorrectly as <code>&gt;</code> into the REPL's.
|
||||
Currently the <code>></code> symbol is being imported incorrectly as <code>&gt;</code> into the REPL's.
|
||||
In this app the <code>></code> symbol has been replaced with <code>().__gt__()</code> so you can run the code
|
||||
without issue. Ex: intead of <code>a > b</code>, you will see <code>(a).__gt__(b)</code> instead. <br>
|
||||
</p>
|
||||
@@ -99,7 +99,7 @@ print("number of parameters", len(model.parameters()))
|
||||
</py-repl><br>
|
||||
|
||||
<div>
|
||||
Line 24 has been changed from: <br>
|
||||
Line 24 has been changed from: <br>
|
||||
<code>accuracy = [(yi > 0) == (scorei.data > 0) for yi, scorei in zip(yb, scores)]</code><br>
|
||||
to: <br>
|
||||
<code>accuracy = [((yi).__gt__(0)) == ((scorei.data).__gt__(0)) for yi, scorei in zip(yb, scores)]</code><br>
|
||||
@@ -108,7 +108,7 @@ print("number of parameters", len(model.parameters()))
|
||||
<py-repl auto-generate="true">
|
||||
# loss function
|
||||
def loss(batch_size=None):
|
||||
|
||||
|
||||
# inline DataLoader :)
|
||||
if batch_size is None:
|
||||
Xb, yb = X, y
|
||||
@@ -116,10 +116,10 @@ def loss(batch_size=None):
|
||||
ri = np.random.permutation(X.shape[0])[:batch_size]
|
||||
Xb, yb = X[ri], y[ri]
|
||||
inputs = [list(map(Value, xrow)) for xrow in Xb]
|
||||
|
||||
|
||||
# forward the model to get scores
|
||||
scores = list(map(model, inputs))
|
||||
|
||||
|
||||
# svm "max-margin" loss
|
||||
losses = [(1 + -yi*scorei).relu() for yi, scorei in zip(yb, scores)]
|
||||
data_loss = sum(losses) * (1.0 / len(losses))
|
||||
@@ -127,7 +127,7 @@ def loss(batch_size=None):
|
||||
alpha = 1e-4
|
||||
reg_loss = alpha * sum((p*p for p in model.parameters()))
|
||||
total_loss = data_loss + reg_loss
|
||||
|
||||
|
||||
# also get accuracy
|
||||
accuracy = [((yi).__gt__(0)) == ((scorei.data).__gt__(0)) for yi, scorei in zip(yb, scores)]
|
||||
return total_loss, sum(accuracy) / len(accuracy)
|
||||
@@ -138,25 +138,25 @@ print(total_loss, acc)
|
||||
<py-repl auto-generate="true">
|
||||
# optimization
|
||||
for k in range(20): #was 100. Accuracy can be further improved w/ more epochs (to 100%).
|
||||
|
||||
|
||||
# forward
|
||||
total_loss, acc = loss()
|
||||
|
||||
|
||||
# backward
|
||||
model.zero_grad()
|
||||
total_loss.backward()
|
||||
|
||||
|
||||
# update (sgd)
|
||||
learning_rate = 1.0 - 0.9*k/100
|
||||
for p in model.parameters():
|
||||
p.data -= learning_rate * p.grad
|
||||
|
||||
|
||||
if k % 1 == 0:
|
||||
print(f"step {k} loss {total_loss.data}, accuracy {acc*100}%")
|
||||
</py-repl><br>
|
||||
<div>
|
||||
<p>
|
||||
Please wait for the training loop above to complete. It will not print out stats until it
|
||||
Please wait for the training loop above to complete. It will not print out stats until it
|
||||
has completely finished. This typically takes 1-2 min. <br><br>
|
||||
|
||||
Line 9 has been changed from: <br>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<link rel="stylesheet" href="../build/pyscript.css" />
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<body>
|
||||
<py-env>
|
||||
- bokeh
|
||||
- numpy
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<script type="text/javascript">
|
||||
Bokeh.set_log_level("info");
|
||||
</script>
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/@holoviz/panel@0.13.0/dist/bundled/bootstraptemplate/bootstrap.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/@holoviz/panel@0.13.0/dist/bundled/defaulttheme/default.css">
|
||||
@@ -43,7 +43,7 @@
|
||||
<link rel="stylesheet" href="../build/pyscript.css" />
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
</head>
|
||||
|
||||
|
||||
<py-env>
|
||||
- altair
|
||||
- numpy
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
|
||||
#output > div:nth-child(even) {
|
||||
border: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<link rel="stylesheet" href="../build/pyscript.css" />
|
||||
<link rel="stylesheet" href="repl.css" />
|
||||
|
||||
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
</head>
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<div class="hero-body">
|
||||
<p class="title is-3">PyScript — Simple Bioinformatics Example <span class="tag is-white">v.1</span></p>
|
||||
<p class="subtitle is-6">
|
||||
Demonstrates the simple use of <a href="https://pyscript.net/" target="_blank"><code>PyScript</code></a>
|
||||
Demonstrates the simple use of <a href="https://pyscript.net/" target="_blank"><code>PyScript</code></a>
|
||||
in <strong>Bioinformatics/Computational Biology</strong> fields!
|
||||
</p>
|
||||
</div>
|
||||
@@ -58,7 +58,7 @@
|
||||
<!--- DNA Sequence Output -->
|
||||
<label class="label">Output for the <code id="operation_name_output">given operation</code></label>
|
||||
<div id="output"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br><br>
|
||||
<!-- Footer -->
|
||||
@@ -84,15 +84,15 @@ operation_element = Element("operation")
|
||||
operation_name_output_element = Element("operation_name_output")
|
||||
|
||||
# DNA Sequene Operations
|
||||
def return_reverse(dna_seq):
|
||||
def return_reverse(dna_seq):
|
||||
return dna_seq[::-1]
|
||||
def return_complement(dna_seq):
|
||||
def return_complement(dna_seq):
|
||||
return dna_seq.translate(str.maketrans("ATCG", "TAGC"))
|
||||
def return_reverse_complement(dna_seq):
|
||||
def return_reverse_complement(dna_seq):
|
||||
return dna_seq.translate(str.maketrans("ATCG", "TAGC"))[::-1]
|
||||
|
||||
# Check DNA seq is valid
|
||||
def check_dna_seq(dna_seq):
|
||||
def check_dna_seq(dna_seq):
|
||||
return all(letter in dna_alphabet for letter in dna_seq.upper())
|
||||
|
||||
# Clear the form and output
|
||||
@@ -115,7 +115,7 @@ def run(*args, **kwargs):
|
||||
output_dna_seq = return_complement(dna_seq)
|
||||
elif operation_name == "ReverseComplement":
|
||||
output_dna_seq = return_reverse_complement(dna_seq)
|
||||
|
||||
|
||||
# Output the result
|
||||
output.write(output_dna_seq)
|
||||
elif (dna_seq.strip() == "") or (dna_seq is None):
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<link rel="stylesheet" href="../build/pyscript.css" />
|
||||
|
||||
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
<py-env>
|
||||
- paths:
|
||||
@@ -34,7 +34,7 @@ async def foo():
|
||||
await asyncio.sleep(1)
|
||||
output = now()
|
||||
pyscript.write("outputDiv2", output)
|
||||
|
||||
|
||||
out3 = Element("outputDiv3")
|
||||
if output[-1] in ["0", "4", "8"]:
|
||||
out3.write("It's espresso time!")
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<link rel="stylesheet" href="/build/pyscript.css" />
|
||||
|
||||
|
||||
<script defer src="/build/pyscript.js"></script>
|
||||
<py-env>
|
||||
- paths:
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<link rel="stylesheet" href="/build/pyscript.css" />
|
||||
|
||||
|
||||
<script defer src="/build/pyscript.js"></script>
|
||||
<py-env>
|
||||
- paths:
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<main class="max-w-xs mx-auto mt-4">
|
||||
<section>
|
||||
|
||||
|
||||
<div class="text-center w-full mb-8">
|
||||
<h1 class="text-3xl font-bold text-gray-800 uppercase tracking-tight">To Do List</h1>
|
||||
</div>
|
||||
@@ -32,20 +32,20 @@
|
||||
Add task
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<py-list id="myList"></py-list>
|
||||
<div id="list-tasks-container" class="flex flex-col-reverse mt-4">
|
||||
</div>
|
||||
|
||||
|
||||
<template id="task-template">
|
||||
<section class="task bg-white my-1">
|
||||
<label for="flex items-center p-2 ">
|
||||
<input class="mr-2" type="checkbox" class="task-check">
|
||||
<p class="m-0 inline"></p>
|
||||
</label>
|
||||
</section>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
@@ -46,4 +46,4 @@ from freedom.__main__ import main
|
||||
|
||||
app = main().main_loop(spa=True)
|
||||
</py-script>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -6,4 +6,4 @@ main.toga.window {
|
||||
|
||||
div.toga.box {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
Wheels will go here.
|
||||
Wheels will go here.
|
||||
|
||||
@@ -28,7 +28,7 @@ canvas {
|
||||
a, a:hover, a:visited {
|
||||
color: red;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
.disable-selection {
|
||||
-moz-user-select: none; /* Firefox */
|
||||
-ms-user-select: none; /* Internet Explorer */
|
||||
@@ -50,4 +50,4 @@ h2::after {
|
||||
position:absolute;
|
||||
top: 14px;
|
||||
padding-left: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
|
||||
@@ -26,4 +26,4 @@
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user