Advanced use cases

Timezone

Set timezone

1
import naas
2
naas.set_remote_timezone("Europe/Lisbon")
Copied!

Get timezone

1
import naas
2
naas.get_remote_timezone()
Copied!

Download URL

Create a download link to Naas from any URL, it can be in GitHub, or anywhere!
1
import naas
2
url = "https://github.com/jupyter-naas/awesome-notebooks/blob/master/Airtable/Airtable_delete_data.ipynb"
3
dl_url = naas.get_download_url(url)
Copied!
Result :
1
https://app.naas.ai/user-redirect/naas/downloader?url=YOURURL
Copied!
Options: mode_api
with &mode_api=yes that create the file in the user but don't open it. Useful for admin
Options: name
with ?name=toto that create a file in the user with the name provided `toto`
if no URL provided it create an empty file.

Run

Run a notebook direct in production and get the result.
1
import naas
2
naas.run()
Copied!

Changelog (deprecated)

Show changelog
1
import naas
2
naas.changelog()
Copied!

Feature request (deprecated)

show feature request inside Jupyter
1
import naas
2
mode = "naas" # can be naas, naas_drivers, awesome_notebook
3
naas.feature_request(mode)
Copied!

Check if you are in production

1
import naas
2
​
3
naas.is_production()
Copied!

Reload jobs

If you need to force update the job list by editing the file in your `.naas/jobs.json`
1
import naas
2
​
3
naas.reload_jobs()
Copied!

N_ENV

This represents the Naas env vars, you can get all to make your script work `naas.n_env`
1
api_port
2
current
3
version
4
remote_mode
5
api
6
notif_api
7
callback_api
8
proxy_api
9
hub_api
10
any_user_url
11
user_url
12
naas_folder
13
server_root
14
path_naas_folder
15
shell_user
16
remote_api
17
token
18
user
19
tz
20
sentry_dsn
21
scheduler
22
scheduler_interval
23
scheduler_job_max
24
scheduler_job_name
25
scheduler_timeout
Copied!

Current

get data in the production of the current running notebook.
For now current gives you this :
1
import naas
2
print(naas.n_env.current)
3
# This will be empty in dev = in notebook run by you
4
# and with vars when run by naas runner ( scheduler or webhook )
Copied!
Last modified 3mo ago