Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Stable URLs, s3 link improvements #79

Merged
merged 112 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
6b175b4
add uat base urls and buckets
bsatoriu Sep 1, 2020
576730d
config-based urls: maapsec
bsatoriu Sep 3, 2020
eba71a7
dps_magic readme typo
bsatoriu Sep 3, 2020
9e7a70c
config based urls: submit_jobs
bsatoriu Sep 3, 2020
0ccb33b
config based urls: dps_info
bsatoriu Sep 3, 2020
17650c7
config based urls: pull_projects
bsatoriu Sep 3, 2020
bc6ca56
revert timeout setting change
bsatoriu Sep 4, 2020
c919de0
config based urls: ssh_info
bsatoriu Sep 4, 2020
d646937
add default_host field for explicitness
bsatoriu Sep 4, 2020
a561ee3
remove hard coded url from dps_info client
bsatoriu Sep 4, 2020
88ea828
clean up hard coded url references
bsatoriu Sep 4, 2020
f89c0fc
remove unnecessary state param
bsatoriu Sep 4, 2020
ac59521
Merge pull request #69 from MAAP-Project/maap-uat-environment
bsatoriu Sep 4, 2020
f61ebbd
Update dps_magic to use maap_environments.json
bsatoriu Sep 4, 2020
363756a
send presigned s3 url req to maap api
bsatoriu Sep 5, 2020
2ec6707
fix ci build error
bsatoriu Sep 5, 2020
2d4cfc2
Update entrypoint.sh
bsatoriu Sep 5, 2020
dac03ca
Replace statedb environment with server lookup
bsatoriu Sep 6, 2020
732dfe7
replace env statedb with server lookup
bsatoriu Sep 6, 2020
4959737
set ade_server in client once during startup
bsatoriu Sep 6, 2020
66c39fe
Merge pull request #71 from MAAP-Project/maap-env-improvements-dev
bsatoriu Sep 6, 2020
646ba92
fix keycloak callback error
bsatoriu Sep 7, 2020
a9c0a6e
Merge pull request #72 from MAAP-Project/maap-env-improvements-dev
bsatoriu Sep 7, 2020
7f346a7
submit jobs convert to tabs to spaces
echyam Sep 8, 2020
e501551
fix submit jobs getMetrics result key
echyam Sep 10, 2020
bc1d4f7
fix dps_info ref to state
echyam Sep 10, 2020
1859425
Use maap-py for MAAP API (#73)
echyam Sep 15, 2020
dd3464b
move edsc url to configuration file
bsatoriu Sep 16, 2020
1c59a75
Merge branch 'develop' of https://github.com/MAAP-Project/maap-jupyte…
bsatoriu Sep 16, 2020
2b3c631
Registration updates (#74)
echyam Sep 18, 2020
4485f3e
make maap-users org folder read-only
echyam Sep 22, 2020
efaeefc
Fix IStateDB bug
bsatoriu Sep 28, 2020
a095383
Merge branch 'develop' of https://github.com/MAAP-Project/maap-jupyte…
bsatoriu Sep 28, 2020
ab42429
update hello-world url regex to allow git token in url
echyam Sep 29, 2020
816fa4c
fix org bucket mount line
echyam Sep 30, 2020
f09820b
update ops search port to 30052
mayadebellis Oct 1, 2020
a88ce27
Parse new api xml format (#76)
echyam Oct 14, 2020
329572f
comment out yaml overwrite for now
bsatoriu Oct 16, 2020
30e91b2
changing default env to ops for now
bsatoriu Oct 16, 2020
206805f
Fix terminal webapp setting
bsatoriu Oct 26, 2020
645b3c3
Update entrypoint.sh
bsatoriu Oct 27, 2020
d666176
s3link checks if path is folder or if file in valid directory (#77)
echyam Oct 27, 2020
87eccd1
user s3 folder is from under maap-users, debugging presigned s3 url
echyam Oct 27, 2020
65b292e
s3 url needed profile token, not proxy-ticket
echyam Oct 27, 2020
285f415
revert change having s3 folders point to same prefix
echyam Oct 27, 2020
9370868
remove tabs side panel wip
echyam Oct 29, 2020
add4141
s3 url handler using wrong token name to get orgs
echyam Nov 3, 2020
d728e4c
pass token to get s3url
echyam Nov 3, 2020
d53e600
getOrgs token different from API proxy-ticket
echyam Nov 3, 2020
a531cee
debugging
echyam Nov 3, 2020
eee0652
check s3 paths against mounted paths instead of orgs call
echyam Nov 9, 2020
f45a81c
decode output for string manipulation
echyam Nov 9, 2020
55ed6a8
typo
echyam Nov 10, 2020
98f64ba
parse df command for mounted folders only
echyam Nov 10, 2020
50957dc
remove unused variable
echyam Nov 10, 2020
b4d283e
add selector for s3 link expiration time
echyam Nov 10, 2020
92b985a
typo
echyam Nov 11, 2020
a2d74b1
Add text reminding s3link expiration
echyam Nov 11, 2020
6766b9c
add button to copy s3 link to clipboard
echyam Nov 11, 2020
59f77bf
fix copy s3link to clipboard
echyam Nov 12, 2020
c8e361c
rm unused code and only show copy s3 link button if there is a valid …
echyam Nov 13, 2020
5456ea4
Merge branch 'master' into develop
echyam Nov 13, 2020
4852468
remove duplicated code from merge
echyam Nov 17, 2020
780492c
add a few lines about 3d data (#81)
mayadebellis Jan 5, 2021
a339be2
Update maap code snippet to include default url
bsatoriu Jan 5, 2021
bdb3707
Merge branch 'master' into develop
mayadebellis Jan 19, 2021
8dc0d95
Update entrypoint.sh
bsatoriu Jan 24, 2021
db73683
Add comment to che machine name env selector
bsatoriu Jan 25, 2021
351516f
Add che7 test config
bsatoriu Feb 2, 2021
9a33df3
Don't use the default maap-py api host
bsatoriu Feb 3, 2021
dd4108d
Fix devche7 letter case
bsatoriu Feb 4, 2021
ebbc2c2
Update README.md
bsatoriu Feb 4, 2021
c9b8a9d
remove password file, replace with iam roles
mayadebellis Feb 18, 2021
6aa3459
change edsc sever port
mayadebellis Feb 18, 2021
2417127
remove references to che installers
mayadebellis Feb 18, 2021
09c4fc1
Update workspace bucket
bsatoriu Feb 18, 2021
7b9c025
Remove s3fs password file reference
bsatoriu Feb 18, 2021
a9a8f4e
repo.uat.maap-project.org
bsatoriu Feb 18, 2021
0f9923f
Update README.md
bsatoriu Feb 18, 2021
f0299fa
Update handlers.py
bsatoriu Feb 18, 2021
43fbd6b
Missed one
bsatoriu Feb 18, 2021
c9f739b
Merge branch 'develop' into update-s3fs
bsatoriu Feb 18, 2021
a1c3520
Merge pull request #83 from MAAP-Project/update-s3fs
bsatoriu Feb 18, 2021
e81bdc8
Update supported MAS domains
bsatoriu Feb 18, 2021
24b05c1
remove references to che installers (#84)
mayadebellis Feb 20, 2021
addc7d3
replace org mount with shared workspace mount
bsatoriu Feb 22, 2021
db76eae
start ssh in entrypoint, add username namespace
mayadebellis Feb 22, 2021
9537a27
Revert shared ws mount and remove read-only
bsatoriu Feb 22, 2021
786bede
fix merge conflict
mayadebellis Feb 22, 2021
b9822fb
Merge pull request #85 from MAAP-Project/update-ssh-info
mayadebellis Feb 22, 2021
c744647
Replace memory with queue
bsatoriu Feb 24, 2021
5f75847
switch from ip address of worker to host address of ade
mayadebellis Feb 24, 2021
105ff7e
update pull projects for che7
mayadebellis Feb 25, 2021
482242b
Dev update
bsatoriu Mar 3, 2021
7eb0448
Readme
bsatoriu Mar 3, 2021
c1fe2c3
Updated entrypoint.sh to make the fix to run Jupyter under Che in 'si…
gchang Mar 16, 2021
8d4a7cf
Update entrypoint.sh
gchang Mar 17, 2021
fa8d269
fix key error in pull projects when no proj exists
mayadebellis Mar 24, 2021
272a32a
Update maap_environments.json
bsatoriu Mar 31, 2021
79f77a6
Added the inline python code to generate the url prefix (#86)
gchang Apr 8, 2021
c7b5bdb
Fixed entrypoint.sh to work in the current UAT environment too
gchang Apr 8, 2021
9664628
remove s3fs and mounting refernces (#87)
mayadebellis Apr 8, 2021
8b1ef82
Reattempt PREVIEW_URL fetch on failure
bsatoriu May 4, 2021
5fea174
update ssh service to find nodeport (#88)
mayadebellis May 5, 2021
f3cb328
remove sucess message that actually fails
mayadebellis May 5, 2021
765251e
Merge branch 'develop' of https://github.com/MAAP-Project/maap-jupyte…
mayadebellis May 5, 2021
3628dc2
Add workspace argument to presigned s3 url paths
bsatoriu May 20, 2021
c1418a4
Fix environment pre-ops 'workspace_bucket' name
bsatoriu May 20, 2021
90a8c23
Remove timestamp from algo reg
bsatoriu May 27, 2021
fcb91db
Merge branch 'develop' of https://github.com/MAAP-Project/maap-jupyte…
bsatoriu May 27, 2021
e253de5
update readme
mayadebellis Jun 3, 2021
543de23
Merge branch 'master' into develop
mayadebellis Jun 3, 2021
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
174 changes: 33 additions & 141 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MAAP Jupyter Interface

This repo includes JupyterLab extensions that have been built for the MAAP project (https://che-k8s.maap.xyz/)
This repo includes JupyterLab extensions that have been built for the MAAP project (https://www.maap-project.org/)

In order to use each of these extensions they must be installed and enabled in your environment. Instructions for each extension can be
found in the respective folder. Make sure each extension's dependencies are installed first.
Expand All @@ -16,8 +16,8 @@ Create a new Conda environment and install common dependencies and versions:
conda create --name maap-ade
conda activate maap-ade
conda install conda=4.7.12 jupyterlab=2.1.4 nodejs=10.13.0 gitpython=3.0.2
jupyter labextension install jupyterlab_toastify@3.3.0 --no-build
npm i jupyterlab_toastify@3.3.0
jupyter labextension install jupyterlab_toastify@3.0.0
npm i jupyterlab_toastify@3.0.0
pip install plotly==4.0.0
jupyter labextension install @jupyter-widgets/[email protected]
```
Expand Down Expand Up @@ -68,143 +68,35 @@ Some Jupyter Extensions/Resources we have found helpful:
In JupyterLab's update to the stable 1.0 version, they have also updated and added lots of documentation on extension
development. I recommend taking a look at [this](https://jupyterlab.readthedocs.io/en/stable/developer/extension_dev.html).

## Deploying Extensions as Part of Eclipse Che
### Dockerizing
Our development process involves building and running an extension locally in jupyterlab using a conda env before
installing it on the che server. To enable an extension in Che, it must be included in the base docker image/stack that a
Che workspace is launched with. The dockerfile that extensions are included in is the `Dockerfile` and the highest level
in this repo. At the point of adding your extension into the Docker image, some minor changes may have to be made
(mainly path issues). This will be explained in the bullets below.

An instance of this repository lives on the Che server under `~/che/dockerfiles/maap-jupyter-ide`. Once an extension has been tested locally, rebuild the docker
image with your new extensions.


- Add your install to the Dockerfile. For example:
```bash
# jlab pull projects into /projects directory
COPY pull_projects /pull_projects
RUN cd /pull_projects && npm run build
RUN cd /pull_projects && jupyter labextension link .
RUN cd /pull_projects && pip install -e .
RUN cd /pull_projects && jupyter serverextension enable --py pull_projects --sys-prefix

```
- If your extension includes a server extension you also need to modify `entrypoint.sh`. This is because jupyter
server extensions function off of having a standard base url, but in the context of che the url is not what jupyter
thinks it is.
- Here is some magic that fixes it (add this line and replace with the path to where
your `load_jupyter_server_extension` function is)
## Steps for Contributing
### Each Contribution
- Clone repository locally to test and develop extensions. Create your own branch and once you have tested it and are ready to contribute, put a PR into the develop branch.
- After you have validated your code is working locally, the next step is to test it in the MAAP ADE in the devlopment environment.
- When there is an update to the develop branch, such as merging in a PR, the CI will be kicked off automatically and will build the image necessary for use in the MAAP ADE. This image will end in the `:develop` tag. This is intended to be used to test in the development environment.
- When updates in develop have been tested in the MAAP ADE and deemed stable, merge them into master.
### Ready for Release
- Once there have been changes that warrant a new release to the operations environment, create a new Github release from the master branch. Name the release the next corresponding number following the `v3.0.1` schema. In the notes of the release include a changelog of the updates included in that release
- Then, update the existing `stable` tag to point to the same place as the release that you just created. This can easily be done on the command line by checking out the latest code on master (or whatever commit the release was created from) and running the following:
```
git tag -f stable
git push -f origin stable
```
- The CI will also be kicked off for `stable` and `v` tags. The `stable` tag is used in the devfiles in the operations environment and automatically pulled in each new workspace, so it is very important pushing changes to this tag have been thuroughly tested. The `v` tag is not used in any environment but is used to track versions and the changes we role out. If there is an issue found in the `stable` tag we can roll it back to the previous `v` release by checking out that release and running the lines above.
- The CI trigger information can be found .github/workflows/gitlab-trigger.yml and in the actions tab

## Docker Images and CI Process
- The CI and images built off of this code live on MAAP's hosted GitLab (https://mas.maap-project.org/root).
- Triggered from maap-jupyter-ide
- Will build corresponding maap-jupyter-ide branch on all of the base images listed in the base_images.txt file
- Triggered from Gitlab
- If triggered from a [base image](https://mas.maap-project.org/root/ade-base-images) being updated, it will only rebuild that base image with map-jupyter-ide’s stable tag on top of it.
- If triggered from an update in the [jupyter-image](https://mas.maap-project.org/root/jupyter-image) repo, it will rebuild all of the base images listed in base_iamges.txt with maap-jupyter-ide’s stable tag.
- Troubleshooting
- If the image failed to build for an unexpected reason, it is likely because the gitlab runner ran out of space. Ssh onto the runner, clean up the docker images (you can get rid of anything - everything important is on s3 backed registries) and restart the failed job.


## Troubleshooting
- If your extension includes a server extension you also need to modify `entrypoint.sh`. This is because jupyter server extensions function off of having a standard base url, but in the context of che the url is not what jupyter thinks it is.
- Here is some magic that fixes it (add this line and replace with the path to where your `load_jupyter_server_extension` function is)
```bash
perl -pi -e "s|web_app.settings\['base_url'\]|'/'|g" /show_ssh_info/show_ssh_info/__init__.py
```
- Then rebuild the docker image. `microk8s.docker build -t localhost:32000/che-jupyter-lab-ide .`
- Push! `microk8s.docker push localhost:32000/che-jupyter-lab-ide `
- Now when you build a new workspace with the `localhost:32000/che-jupyter-lab-ide` image it will automatically
fetch the new image. (found in the stack's `Recipe` or `Raw Configuration`)
- you can also specify the image tag to use in your build on the stack if you want to use a previous build
- Any change pushed to `microk8s.docker push localhost:32000/che-jupyter-lab-ide ` will affect the default stacks
on all user accounts. If you are testing something, you can create your own image and your own stack to play around with.


### Che Stacks
To make your custom docker image available to users in Che, you need to make a new stack that creates workspaces using your image and make it available to users.
Below is an example stack configuration using our locally built dockerized juptyer image with MAAP extensions installed.

Make sure to replace the image name in `workspaceConfig.environments.default.recipe.image` with the location of your image.
In order for SSH-ing into the workspace to be possible, the `org.eclipse.che.exec` and `org.eclipse.che.ssh` installers must be enabled under `workspaceConfig.environments.default.machines.ws/jupyter.installers`.

#### Che Stack Raw Configuration
```
{
"scope": "general",
"description": "Use this one. Stable jupyter. No extra packages",
"creator": "b07e3a58-ed50-4a6e-be17-fcf49ff8b242",
"tags": [
"MAAP",
"JUPYTER",
"STABLE"
],
"workspaceConfig": {
"defaultEnv": "default",
"environments": {
"default": {
"recipe": {
"contentType": "text/x-yaml",
"type": "kubernetes",
"content": "kind: List\nitems:\n - \n apiVersion: v1\n kind: Pod\n metadata:\n name: ws\n labels:\n name: ws\n spec:\n containers:\n - \n name: jupyter\n image: 'localhost:32000/stable-ide:latest'\n resources:\n limits:\n memory: 1024Mi\n securityContext:\n privileged: true\n - \n apiVersion: v1\n kind: Service\n metadata:\n name: ws\n spec:\n type: NodePort\n ports:\n - \n port: 22\n selector:\n name: ws\n \n "
},
"machines": {
"ws/jupyter": {
"env": {
"MACHINE_NAME": "WS_JUPYTER"
},
"servers": {
"jupyter": {
"path": "/",
"attributes": {
"cookiesAuthEnabled": "true",
"type": "ide",
"secure": "true"
},
"protocol": "http",
"port": "3100"
}
},
"installers": [
"org.eclipse.che.exec",
"org.eclipse.che.ssh"
],
"volumes": {
"projects": {
"path": "/projects"
}
},
"attributes": {}
}
}
}
},
"projects": [],
"commands": [],
"name": "default",
"attributes": {},
"links": []
},
"components": [],
"name": "maap-jupyter-ide",
"id": "stacktdo2q0ixhv7cge00"
}
```
#### Enabling Privileged Docker Containers
1. Cluster Privileges
- in `/var/snap/microk8s/current/args/kubelet` and `/var/snap/microk8s/current/args/kube-apiserver`, append `--allow-privileged`
- restart both services:
```
sudo systemctl restart snap.microk8s.daemon-apiserver
sudo systemctl restart snap.microk8s.daemon-kubelet
```

2. Che Permissions
- in `che/dockerfiles/init/manifest/che.env`, set `CHE_DOCKER_PRIVILEGED=true` under the Privileged Mode section
- restart Che

#### Creating and Sharing Stacks
To create a stack, you write a raw configuration with all the che and docker settings your workspace will require, including installers, volumes, docker run tags, docker images, etc. See the example above.

To share a stack, you will need to be the owner (creator) of the stack.
Go to the homepage of where your Che instance is hosted and add `/swagger` to the end of the url for an interface with Che's API. Under the `permissions`section, make a POST request with the users you want to share with and the id of your stack (shows up at the bottom of the configuration after creation).
POST body:
```
{
"userId": "*",
"domainId": "stack",
"instanceId": "${STACK_ID}",
"actions": [
"read",
"search"
]
}
```
reference: https://www.eclipse.org/che/docs/che-6/stacks.html#sharing-stacks-and-system-stacks
.
9 changes: 4 additions & 5 deletions dps_info/src/jobinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,12 @@ export class JobTable extends Widget {
}

async _getJobList(me:JobTable) {
// console.log(this._username);
const res:RequestResult = await getJobs(me._state, me._username);
if(res.ok){
let json_response:any = res.json();
INotification.success("Get user jobs success.");
// console.log(json_response);
if (json_response['status_code'] === 200){
// let resp = json_response['result'];
INotification.success("Get user jobs success.");

me._table = json_response['result'];
JOBS = json_response['jobs'];
DISPLAYS = json_response['displays'];
Expand Down Expand Up @@ -1130,8 +1128,9 @@ export class JobWidget extends Widget {
const res:RequestResult = await getJobs(this._state, this._username);
if(res.ok){
let json_response:any = res.json();
INotification.success("Get user jobs success.");
if (json_response['status_code'] === 200){
INotification.success("Get user jobs success.");

me._table = json_response['table'];
JOBS = json_response['jobs'];
DISPLAYS = json_response['displays'];
Expand Down
20 changes: 18 additions & 2 deletions edsc_extension/edsc_extension/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,25 @@
import nbformat
from notebook.base.handlers import IPythonHandler
import subprocess
import functools
import json
import maap
from maap.maap import MAAP

@functools.lru_cache(maxsize=128)
def get_maap_config(host):
path_to_json = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../..', 'maap_environments.json')

with open(path_to_json) as f:
data = json.load(f)

match = next((x for x in data if host in x['ade_server']), None)
maap_config = next((x for x in data if x['default_host'] == True), None) if match is None else match

return maap_config

def maap_api(host):
return get_maap_config(host)['api_server']

class GetGranulesHandler(IPythonHandler):
def printUrls(self, granules):
Expand All @@ -18,7 +34,7 @@ def printUrls(self, granules):

def get(self):

maap = MAAP()
maap = MAAP(maap_api(self.request.host))
cmr_query = self.get_argument('cmr_query', '')
limit = str(self.get_argument('limit', ''))
print("cmr_query", cmr_query)
Expand All @@ -35,7 +51,7 @@ def get(self):

class GetQueryHandler(IPythonHandler):
def get(self):
maap = MAAP()
maap = MAAP(maap_api(self.request.host))
cmr_query = self.get_argument('cmr_query', '')
limit = str(self.get_argument('limit', ''))
query_type = self.get_argument('query_type', 'granule')
Expand Down
Loading