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

EBR-91: rename the python package to align with the default convention #30

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 3 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ jobs:
CLB_AUTH: 'TEST_TOKEN'
run: |
set -eux
jlpm
jlpm run build
python -m pip install .[test]

jupyter server extension list

jupyter server extension list 2>&1 | grep -ie "tvbextunicore.*OK"
jupyter server extension list 2>&1 | grep -ie "tvb_ext_unicore.*OK"
jupyter labextension list 2>&1 | grep -ie "tvb-ext-unicore.*OK"
python -m jupyterlab.browser_check

Expand All @@ -57,7 +55,7 @@ jobs:
- name: Run Python & JS tests
run: |
set -eux
pytest tvbextunicore -r ap
pytest tvb_ext_unicore -r ap
yarn test

- name: Package the extension
Expand Down Expand Up @@ -126,6 +124,6 @@ jobs:

pip install "jupyterlab>=4.0.0,<5" tvb_ext_unicore*.whl

jupyter server extension list 2>&1 | grep -ie "tvbextunicore.*OK"
jupyter server extension list 2>&1 | grep -ie "tvb_ext_unicore.*OK"
jupyter labextension list 2>&1 | grep -ie "tvb-ext-unicore.*OK"
python -m jupyterlab.browser_check --no-browser-test
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ node_modules/
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo
tvbextunicore/labextension
tvb_ext_unicore/labextension
# Version file is handled by hatchling
tvbextunicore/_version.py
tvb_ext_unicore/_version.py

# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ node_modules
**/lib
**/package.json
!/package.json
tvbextunicore
tvb_ext_unicore
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This jupyter extension offers a UI component to monitor HPC jobs through Unicore
to easily switch between computing sites, retrieve details about the jobs,
and also cancel them.

The package is composed of a Python module named `tvbextunicore`
The package is composed of a Python module named `tvb_ext_unicore`
for the server extension and a NPM package named `tvb-ext-unicore`
for the frontend extension.

Expand Down Expand Up @@ -85,7 +85,7 @@ pip install -e .
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Server extension must be manually installed in develop mode
jupyter server extension enable tvbextunicore
jupyter server extension enable tvb_ext_unicore

# Define CLB_AUTH environment variable holding your EBRAINS token
export CLB_AUTH=${ebrains_token}
Expand Down Expand Up @@ -115,7 +115,7 @@ jupyter lab build --minimize=False

```bash
# Server extension must be manually disabled in develop mode
jupyter server extension disable tvbextunicore
jupyter server extension disable tvb_ext_unicore
pip uninstall tvb-ext-unicore
```

Expand All @@ -141,7 +141,7 @@ jupyter labextension develop . --overwrite
To execute them, run:

```sh
pytest -vv -r ap --cov tvbextunicore
pytest -vv -r ap --cov tvb_ext_unicore
```

#### Frontend tests
Expand Down
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

@pytest.fixture
def jp_server_config(jp_server_config):
return {"ServerApp": {"jpserver_extensions": {"tvbextunicore": True}}}
return {"ServerApp": {"jpserver_extensions": {"tvb_ext_unicore": True}}}
2 changes: 1 addition & 1 deletion jupyter-config/nb-config/tvbextunicore.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"NotebookApp": {
"nbserver_extensions": {
"tvbextunicore": true
"tvb_ext_unicore": true
}
}
}
2 changes: 1 addition & 1 deletion jupyter-config/server-config/tvbextunicore.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ServerApp": {
"jpserver_extensions": {
"tvbextunicore": true
"tvb_ext_unicore": true
}
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension",
"clean": "jlpm clean:lib",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"clean:labextension": "rimraf tvbextunicore/labextension tvbextunicore/_version.py",
"clean:labextension": "rimraf tvb_ext_unicore/labextension tvb_ext_unicore/_version.py",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"eslint": "jlpm eslint:check --fix",
Expand Down Expand Up @@ -122,7 +122,7 @@
}
},
"extension": true,
"outputDir": "tvbextunicore/labextension"
"outputDir": "tvb_ext_unicore/labextension"
},
"jupyter-releaser": {
"hooks": {
Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,25 @@ source = "nodejs"
fields = ["description", "authors", "urls", "keywords"]

[tool.hatch.build.targets.sdist]
artifacts = ["tvbextunicore/labextension"]
artifacts = ["tvb_ext_unicore/labextension"]
exclude = [".github", "binder"]

[tool.hatch.build.targets.wheel.shared-data]
"tvbextunicore/labextension" = "share/jupyter/labextensions/tvb-ext-unicore"
"tvb_ext_unicore/labextension" = "share/jupyter/labextensions/tvb-ext-unicore"
"install.json" = "share/jupyter/labextensions/tvb-ext-unicore/install.json"
"jupyter-config/server-config" = "etc/jupyter/jupyter_server_config.d"

[tool.hatch.build.hooks.version]
path = "tvbextunicore/_version.py"
path = "tvb_ext_unicore/_version.py"

[tool.hatch.build.hooks.jupyter-builder]
dependencies = ["hatch-jupyter-builder>=0.5"]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = [
"tvbextunicore/labextension/static/style.js",
"tvbextunicore/labextension/package.json",
"tvb_ext_unicore/labextension/static/style.js",
"tvb_ext_unicore/labextension/package.json",
]
skip-if-exists = ["tvbextunicore/labextension/static/style.js"]
skip-if-exists = ["tvb_ext_unicore/labextension/static/style.js"]

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
build_cmd = "build:prod"
Expand All @@ -72,7 +72,7 @@ npm = ["jlpm"]
build_cmd = "install:extension"
npm = ["jlpm"]
source_dir = "src"
build_dir = "tvbextunicore/labextension"
build_dir = "tvb_ext_unicore/labextension"

[tool.jupyter-releaser.options]
version_cmd = "hatch version"
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/constants.tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { getJobCode, getDownloadFileCode } from '../constants';

describe('test getJobCode, getDownloadFileCode', () => {
it('generates code to get a job', () => {
const expected = `from tvbextunicore.unicore_wrapper import unicore_wrapper
const expected = `from tvb_ext_unicore.unicore_wrapper import unicore_wrapper
unicore = unicore_wrapper.UnicoreWrapper()
job = unicore.get_job('url')
job`;
expect(getJobCode('url')).toBe(expected);
});

it('generates code to download a file', () => {
const expected = `from tvbextunicore.unicore_wrapper import unicore_wrapper
const expected = `from tvb_ext_unicore.unicore_wrapper import unicore_wrapper
unicore = unicore_wrapper.UnicoreWrapper()
download_result = unicore.download_file('test_url', 'test_file')
download_result`;
Expand Down
4 changes: 2 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const RELOAD_CHECK_RATE_MS = 10000; //should check every 10sec
* @param file
*/
export function getDownloadFileCode(job_url: string, file: string): string {
return `from tvbextunicore.unicore_wrapper import unicore_wrapper
return `from tvb_ext_unicore.unicore_wrapper import unicore_wrapper
unicore = unicore_wrapper.UnicoreWrapper()
download_result = unicore.download_file('${job_url}', '${file}')
download_result`;
Expand All @@ -41,7 +41,7 @@ download_result`;
* @param job_url
*/
export function getJobCode(job_url: string): string {
return `from tvbextunicore.unicore_wrapper import unicore_wrapper
return `from tvb_ext_unicore.unicore_wrapper import unicore_wrapper
unicore = unicore_wrapper.UnicoreWrapper()
job = unicore.get_job('${job_url}')
job`;
Expand Down
4 changes: 2 additions & 2 deletions src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function requestAPI<T>(
const settings = ServerConnection.makeSettings();
const requestUrl = URLExt.join(
settings.baseUrl,
'tvbextunicore', // API Namespace
'tvb_ext_unicore', // API Namespace
endPoint
);
let response: Response;
Expand Down Expand Up @@ -60,7 +60,7 @@ export async function requestStream<T>(
const settings = ServerConnection.makeSettings();
const requestUrl = URLExt.join(
settings.baseUrl,
'tvbextunicore', // API Namespace
'tvb_ext_unicore', // API Namespace
endPoint
);
let response: Response;
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export type NullableIKernelConnection =
* Initialization data for the tvb-ext-unicore extension.
*/
const plugin: JupyterFrontEndPlugin<void> = {
id: 'tvbextunicore:plugin',
id: 'tvb_ext_unicore:plugin',
autoStart: true,
requires: [
ICommandPalette,
Expand All @@ -73,7 +73,7 @@ const plugin: JupyterFrontEndPlugin<void> = {
console.log('JupyterLab extension tvb-ext-unicore is activated!');
let widget: MainAreaWidget<PyunicoreWidget>;
const columns = ['id', 'name', 'owner', 'site', 'status', 'start_time'];
const command = 'tvbextunicore:open';
const command = 'tvb_ext_unicore:open';
app.commands.addCommand(command, {
label: 'PyUnicore Task Stream',
execute: async (args = { defaultSite: NO_SITE }): Promise<any> => {
Expand Down Expand Up @@ -125,7 +125,7 @@ const plugin: JupyterFrontEndPlugin<void> = {
});

widget = new MainAreaWidget({ content });
widget.id = 'tvbextunicore';
widget.id = 'tvb_ext_unicore';
widget.title.label = 'PyUnicore Task Stream';
widget.title.closable = true;
}
Expand Down
6 changes: 3 additions & 3 deletions tvbextunicore/__init__.py → tvb_ext_unicore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
def _jupyter_labextension_paths():
return [{
"src": "labextension",
"dest": "tvbextunicore"
"dest": "tvb_ext_unicore"
}]



def _jupyter_server_extension_points():
return [{
"module": "tvbextunicore"
"module": "tvb_ext_unicore"
}]


Expand All @@ -26,7 +26,7 @@ def _load_jupyter_server_extension(server_app):
JupyterLab application instance
"""
setup_handlers(server_app.web_app)
server_app.log.info("Registered tvbextunicore server extension")
server_app.log.info("Registered tvb_ext_unicore server extension")


# For backward compatibility with notebook server - useful for Binder/JupyterHub
Expand Down
File renamed without changes.
16 changes: 8 additions & 8 deletions tvbextunicore/handlers.py → tvb_ext_unicore/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import tornado
from tornado.web import MissingArgumentError

from tvbextunicore.exceptions import SitesDownException, FileNotExistsException, JobRunningException
from tvbextunicore.unicore_wrapper.unicore_wrapper import UnicoreWrapper
from tvbextunicore.logger.builder import get_logger
from tvbextunicore.utils import build_response, DownloadStatus
from tvb_ext_unicore.exceptions import SitesDownException, FileNotExistsException, JobRunningException
from tvb_ext_unicore.unicore_wrapper.unicore_wrapper import UnicoreWrapper
from tvb_ext_unicore.logger.builder import get_logger
from tvb_ext_unicore.utils import build_response, DownloadStatus

LOGGER = get_logger(__name__)

Expand Down Expand Up @@ -135,10 +135,10 @@ def setup_handlers(web_app):
host_pattern = ".*$"

base_url = web_app.settings["base_url"]
sites_pattern = url_path_join(base_url, "tvbextunicore", "sites")
jobs_pattern = url_path_join(base_url, "tvbextunicore", "jobs")
output_pattern = url_path_join(base_url, "tvbextunicore", "job_output")
drive_pattern = url_path_join(base_url, "tvbextunicore", r"drive/([^/]+)?/([^/]+)?")
sites_pattern = url_path_join(base_url, "tvb_ext_unicore", "sites")
jobs_pattern = url_path_join(base_url, "tvb_ext_unicore", "jobs")
output_pattern = url_path_join(base_url, "tvb_ext_unicore", "job_output")
drive_pattern = url_path_join(base_url, "tvb_ext_unicore", r"drive/([^/]+)?/([^/]+)?")
handlers = [
(jobs_pattern, JobsHandler),
(sites_pattern, SitesHandler),
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## TVB-EXT-UNICORE - logging configuration. ##
############################################
[loggers]
keys=root, tvbextunicore
keys=root, tvb_ext_unicore

[handlers]
keys=consoleHandler, fileHandler
Expand All @@ -16,12 +16,12 @@ handlers=consoleHandler, fileHandler
propagate=0

############################################
## tvbextunicore specific logging ##
## tvb_ext_unicore specific logging ##
############################################
[logger_tvbextunicore]
[logger_tvb_ext_unicore]
level=INFO
handlers=consoleHandler, fileHandler
qualname=tvbextunicore
qualname=tvb_ext_unicore
propagate=0

############################################
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
import pytest
from datetime import datetime

from tvbextunicore.exceptions import TVBExtUnicoreException, SitesDownException, \
from tvb_ext_unicore.exceptions import TVBExtUnicoreException, SitesDownException, \
FileNotExistsException, JobRunningException
from tvbextunicore.unicore_wrapper.unicore_wrapper import UnicoreWrapper, DOWNLOAD_MESSAGE
from tvbextunicore.unicore_wrapper.job_dto import JobDTO, NAME, OWNER, SITE_NAME, STATUS, SUBMISSION_TIME, \
from tvb_ext_unicore.unicore_wrapper.unicore_wrapper import UnicoreWrapper, DOWNLOAD_MESSAGE
from tvb_ext_unicore.unicore_wrapper.job_dto import JobDTO, NAME, OWNER, SITE_NAME, STATUS, SUBMISSION_TIME, \
TERMINATION_TIME, \
MOUNT_POINT
from tvbextunicore.utils import build_response, DownloadStatus
from tvb_ext_unicore.utils import build_response, DownloadStatus

GET_JOB = 'tvbextunicore.unicore_wrapper.unicore_wrapper.UnicoreWrapper.get_job'
GET_JOB = 'tvb_ext_unicore.unicore_wrapper.unicore_wrapper.UnicoreWrapper.get_job'
SHUTIL_MOVE = 'shutil.move'


Expand Down Expand Up @@ -135,7 +135,7 @@ def test_get_jobs(mocker):
def mockk(self, site=''):
return MockPyUnicoreClient()

mocker.patch('tvbextunicore.unicore_wrapper.unicore_wrapper.UnicoreWrapper._UnicoreWrapper__build_client', mockk)
mocker.patch('tvb_ext_unicore.unicore_wrapper.unicore_wrapper.UnicoreWrapper._UnicoreWrapper__build_client', mockk)
unicore_wrapper = UnicoreWrapper()
jobs, msg = unicore_wrapper.get_jobs('TEST_SITE')

Expand All @@ -153,7 +153,7 @@ def test_get_jobs_exception_at_sites(mocker):
def mockk(self, site=''):
raise SitesDownException(exception_msg)

mocker.patch('tvbextunicore.unicore_wrapper.unicore_wrapper.UnicoreWrapper._UnicoreWrapper__build_client', mockk)
mocker.patch('tvb_ext_unicore.unicore_wrapper.unicore_wrapper.UnicoreWrapper._UnicoreWrapper__build_client', mockk)
unicore_wrapper = UnicoreWrapper()
jobs, msg = unicore_wrapper.get_jobs('TEST_SITE')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import pyunicore.client as unicore_client
from pyunicore.credentials import OIDCToken
from requests.exceptions import ConnectionError
from tvbextunicore.exceptions import TVBExtUnicoreException, ClientAuthException, SitesDownException
from tvbextunicore.exceptions import FileNotExistsException, JobRunningException
from tvbextunicore.logger.builder import get_logger
from tvbextunicore.unicore_wrapper.job_dto import JobDTO
from tvb_ext_unicore.exceptions import TVBExtUnicoreException, ClientAuthException, SitesDownException
from tvb_ext_unicore.exceptions import FileNotExistsException, JobRunningException
from tvb_ext_unicore.logger.builder import get_logger
from tvb_ext_unicore.unicore_wrapper.job_dto import JobDTO

LOGGER = get_logger(__name__)
DOWNLOAD_MESSAGE = 'Downloaded successfully!'
Expand Down
2 changes: 1 addition & 1 deletion tvbextunicore/utils.py → tvb_ext_unicore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import json
import enum
from tvbextunicore.logger.builder import get_logger
from tvb_ext_unicore.logger.builder import get_logger

LOGGER = get_logger(__name__)

Expand Down