Skip to content

Commit

Permalink
revert main and WeatherExample
Browse files Browse the repository at this point in the history
  • Loading branch information
thadk committed Nov 30, 2023
1 parent 5266c84 commit 87f1ca0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 50 deletions.
33 changes: 16 additions & 17 deletions heat-stack/app/components/WeatherExample.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import { useLoaderData } from '@remix-run/react'
import { type loader } from '#app/root.tsx'
// import test from "@playwright/test";
// import { json } from "@remix-run/node"; // or cloudflare/deno
import { loader } from "#app/root.tsx";

Check warning on line 1 in heat-stack/app/components/WeatherExample.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

All imports in the declaration are only used as types. Use `import type`

Check warning on line 1 in heat-stack/app/components/WeatherExample.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

`#app/root.tsx` import should occur after import of `@remix-run/react`
import test from "@playwright/test";

Check warning on line 2 in heat-stack/app/components/WeatherExample.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

'test' is defined but never used
import { json } from "@remix-run/node"; // or cloudflare/deno

Check warning on line 3 in heat-stack/app/components/WeatherExample.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

'json' is defined but never used
import { useLoaderData } from "@remix-run/react";

// weather `loader` is in root.tsx

export function WeatherExample() {
const one_loader = useLoaderData<typeof loader>()
if (!one_loader.weather) {
return <div>Loading weather...</div>
}
const time: string = one_loader.weather.daily?.time[0]
const temp: number = one_loader.weather.daily?.temperature_2m_max[0]

return (
<div>
<span>
time/temp first item: {time}/{temp}
</span>
</div>
)
const one_loader = useLoaderData<typeof loader>();
if (!one_loader.weather) {
return <div>Loading weather...</div>;
}
const time: string = one_loader.weather.daily?.time[0]
const temp: number = one_loader.weather.daily?.temperature_2m_max[0]

return (
<div>
<span>time/temp first item: {time}/{temp}</span>
</div>
);
}
66 changes: 33 additions & 33 deletions heat-stack/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ import { getToast } from './utils/toast.server.ts'
import { useOptionalUser, useUser } from './utils/user.ts'

import { WeatherExample } from './components/WeatherExample.tsx'

Check warning on line 63 in heat-stack/app/root.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

`./components/WeatherExample.tsx` import should occur before import of `./styles/font.css`
import type { Weather } from './WeatherExample.d.ts'
import type { Weather } from './WeatherExample.d.ts';

Check warning on line 64 in heat-stack/app/root.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

Prefer using inline type specifiers instead of a top-level type-only import

import * as pyodideModule from 'pyodide'

Check warning on line 66 in heat-stack/app/root.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

`pyodide` import should occur before import of `react`
import engine from '../../rules-engine/src/rules_engine/engine.py'
import engine from '../../rules-engine/src/rules_engine/engine.py';

const getPyodide = async () => {
// public folder:
Expand All @@ -74,12 +74,13 @@ const getPyodide = async () => {
}

const runPythonScript = async () => {
const pyodide: any = await getPyodide()
const pyodide: any = await getPyodide();
// console.log(engine);
await pyodide.loadPackage('numpy')
await pyodide.runPythonAsync(engine)
return pyodide
}
await pyodide.loadPackage("numpy")
await pyodide.runPythonAsync(engine);
return pyodide;
};


export const links: LinksFunction = () => {
return [
Expand Down Expand Up @@ -158,9 +159,8 @@ export async function loader({ request }: DataFunctionArgs) {
const { confettiId, headers: confettiHeaders } = getConfetti(request)

// Weather station data
const w_href: string =
'https://archive-api.open-meteo.com/v1/archive?latitude=52.52&longitude=13.41&daily=temperature_2m_max&timezone=America%2FNew_York&start_date=2022-01-01&end_date=2023-08-30&temperature_unit=fahrenheit'
const w_res: Response = await fetch(w_href)
const w_href: string = 'https://archive-api.open-meteo.com/v1/archive?latitude=52.52&longitude=13.41&daily=temperature_2m_max&timezone=America%2FNew_York&start_date=2022-01-01&end_date=2023-08-30&temperature_unit=fahrenheit';
const w_res: Response = await fetch(w_href);
const weather: Weather = (await w_res.json()) as Weather

return json(
Expand Down Expand Up @@ -235,17 +235,17 @@ function Document({
theme?: Theme
env?: Record<string, string>
}) {
const [output, setOutput] = useState<string | null>('(loading python...)')
const [output, setOutput] = useState<string | null>('(loading python...)');

useEffect(() => {
const run = async () => {
const pyodide: any = await runPythonScript()
// console.log(pyodide);
const result = await pyodide.runPythonAsync('hdd(57, 60)')
setOutput(result)
}
run()
}, [])
const pyodide: any = await runPythonScript();
// console.log(pyodide);
const result = await pyodide.runPythonAsync("hdd(57, 60)");
setOutput(result);
};
run();
}, []);
return (
<html lang="en" className={`${theme} h-full overflow-x-hidden`}>
<head>
Expand All @@ -256,21 +256,21 @@ function Document({
<Links />
</head>
<body className="bg-background text-foreground">
<div>
<div>Output:</div>
{output}
</div>
<WeatherExample />
{children}
<script
nonce={nonce}
dangerouslySetInnerHTML={{
__html: `window.ENV = ${JSON.stringify(env)}`,
}}
/>
<ScrollRestoration nonce={nonce} />
<Scripts nonce={nonce} />
<LiveReload nonce={nonce} />
<div>
<div>Output:</div>
{output}
</div>
<WeatherExample />
{children}
<script
nonce={nonce}
dangerouslySetInnerHTML={{
__html: `window.ENV = ${JSON.stringify(env)}`,
}}
/>
<ScrollRestoration nonce={nonce} />
<Scripts nonce={nonce} />
<LiveReload nonce={nonce} />
</body>
</html>
)
Expand Down

0 comments on commit 87f1ca0

Please sign in to comment.