Skip to content
Merged
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0f82489
Added functionality for merging of common and specific templates
theory-in-progress Jun 17, 2023
b3a6a3f
Merge common and Specific code-templates
theory-in-progress Jun 20, 2023
8f67e46
Handle error code-tag is present in a file but file is missing in Com…
theory-in-progress Jun 20, 2023
bc688be
Update branch with changes from main
theory-in-progress Jun 21, 2023
83f4051
Merge branch 'pytorch-ignite:main' into merge-common-specific
theory-in-progress Jun 21, 2023
463d004
Code format
theory-in-progress Jun 21, 2023
b044f5e
Changed code tag to `from_template_common`
theory-in-progress Jun 21, 2023
bb04373
Refactoring the redundant/repeating code in utils.py
theory-in-progress Jun 21, 2023
5ed9d8c
Fix lint of utils.py
theory-in-progress Jun 21, 2023
c3d1eed
Refactoring the redundant/repeating code in config.yaml
theory-in-progress Jun 21, 2023
e474921
Refactoring the redundant/repeating code in main.py
theory-in-progress Jun 21, 2023
ac621bf
MOdify lint options
theory-in-progress Jun 21, 2023
6d9415f
Deleting the script check_copies.py and the command in workflow
theory-in-progress Jun 22, 2023
d9888dd
Add lint in tests and modify min_lint in lint
theory-in-progress Jun 22, 2023
7703a72
Merge branch 'main' into merge-common-specific
vfdev-5 Jun 22, 2023
c5c9ae0
Modify render with replace using js on vision-classification template
theory-in-progress Jun 22, 2023
bb5b106
Merge branch 'merge-common-specific' of github.com:theory-in-progress…
theory-in-progress Jun 22, 2023
4f965b1
Install formatting tools in tests job
theory-in-progress Jun 22, 2023
da90ef3
Change code tags from `#:::- from_template_common :::#` to `#::= from…
theory-in-progress Jun 22, 2023
23e2385
Modifying trainers.py to include the if else statements for unused im…
theory-in-progress Jun 22, 2023
d738012
Removes any usort skip statements in the final code
theory-in-progress Jun 23, 2023
ff45072
Added usort skip statements for certain imports in trainers.py
theory-in-progress Jun 23, 2023
38c0f80
Modified tests, imports, workflow
theory-in-progress Jun 23, 2023
733b9ea
Added type hints for functions in template-vision-segmentation/traine…
theory-in-progress Jun 23, 2023
eb75d1d
Formatting modifications
theory-in-progress Jun 23, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ export function saveConfig(key, value) {
}
}

// merges the code from the common and specific files using ejs
function mergeCode(specificFileText, commonFileText) {
const replaced = ejs.render(specificFileText, {
replace_here: commonFileText
})
return replaced
}

// render the code if there are fetched files for current selected template
export function genCode() {
const currentFiles = files[store.config.template]
Expand Down Expand Up @@ -98,7 +106,14 @@ export async function fetchTemplates(template) {
files[template] = {}
for (const filename of templates[template]) {
const response = await fetch(`${url}/${template}/${filename}`)
files[template][filename] = await response.text()
const text_specific = await response.text()
// Dynamically fetch the common templates-code, if the file exists in common,
// then render the replace_here code tag using ejs template
// If the file doesn't exist in common, then it will fetch an empty string
// then the code tag is replaced with empty string
const res_common = await fetch(`${url}/template-common/${filename}`)
const text_common = await res_common.text()
files[template][filename] = mergeCode(text_specific, text_common)
}

// calling genCode explicitly here
Expand Down