From 304c7e1ffcd132d508ada189e728b8f8293406fe Mon Sep 17 00:00:00 2001 From: Dibyam Kumar Date: Thu, 23 Nov 2023 12:44:41 +0530 Subject: [PATCH 1/4] Fix lint errors --- .../deepchem/components/Layers/LayerCard.js | 78 +++++++++-------- new-website/deepchem/pages/layers.js | 84 +++++++++---------- 2 files changed, 77 insertions(+), 85 deletions(-) diff --git a/new-website/deepchem/components/Layers/LayerCard.js b/new-website/deepchem/components/Layers/LayerCard.js index 69e4de7c..5eb1b372 100644 --- a/new-website/deepchem/components/Layers/LayerCard.js +++ b/new-website/deepchem/components/Layers/LayerCard.js @@ -11,49 +11,47 @@ import deepchemKeras from "../../public/icons/deepchem-keras.png"; * @return {string} - The parsed and formatted string */ function parseName(name) { - name = name.replaceAll(/([A-Z]+)/g, " $1"); - name = name.replace(/([^ ])(Layer)/, "$1 Layer"); - return name; - } + name = name.replaceAll(/([A-Z]+)/g, " $1"); + name = name.replace(/([^ ])(Layer)/, "$1 Layer"); + return name; +} const LayerCard = ({ layer }) => { - let models = layer.models.length - ? layer.models.join(", ") - : "N/A"; - models = models + " " + "\xa0".repeat(300); + let models = layer.models.length ? layer.models.join(", ") : "N/A"; + models = models + " " + "\xa0".repeat(300); - return ( - <> - -
-
-
- {parseName(layer.name)} -
-
- {layer.category === "torch" && ( - PyTorch - )} - {layer.category === "keras" && ( - Keras - )} -
-
- {layer.category} -
-
- { -
-

Acceptable Models

-

- {models} -

-
- } + return ( + <> + +
+
+
+ {parseName(layer.name)}
- - - ); +
+ {layer.category === "torch" && ( + PyTorch + )} + {layer.category === "keras" && ( + Keras + )} +
+
+ {layer.category} +
+
+ { +
+

Acceptable Models

+

+ {models} +

+
+ } +
+ + + ); }; -export default LayerCard; \ No newline at end of file +export default LayerCard; diff --git a/new-website/deepchem/pages/layers.js b/new-website/deepchem/pages/layers.js index f9eeca0d..a188efaa 100644 --- a/new-website/deepchem/pages/layers.js +++ b/new-website/deepchem/pages/layers.js @@ -8,18 +8,15 @@ import FilterButton from "/components/common/FilterButton"; import layers from "/data/layers/layers.json"; import modelList from "/data/layers/models.json"; -import deepchemPyTorch from "/public/icons/deepchem-pytorch.png"; -import deepchemKeras from "/public/icons/deepchem-keras.png"; import deepchemFilter from "/public/icons/deepchem-filter.png"; - /** * Models component that displays the models page of the application * @component * @return {JSX.Element} The JSX element to render the Model component */ -const Layers = () => { +const Layers = () => { const [filteredLayers, setFilteredLayers] = useState(layers); const [models, setModels] = useState([]); const [isPopUp, setIsPopUp] = useState(false); @@ -43,9 +40,7 @@ const Layers = () => { useEffect(() => { let newlayers = []; const flayers = layers; - if ( - models.length === 0 - ) { + if (models.length === 0) { newlayers = layers; } else { flayers.map((flayer) => { @@ -73,7 +68,6 @@ const Layers = () => { }, []); return ( -
{ } fixed bg-dc-gray/80 w-full h-[100vh] top-0 lg:hidden`} onClick={handlePopUp} >
-
+
{/* HEADING BEGIN */}
Our Layers
@@ -90,41 +84,41 @@ const Layers = () => { {"Filter
- {/* HEADING END */} - {/* BODY BEGIN */} -
- {/* FILTER SECTION BEGIN */} -
- {/* MODEL BEGIN */} -
-
Model
-
- {modelList.map((model, index) => ( -
- -
- ))} -
+ {/* HEADING END */} + {/* BODY BEGIN */} +
+ {/* FILTER SECTION BEGIN */} +
+ {/* MODEL BEGIN */} +
+
Model
+
+ {modelList.map((model, index) => ( +
+ +
+ ))}
- {/* MODEL END */} - {/* LAYER CARDS SECTION BEGIN */} +
+ {/* MODEL END */} + {/* LAYER CARDS SECTION BEGIN */}
{
)}
- {/* MODEL CARDS SECTION END */} + {/* MODEL CARDS SECTION END */}
- {/*BODY END*/} + {/* BODY END */}
From a3faa19873ba94d16aa3b03c33922ea037efb341 Mon Sep 17 00:00:00 2001 From: Dibyam Kumar Date: Thu, 23 Nov 2023 12:45:06 +0530 Subject: [PATCH 2/4] Update workflow to check lint and build on pull requests to main --- ...es.yml => build_check_deploy_gh_pages.yml} | 10 +++++ new-website/deepchem/package-lock.json | 39 +++++++------------ 2 files changed, 23 insertions(+), 26 deletions(-) rename .github/workflows/{deploy_gh_pages.yml => build_check_deploy_gh_pages.yml} (78%) diff --git a/.github/workflows/deploy_gh_pages.yml b/.github/workflows/build_check_deploy_gh_pages.yml similarity index 78% rename from .github/workflows/deploy_gh_pages.yml rename to .github/workflows/build_check_deploy_gh_pages.yml index 2eb0b392..5df654ea 100644 --- a/.github/workflows/deploy_gh_pages.yml +++ b/.github/workflows/build_check_deploy_gh_pages.yml @@ -3,6 +3,8 @@ name: Deploy to gh-pages on: push: branches: [ main ] + pull_request: + branches: [main] repository_dispatch: types: [ rebuild-website ] workflow_dispatch: @@ -36,6 +38,12 @@ jobs: cd utils/models python3 get_models.py + - name: fetch and convert layer data + run: | + cd new-website + cd utils/layers + python3 get_layers.py + - name: fetch and convert tutorial data run: | sudo apt-get install jq @@ -52,7 +60,9 @@ jobs: npm run lint npm run export + # Run the deploy action if the push is to the main branch - name: Deploy 🚀 + if: ${{ github.ref == 'refs/heads/main' }} uses: JamesIves/github-pages-deploy-action@v4 with: folder: new-website/deepchem/out diff --git a/new-website/deepchem/package-lock.json b/new-website/deepchem/package-lock.json index 985741f0..ca96f25b 100644 --- a/new-website/deepchem/package-lock.json +++ b/new-website/deepchem/package-lock.json @@ -7527,8 +7527,7 @@ "@emotion/use-insertion-effect-with-fallbacks": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@emotion/use-insertion-effect-with-fallbacks/-/use-insertion-effect-with-fallbacks-1.0.0.tgz", - "integrity": "sha512-1eEgUGmkaljiBnRMTdksDV1W4kUnmwgp7X9G8B++9GYwl1lUdqSndSriIrTJ0N7LQaoauY9JJ2yhiOYK5+NI4A==", - "requires": {} + "integrity": "sha512-1eEgUGmkaljiBnRMTdksDV1W4kUnmwgp7X9G8B++9GYwl1lUdqSndSriIrTJ0N7LQaoauY9JJ2yhiOYK5+NI4A==" }, "@emotion/utils": { "version": "1.2.0", @@ -7784,8 +7783,7 @@ "@mui/types": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/@mui/types/-/types-7.2.3.tgz", - "integrity": "sha512-tZ+CQggbe9Ol7e/Fs5RcKwg/woU+o8DCtOnccX6KmbBc7YrfqMYEYuaIcXHuhpT880QwNkZZ3wQwvtlDFA2yOw==", - "requires": {} + "integrity": "sha512-tZ+CQggbe9Ol7e/Fs5RcKwg/woU+o8DCtOnccX6KmbBc7YrfqMYEYuaIcXHuhpT880QwNkZZ3wQwvtlDFA2yOw==" }, "@mui/utils": { "version": "5.11.7", @@ -8313,15 +8311,13 @@ "version": "1.8.0", "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz", "integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==", - "dev": true, - "requires": {} + "dev": true }, "acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "requires": {} + "dev": true }, "acorn-node": { "version": "1.8.2", @@ -8364,8 +8360,7 @@ "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true, - "requires": {} + "dev": true }, "align-text": { "version": "0.1.4", @@ -9215,8 +9210,7 @@ "version": "0.14.0", "resolved": "https://registry.npmjs.org/eslint-config-google/-/eslint-config-google-0.14.0.tgz", "integrity": "sha512-WsbX4WbjuMvTdeVL6+J3rK1RGhCTqjsFjX7UMSMgZiyxxaNLkoJENbrGExzERFeoTpGw3F3FypTiWAP9ZXzkEw==", - "dev": true, - "requires": {} + "dev": true }, "eslint-config-next": { "version": "13.0.4", @@ -9239,8 +9233,7 @@ "version": "8.6.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.6.0.tgz", "integrity": "sha512-bAF0eLpLVqP5oEVUFKpMA+NnRFICwn9X8B5jrR9FcqnYBuPbqWEjTEspPWMj5ye6czoSLDweCzSo3Ko7gGrZaA==", - "dev": true, - "requires": {} + "dev": true }, "eslint-import-resolver-node": { "version": "0.3.7", @@ -9465,8 +9458,7 @@ "version": "4.6.0", "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz", "integrity": "sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==", - "dev": true, - "requires": {} + "dev": true }, "eslint-scope": { "version": "7.1.1", @@ -11172,8 +11164,7 @@ "react-frame-component": { "version": "5.2.6", "resolved": "https://registry.npmjs.org/react-frame-component/-/react-frame-component-5.2.6.tgz", - "integrity": "sha512-CwkEM5VSt6nFwZ1Op8hi3JB5rPseZlmnp5CGiismVTauE6S4Jsc4TNMlT0O7Cts4WgIC3ZBAQ2p1Mm9XgLbj+w==", - "requires": {} + "integrity": "sha512-CwkEM5VSt6nFwZ1Op8hi3JB5rPseZlmnp5CGiismVTauE6S4Jsc4TNMlT0O7Cts4WgIC3ZBAQ2p1Mm9XgLbj+w==" }, "react-is": { "version": "18.2.0", @@ -11193,8 +11184,7 @@ "react-placeholder": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/react-placeholder/-/react-placeholder-4.1.0.tgz", - "integrity": "sha512-z1HGD86NWJTYTQumHsmGH9jkozv4QHa9dju/vHVUd4f1svu23pf5v7QoBLBfs3kA1S9GLJaCeRMHLbO2SCdz5A==", - "requires": {} + "integrity": "sha512-z1HGD86NWJTYTQumHsmGH9jkozv4QHa9dju/vHVUd4f1svu23pf5v7QoBLBfs3kA1S9GLJaCeRMHLbO2SCdz5A==" }, "react-responsive-carousel": { "version": "3.2.23", @@ -11217,8 +11207,7 @@ "react-scroll-to-top": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/react-scroll-to-top/-/react-scroll-to-top-3.0.0.tgz", - "integrity": "sha512-I/k45Ujai097du59tHBbzGxN7Lyc6K8Uc3IChq6HMXaBfB8N/rrfm055T5Yv0DWfVpf6pOFaBmhD3LOfH5unGw==", - "requires": {} + "integrity": "sha512-I/k45Ujai097du59tHBbzGxN7Lyc6K8Uc3IChq6HMXaBfB8N/rrfm055T5Yv0DWfVpf6pOFaBmhD3LOfH5unGw==" }, "react-tooltip": { "version": "5.7.5", @@ -11243,8 +11232,7 @@ "react-type-animation": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/react-type-animation/-/react-type-animation-2.1.2.tgz", - "integrity": "sha512-6/t4Whl87sLR0c8kzvJngTrCV6OVy3jEeUZoe2svVu9VaYr951VD7OeUie1rIyeD8JfpBIqZGYrPFHZQ04XHrw==", - "requires": {} + "integrity": "sha512-6/t4Whl87sLR0c8kzvJngTrCV6OVy3jEeUZoe2svVu9VaYr951VD7OeUie1rIyeD8JfpBIqZGYrPFHZQ04XHrw==" }, "read-cache": { "version": "1.0.0", @@ -11923,8 +11911,7 @@ "use-sync-external-store": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz", - "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==", - "requires": {} + "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==" }, "util-deprecate": { "version": "1.0.2", From 98cb16dae6055e6d3a645a60459006a8dd2b4597 Mon Sep 17 00:00:00 2001 From: Dibyam Kumar Date: Thu, 23 Nov 2023 13:28:12 +0530 Subject: [PATCH 3/4] Fix get_layer script --- new-website/utils/layers/get_layers.py | 33 +++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/new-website/utils/layers/get_layers.py b/new-website/utils/layers/get_layers.py index df2082e6..aeafcd27 100644 --- a/new-website/utils/layers/get_layers.py +++ b/new-website/utils/layers/get_layers.py @@ -12,13 +12,16 @@ PATH = '../../deepchem/data/layers/' REDIRECT_URL = 'https://deepchem.readthedocs.io/en/latest/api_reference/layers.html#' CHEATSHEETS = { - 'keras': 'https://raw.githubusercontent.com/deepchem/deepchem/master/docs/source/api_reference/keras_layers.csv', - 'torch': 'https://raw.githubusercontent.com/deepchem/deepchem/master/docs/source/api_reference/torch_layers.csv' + 'keras': + 'https://raw.githubusercontent.com/deepchem/deepchem/master/docs/source/api_reference/keras_layers.csv', + 'torch': + 'https://raw.githubusercontent.com/deepchem/deepchem/master/docs/source/api_reference/torch_layers.csv' } layer_list = [] model_list = [] + @dataclasses.dataclass class Layer: """ @@ -37,14 +40,16 @@ class Layer: """ name: str url: str - category: str - models : list + category: str + models: list layer_id: int - + + class LayerListEncoder(JSONEncoder): """ LayerEncoder class to encode the Layer object to JSON """ + def default(self, o): """ Default function to encode the Layer object to JSON @@ -55,6 +60,7 @@ def default(self, o): """ return o.__dict__ + def convert_to_json(data, name, is_layer=False): """ Convert the list of data to JSON format and write to a file @@ -78,25 +84,30 @@ def convert_to_json(data, name, is_layer=False): with open(PATH + name, 'w', encoding="utf-8") as file: file.write(data) + def fetch_data(): """ Function to fetch the layer csv files and extract necessary data """ for category in CHEATSHEETS.items(): - subprocess.call(f'curl -o {PATH}{category[0] + ".csv"} {category[1]}', shell=True) + subprocess.call(f'curl -o {PATH}{category[0] + ".csv"} {category[1]}', + shell=True) index = -1 for filename in os.listdir(PATH): - for row in pd.read_csv(PATH + filename, on_bad_lines='skip').replace(np.nan, '').iterrows(): + for row in pd.read_csv(PATH + filename, + on_bad_lines='skip').replace(np.nan, + '').iterrows(): name = row[1]['Layer'] url = REDIRECT_URL + name.lower() category = filename.split('.')[0] - models = row['Model'].split(' ') if row['Model'] != '' else [] + models = row[1][' Model'].split( + ' ') if row[1][' Model'] != '' else [] index += 1 - model_list.append(models) + model_list.append(models) layer_list.append(Layer(name, url, category, models, index)) - + def main(): """ @@ -107,6 +118,6 @@ def main(): convert_to_json(layer_list, 'layers.json', is_layer=True) convert_to_json(model_list, 'models.json') + if __name__ == '__main__': main() - From 989ec5594ff4ff7820f5e50118951fb4d9cff0c3 Mon Sep 17 00:00:00 2001 From: Dibyam Kumar Date: Thu, 23 Nov 2023 13:29:40 +0530 Subject: [PATCH 4/4] Fix Layers Page UI --- .../deepchem/components/Layers/LayerCard.js | 17 ++--- new-website/deepchem/pages/layers.js | 70 ++++++++++--------- 2 files changed, 46 insertions(+), 41 deletions(-) diff --git a/new-website/deepchem/components/Layers/LayerCard.js b/new-website/deepchem/components/Layers/LayerCard.js index 5eb1b372..a7795d77 100644 --- a/new-website/deepchem/components/Layers/LayerCard.js +++ b/new-website/deepchem/components/Layers/LayerCard.js @@ -28,14 +28,15 @@ const LayerCard = ({ layer }) => {
{parseName(layer.name)}
-
- {layer.category === "torch" && ( - PyTorch - )} - {layer.category === "keras" && ( - Keras - )} -
+
+ +
+ {layer.category === "torch" && ( + PyTorch + )} + {layer.category === "keras" && ( + Keras + )}
{layer.category}
diff --git a/new-website/deepchem/pages/layers.js b/new-website/deepchem/pages/layers.js index a188efaa..1233356a 100644 --- a/new-website/deepchem/pages/layers.js +++ b/new-website/deepchem/pages/layers.js @@ -77,24 +77,26 @@ const Layers = () => { >
{/* HEADING BEGIN */} -
+
Our Layers
- {/* HEADING END */} - {/* BODY BEGIN */} -
- {/* FILTER SECTION BEGIN */} -
+
+ {/* HEADING END */} + + {/* BODY BEGIN */} +
+ {/* FILTER SECTION BEGIN */} +
{/* MODEL BEGIN */}
Model
@@ -118,29 +120,31 @@ const Layers = () => {
{/* MODEL END */} - {/* LAYER CARDS SECTION BEGIN */} -
- {filteredLayers.length ? ( - filteredLayers.map((layer) => ( - - )) - ) : ( -
- -

No such layers exist!

-
- )} -
- {/* MODEL CARDS SECTION END */}
- {/* BODY END */} + {/* FILTER SECTION END */} + + {/* LAYER CARDS SECTION BEGIN */} +
+ {filteredLayers.length ? ( + filteredLayers.map((layer) => ( + + )) + ) : ( +
+ +

No such layers exist!

+
+ )} +
+ {/* MODEL CARDS SECTION END */}
+ {/* BODY END */}
);