DImuthuUpe commented on code in PR #435:
URL: https://github.com/apache/airavata/pull/435#discussion_r1724384562
##########
airavata-local-agent/electron-builder.yml:
##########
@@ -0,0 +1,12 @@
+appId: com.example.nextron
Review Comment:
Add Apache licence header for all files
##########
airavata-local-agent/package.json:
##########
@@ -0,0 +1,52 @@
+{
Review Comment:
Please verify whether all the dependencies are apache licence compatible
##########
airavata-local-agent/renderer/components/ExperimentsList.jsx:
##########
@@ -0,0 +1,142 @@
+import { useState } from "react";
+import {
+ Tr, Tooltip, Box, Td, Text, Badge, HStack, Button, Modal,
+ ModalOverlay,
+ ModalContent,
+ ModalHeader,
+ useDisclosure,
+ ModalBody,
+ ModalCloseButton,
+} from "@chakra-ui/react";
+import ExperimentModal from "./ExperimentModal";
+import { getColorScheme, getResourceFromId } from '../lib/utilityFuncs';
+import dayjs from "dayjs";
+import relativeTime from "dayjs/plugin/relativeTime";
+dayjs.extend(relativeTime);
+
+
+const isValidStatus = (status) => {
+ let invalidStatus = ["CREATED"]; // TODO here
+ return !invalidStatus.includes(status);
+};
+
+const getExperimentApplication = (executionId) => {
Review Comment:
Add a comment explaining why these values are hardcoded
##########
airavata-local-agent/README.md:
##########
@@ -0,0 +1,16 @@
+# Airavata UI
+
Review Comment:
Please provide a description of the local agent and what purpose it server.
Also, please provide some screenshots
##########
airavata-local-agent/renderer/components/ExperimentsList.jsx:
##########
@@ -0,0 +1,142 @@
+import { useState } from "react";
+import {
+ Tr, Tooltip, Box, Td, Text, Badge, HStack, Button, Modal,
+ ModalOverlay,
+ ModalContent,
+ ModalHeader,
+ useDisclosure,
+ ModalBody,
+ ModalCloseButton,
+} from "@chakra-ui/react";
+import ExperimentModal from "./ExperimentModal";
+import { getColorScheme, getResourceFromId } from '../lib/utilityFuncs';
+import dayjs from "dayjs";
+import relativeTime from "dayjs/plugin/relativeTime";
+dayjs.extend(relativeTime);
+
+
+const isValidStatus = (status) => {
+ let invalidStatus = ["CREATED"]; // TODO here
Review Comment:
What is the TODO here?
##########
airavata-local-agent/renderer/components/JupyterLab.jsx:
##########
@@ -0,0 +1,304 @@
+import React, { Component } from "react";
+import { Alert, Spinner, Text } from "@chakra-ui/react";
+
+const HOSTNAME = "https://api2.cybershuttle.org/proxy";
+export default class JupyterLab extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ rendering: false,
+ msg: "",
+ windowClosed: false,
+ serverPort: null
+ };
+ this.associatedId = `JN_${this.props.experimentId}`;
+ this.interval = null;
+ this.interval2 = null;
+ }
+
+ shouldComponentUpdate(nextProps, nextState) {
+ console.log("state: ", this.state, nextState);
+ console.log("props: ", this.props, nextProps);
+
+ return this.state.rendering !== nextState.rendering ||
this.state.windowClosed !== nextState.windowClosed || this.state.msg !==
nextState.msg;
+
+ // return this.state.rendering !== nextState.rendering ||
this.state.windowClosed !== nextState.windowClosed || this.state.msg !==
nextState.msg;
+ // return false;
+ }
+
+ componentDidMount() {
+ const { reqPort, applicationId, headers } = this.props;
+
+ window.ipc.on("window-has-been-closed", (windowAssociatedId) => {
+ console.log("firing...");
+ if (windowAssociatedId === this.associatedId) {
+ console.log("Matching associated Ids, closing window");
+ this.setState({ windowClosed: true });
+ }
+ });
+
+ if (!reqPort) {
+ this.interval = setInterval(async () => {
+ const resp = await
fetch(`https://api.cybershuttle.org/api/v1/application/${applicationId}/connect`,
{
+ method: "POST",
+ headers: headers,
+ });
+
+ if (!resp.ok) {
+ console.log("Error fetching the application status");
+ clearInterval(this.interval);
+ return;
+ }
+
+ const data = await resp.json();
+
+ if (data.status === "PENDING") {
+ console.log("Waiting for the application to launch...");
+ } else if (data.status === "COMPLETED") {
+ let serverPortFromData = data.allocatedPorts[0];
+ this.setState({ serverPort: serverPortFromData }, () => {
+ this.tryAndLaunchServer(serverPortFromData);
+ });
+ clearInterval(this.interval);
+ }
+ }, 5000);
+ }
+ }
+
+ componentWillUnmount() {
+ console.log("unmounting component...");
+ clearInterval(this.interval);
+ clearInterval(this.interval2);
+ this.setState({ rendering: false });
+ }
+
+ doneWithGettingData = (port) => {
+ this.setState({ rendering: true });
+ console.log("the associated id is", this.associatedId);
+ window.jn.showWindow(`${HOSTNAME}/${port}/lab?token=1234`,
this.associatedId);
+
+ console.log("trying to show the window...");
+ this.setState({ msg: "JupyterLab is ready to use in a new window. Please
enter 1234 as the password box, if prompted." });
+
+
+ };
+
+ tryAndLaunchServer = async (port) => {
+ console.log("polling the jupyter server...");
+
+
+ try {
+ console.log("in the first try");
+ const resp = await fetch(`${HOSTNAME}/${port}/lab?token=1234`);
+ if (resp.ok) {
+ this.doneWithGettingData(port);
+ } else {
+ throw new Error("Error fetching the application status");
+ }
+
+ } catch (e) {
+ console.log("in the first catch", e);
+ this.interval2 = setInterval(async () => {
+ try {
+ console.log("in the second try");
+ const resp = await fetch(`${HOSTNAME}/${port}/lab?token=1234`);
+
+ if (resp.ok) {
+ clearInterval(this.interval2);
+ this.doneWithGettingData(port);
+ }
+ } catch (ex) {
+ console.log("in the second catch", ex);
+ }
+ }, 5000);
+ }
+ };
+
+ render() {
+ const { rendering, msg, windowClosed } = this.state;
+
+ if (!rendering) {
+ return (
+ <Alert status='info' rounded='md'>
+ <Spinner mr={2} />
+ <Text>
+ We're currently starting the Jupyter Notebook, this may take a few
minutes. Please wait...
+ </Text>
+ </Alert>
+ );
+ }
+
+ if (windowClosed) {
+ return (
+ <Alert status='error' rounded='md'>
+ <Text>
+ Please close this tab, your jupyter session is no longer active.
+ </Text>
+ </Alert>
+ );
+ }
+
+ return (
+ <>
+ {
+ msg && (
+ <Alert status='success' rounded='md'>
+ <Text>
+ {msg}
+ </Text>
+ </Alert>
+ )
+ }
+
+ {/* <iframe
src={`${HOSTNAME}/${this.state.serverPort}/lab?token=1234`} width="100%"
height="100%"></iframe> */}
+
+
+
+ <h1>Note: If you close this tab, your jupyter session will no longer
save any changes.</h1>
+ </>
+ );
+ }
+}
+
+
Review Comment:
Do we need following commented code?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]