Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wget option Added along with a new dropdown menu #265

Merged
merged 30 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
22717ed
Some changes for the new wget code panel
guptaaryan16 Jun 26, 2023
e6ed93a
Made some more changes and refactoring
guptaaryan16 Jun 26, 2023
671cc09
Added text copy button
guptaaryan16 Jun 26, 2023
e53aac9
Merge branch 'main' of github.com:guptaaryan16/code-generator into wg…
guptaaryan16 Jun 26, 2023
a19bb7f
Merge branch 'pytorch-ignite:main' into wget_option
guptaaryan16 Jun 26, 2023
b414c57
Update PaneLeft.vue
guptaaryan16 Jun 26, 2023
dbf657c
Made some changes
guptaaryan16 Jun 26, 2023
886c501
changed the configuration of code option and download button
guptaaryan16 Jun 30, 2023
5da0df4
Made few changes in CSS styles of NavCode.vue
guptaaryan16 Jun 30, 2023
e88bcd6
Fix bug for NavDownload success message
guptaaryan16 Jun 30, 2023
bcb492b
Made final changes for the Code dropdown button
guptaaryan16 Jul 4, 2023
9394123
A minor change
guptaaryan16 Jul 4, 2023
e92d7da
Minor fixes
guptaaryan16 Jul 4, 2023
efe1642
Minor change
guptaaryan16 Jul 4, 2023
d1f3293
Minor fix
guptaaryan16 Jul 4, 2023
95b9888
Last fix
guptaaryan16 Jul 4, 2023
0f37ac9
minor change in the NavCode
guptaaryan16 Jul 4, 2023
3e03699
Merge branch 'pytorch-ignite:main' into wget_option
guptaaryan16 Jul 4, 2023
6682e82
Last fix
guptaaryan16 Jul 4, 2023
273e7a6
UI fixes
guptaaryan16 Jul 4, 2023
75e4094
Made all the required UI fixes for now
guptaaryan16 Jul 5, 2023
fc47f36
reconfigured tests
guptaaryan16 Jul 6, 2023
4dc775b
Made some changes
guptaaryan16 Jul 7, 2023
f73ed43
Added changes to CSS of NavCode and NavDownload for center alignmnet
guptaaryan16 Jul 10, 2023
aa9d21e
Added copy notification in NavCode
guptaaryan16 Jul 10, 2023
cff1ff9
Fixed issues and reformatted the NavCode tab
guptaaryan16 Jul 10, 2023
96fbb30
Fixed button styles, formatting and tests
guptaaryan16 Jul 11, 2023
8cbaecd
Merge branch 'main' of https://github.com/guptaaryan16/code-generator…
guptaaryan16 Jul 11, 2023
24d79d6
Fix tests for failing on await
guptaaryan16 Jul 13, 2023
76cfe0a
Fixed and reduced CSS for NavCode.vue
guptaaryan16 Jul 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 35 additions & 24 deletions __tests__/text-classification.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ test('text classification simple', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])

await download.saveAs('./dist-tests/text-classification-simple.zip')
await page.getByRole('button', { name: 'Code' }).click()
const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})

await downloadPromise.saveAs('./dist-tests/text-classification-simple.zip')
})

test('text classification all', async () => {
Expand Down Expand Up @@ -85,12 +88,14 @@ test('text classification all', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])

await download.saveAs('./dist-tests/text-classification-all.zip')
await page.getByRole('button', { name: 'Code' }).click()
const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})
await downloadPromise.saveAs('./dist-tests/text-classification-all.zip')
})

test('text classification launch', async () => {
Expand All @@ -107,12 +112,15 @@ test('text classification launch', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])

await download.saveAs('./dist-tests/text-classification-launch.zip')
await page.getByRole('button', { name: 'Code' }).click()
await page.getByRole('button', { name: 'Download Zip' }).click()
const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})
await downloadPromise.saveAs('./dist-tests/text-classification-launch.zip')
})

test('text classification spawn', async () => {
Expand All @@ -130,10 +138,13 @@ test('text classification spawn', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])

await download.saveAs('./dist-tests/text-classification-spawn.zip')
await page.getByRole('button', { name: 'Code' }).click()
await page.getByRole('button', { name: 'Download Zip' }).click()
const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})
await downloadPromise.saveAs('./dist-tests/text-classification-spawn.zip')
})
60 changes: 37 additions & 23 deletions __tests__/vision-classification.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ test('vision classification simple', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])
await page.getByRole('button', { name: 'Code' }).click()
await page.getByRole('button', { name: 'Download Zip' }).click()

await download.saveAs('./dist-tests/vision-classification-simple.zip')
const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})

await downloadPromise.saveAs('./dist-tests/vision-classification-simple.zip')
})

test('vision classification all', async () => {
Expand Down Expand Up @@ -85,12 +90,15 @@ test('vision classification all', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])

await download.saveAs('./dist-tests/vision-classification-all.zip')
await page.getByRole('button', { name: 'Code' }).click()
await page.getByRole('button', { name: 'Download Zip' }).click()
const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})
await downloadPromise.saveAs('./dist-tests/vision-classification-all.zip')
})

test('vision classification launch', async () => {
Expand All @@ -107,12 +115,15 @@ test('vision classification launch', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])

await download.saveAs('./dist-tests/vision-classification-launch.zip')
await page.getByRole('button', { name: 'Code' }).click()
await page.getByRole('button', { name: 'Download Zip' }).click()
const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})
await downloadPromise.saveAs('./dist-tests/vision-classification-launch.zip')
})

test('vision classification spawn', async () => {
Expand All @@ -130,10 +141,13 @@ test('vision classification spawn', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])

await download.saveAs('./dist-tests/vision-classification-spawn.zip')
await page.getByRole('button', { name: 'Code' }).click()
await page.getByRole('button', { name: 'Download Zip' }).click()
const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})
await downloadPromise.saveAs('./dist-tests/vision-classification-spawn.zip')
})
60 changes: 39 additions & 21 deletions __tests__/vision-dcgan.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ test('vision dcgan simple', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])

await download.saveAs('./dist-tests/vision-dcgan-simple.zip')
await page.getByRole('button', { name: 'Code' }).click()
await page.getByRole('button', { name: 'Download Zip' }).click()

const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})
await downloadPromise.saveAs('./dist-tests/vision-dcgan-simple.zip')
})

test('vision dcgan all', async () => {
Expand Down Expand Up @@ -85,12 +89,17 @@ test('vision dcgan all', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])
await page.getByRole('button', { name: 'Code' }).click()
await page.getByRole('button', { name: 'Download Zip' }).click()

const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})

await download.saveAs('./dist-tests/vision-dcgan-all.zip')
await downloadPromise.saveAs('./dist-tests/vision-dcgan-all.zip')
})

test('vision dcgan launch', async () => {
Expand All @@ -107,12 +116,17 @@ test('vision dcgan launch', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])
await page.getByRole('button', { name: 'Code' }).click()
await page.getByRole('button', { name: 'Download Zip' }).click()

const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})

await download.saveAs('./dist-tests/vision-dcgan-launch.zip')
await downloadPromise.saveAs('./dist-tests/vision-dcgan-launch.zip')
})

test('vision dcgan spawn', async () => {
Expand All @@ -130,10 +144,14 @@ test('vision dcgan spawn', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])
await page.getByRole('button', { name: 'Code' }).click()
await page.getByRole('button', { name: 'Download Zip' }).click()

await download.saveAs('./dist-tests/vision-dcgan-spawn.zip')
const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})
await downloadPromise.saveAs('./dist-tests/vision-dcgan-spawn.zip')
})
60 changes: 40 additions & 20 deletions __tests__/vision-segmentation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ test('vision segmentation simple', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])
await page.getByRole('button', { name: 'Code' }).click()
await page.getByRole('button', { name: 'Download Zip' }).click()

await download.saveAs('./dist-tests/vision-segmentation-simple.zip')
const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})

await downloadPromise.saveAs('./dist-tests/vision-segmentation-simple.zip')
})

test('vision segmentation all', async () => {
Expand Down Expand Up @@ -85,12 +90,17 @@ test('vision segmentation all', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])
await page.getByRole('button', { name: 'Code' }).click()
await page.getByRole('button', { name: 'Download Zip' }).click()

const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})

await download.saveAs('./dist-tests/vision-segmentation-all.zip')
await downloadPromise.saveAs('./dist-tests/vision-segmentation-all.zip')
})

test('vision segmentation launch', async () => {
Expand All @@ -107,12 +117,17 @@ test('vision segmentation launch', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])
await page.getByRole('button', { name: 'Code' }).click()
await page.getByRole('button', { name: 'Download Zip' }).click()

await download.saveAs('./dist-tests/vision-segmentation-launch.zip')
const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})

await downloadPromise.saveAs('./dist-tests/vision-segmentation-launch.zip')
})

test('vision segmentation spawn', async () => {
Expand All @@ -130,10 +145,15 @@ test('vision segmentation spawn', async () => {
await page.click('text=Loggers')
await page.click('text=config.yaml')

const [download] = await Promise.all([
page.waitForEvent('download'),
page.click('button:has-text("Download")')
])
await page.getByRole('button', { name: 'Code' }).click()
await page.getByRole('button', { name: 'Download Zip' }).click()

const downloadPromise = await page
.waitForEvent('download', { timeout: 2000 })
.catch(() => {
page.getByRole('button', { name: 'Download Zip' }).click()
return page.waitForEvent('download')
})

await download.saveAs('./dist-tests/vision-segmentation-spawn.zip')
await downloadPromise.saveAs('./dist-tests/vision-segmentation-spawn.zip')
})
41 changes: 41 additions & 0 deletions functions/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Below imports are defined in
// `external_node_modules` of [functions] in netlify.toml
// They are required for this function to run

import { v4 as uuidv4 } from 'uuid'
import JSZip from 'jszip'
import { pushToGitHub } from './utils'

const nbUid = uuidv4()
const repoOwner = process.env.VUE_APP_GH_USER
const repo = process.env.VUE_APP_GH_REPO

// This function is the one Netlify function runs on
// https://docs.netlify.com/functions/build-with-javascript/#synchronous-function-format
exports.handler = async function (event, _) {
// event is a JSON object
const data = JSON.parse(event.body)
const zip = new JSZip()
const code = data.code
const template = `ignite-${data.template}`

// As usual from Download component,
// we will zip the files and
// generate a base64 format for pushing to GitHub
// with Octokit.
for (const filename in code) {
zip.file(filename, code[filename])
}
const content = await zip.generateAsync({ type: 'base64' })
const zipRes = await pushToGitHub(
content,
`${template}.zip`,
nbUid,
repoOwner,
repo
)
return {
statusCode: 200,
body: zipRes
}
}
Loading