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

feat(ws): update JSON field names to camelCase in types and README. #214

Open
wants to merge 1 commit into
base: notebooks-v2
Choose a base branch
from

Conversation

ederign
Copy link
Member

@ederign ederign commented Feb 16, 2025

To make FE/Typescript marshaling straightforward, we default our JSON format to camelCase.

Some tests:

// http://localhost:4000/api/v1/healthcheck

{
  "status": "Healthy",
  "systemInfo": {
    "version": "1.0.0"
  }
}
// http://localhost:4000/api/v1/workspacekinds/jupyterlab
{
  "data": {
    "name": "jupyterlab",
    "displayName": "JupyterLab Notebook",
    "description": "A Workspace which runs JupyterLab in a Pod",
    "deprecated": false,
    "deprecationMessage": "This WorkspaceKind will be removed on 20XX-XX-XX, please use another WorkspaceKind.",
    "hidden": false,
    "icon": {
      "url": "/workspaces/backend/api/v1/workspacekinds/jupyterlab/assets/icon"
    },
    "logo": {
      "url": "/workspaces/backend/api/v1/workspacekinds/jupyterlab/assets/logo"
    },
    "podTemplate": {
      "podMetadata": {
        "labels": {
          "my-workspace-kind-label": "my-value"
        },
        "annotations": {
          "my-workspace-kind-annotation": "my-value"
        }
      },
      "volumeMounts": {
        "home": "/home/jovyan"
      },
      "options": {
        "imageConfig": {
          "default": "jupyterlab_scipy_190",
          "values": [
            {
              "id": "jupyterlab_scipy_180",
              "displayName": "jupyter-scipy:v1.8.0",
              "description": "JupyterLab, with SciPy Packages",
              "labels": [
                {
                  "key": "python_version",
                  "value": "3.11"
                }
              ],
              "hidden": true,
              "redirect": {
                "to": "jupyterlab_scipy_190",
                "message": {
                  "text": "This update will change...",
                  "level": "Info"
                }
              }
            },
            {
              "id": "jupyterlab_scipy_190",
              "displayName": "jupyter-scipy:v1.9.0",
              "description": "JupyterLab, with SciPy Packages",
              "labels": [
                {
                  "key": "python_version",
                  "value": "3.11"
                }
              ],
              "hidden": false
            }
          ]
        },
        "podConfig": {
          "default": "tiny_cpu",
          "values": [
            {
              "id": "tiny_cpu",
              "displayName": "Tiny CPU",
              "description": "Pod with 0.1 CPU, 128 Mb RAM",
              "labels": [
                {
                  "key": "cpu",
                  "value": "100m"
                },
                {
                  "key": "memory",
                  "value": "128Mi"
                }
              ],
              "hidden": false
            },
            {
              "id": "small_cpu",
              "displayName": "Small CPU",
              "description": "Pod with 1 CPU, 2 GB RAM",
              "labels": [
                {
                  "key": "cpu",
                  "value": "1000m"
                },
                {
                  "key": "memory",
                  "value": "2Gi"
                }
              ],
              "hidden": false
            },
            {
              "id": "big_gpu",
              "displayName": "Big GPU",
              "description": "Pod with 4 CPU, 16 GB RAM, and 1 GPU",
              "labels": [
                {
                  "key": "cpu",
                  "value": "4000m"
                },
                {
                  "key": "memory",
                  "value": "16Gi"
                },
                {
                  "key": "gpu",
                  "value": "1"
                }
              ],
              "hidden": false
            }
          ]
        }
      }
    }
  }
}
// http://localhost:4000/api/v1/workspaces/workspace-test/jupyterlab-workspace

{
  "data": {
    "name": "jupyterlab-workspace",
    "namespace": "workspace-test",
    "workspaceKind": {
      "name": "jupyterlab",
      "missing": false,
      "icon": {
        "url": "/workspaces/backend/api/v1/workspacekinds/jupyterlab/assets/icon"
      },
      "logo": {
        "url": "/workspaces/backend/api/v1/workspacekinds/jupyterlab/assets/logo"
      }
    },
    "deferUpdates": false,
    "paused": false,
    "pausedTime": 0,
    "state": "Running",
    "stateMessage": "Workspace is running",
    "podTemplate": {
      "podMetadata": {
        "labels": {
          
        },
        "annotations": {
          
        }
      },
      "volumes": {
        "home": {
          "pvcName": "workspace-home-pvc",
          "mountPath": "/home/jovyan",
          "readOnly": false
        },
        "data": [
          {
            "pvcName": "workspace-data-pvc",
            "mountPath": "/data/my-data",
            "readOnly": false
          }
        ]
      },
      "options": {
        "imageConfig": {
          "current": {
            "id": "jupyterlab_scipy_190",
            "displayName": "jupyter-scipy:v1.9.0",
            "description": "JupyterLab, with SciPy Packages",
            "labels": [
              {
                "key": "python_version",
                "value": "3.11"
              }
            ]
          }
        },
        "podConfig": {
          "current": {
            "id": "tiny_cpu",
            "displayName": "Tiny CPU",
            "description": "Pod with 0.1 CPU, 128 Mb RAM",
            "labels": [
              {
                "key": "cpu",
                "value": "100m"
              },
              {
                "key": "memory",
                "value": "128Mi"
              }
            ]
          }
        }
      }
    },
    "activity": {
      "lastActivity": 0,
      "lastUpdate": 0
    }
  }
}
 curl -i -X POST http://localhost:4000/api/v1/workspaces/default \                   (kind-notebooks-v2/default)
    -H "Content-Type: application/json" \
    -d '{
    "data": {
        "name": "asdfdora",
        "kind": "jupyterlab",
        "paused": false,
        "deferUpdates": false,
        "podTemplate": {
            "podMetadata": {
                "labels": {
                    "app": "dora"
                },
                "annotations": {
                    "app": "dora"
                }
            },
            "volumes": {
                "home": "workspace-home-bella",
                "data": [
                    {
                        "pvcName": "workspace-data-bella",
                        "mountPath": "/data/my-data",
                        "readOnly": false
                    }
                ]
            },
            "options": {
                "imageConfig": "jupyterlab_scipy_190",
                "podConfig": "tiny_cpu"
            }
        }
    }
}'
HTTP/1.1 201 Created
Access-Control-Allow-Origin: *
Content-Type: application/json
Location: /api/v1/workspaces/default/asdfdora
Date: Sun, 16 Feb 2025 15:33:36 GMT
Content-Length: 505

{
	"data": {
		"name": "asdfdora",
		"kind": "jupyterlab",
		"paused": false,
		"deferUpdates": false,
		"podTemplate": {
			"podMetadata": {
				"labels": {
					"app": "dora"
				},
				"annotations": {
					"app": "dora"
				}
			},
			"volumes": {
				"home": "workspace-home-bella",
				"data": [
					{
						"pvcName": "workspace-data-bella",
						"mountPath": "/data/my-data"
					}
				]
			},
			"options": {
				"imageConfig": "jupyterlab_scipy_190",
				"podConfig": "tiny_cpu"
			}
		}
	}
}

@ederign
Copy link
Member Author

ederign commented Feb 16, 2025

@paulovmr, could you please review this one to see if it fits your needs?

@ederign
Copy link
Member Author

ederign commented Feb 16, 2025

/assign @paulovmr

Copy link

@paulovmr paulovmr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @ederign !

Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: paulovmr
Once this PR has been reviewed and has the lgtm label, please assign kimwnasptd for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@paulovmr
Copy link

/lgtm

@google-oss-prow google-oss-prow bot added the lgtm label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

2 participants