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

Commit

Permalink
Update packaging and requirements for Girder 5 dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmullen committed Jun 13, 2024
1 parent 7507c8d commit 2f39300
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 53 deletions.
67 changes: 26 additions & 41 deletions girder_worker/girder_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,52 +27,37 @@
import logging
from pathlib import Path

import girder # noqa
from girder import events
from girder.constants import AccessType
from girder.plugin import getPlugin, GirderPlugin, registerPluginStaticContent
from girder_jobs.models.job import Job

logger = logging.getLogger(__name__)

# Detect if girder>=3 is installed by checking an import that was added in 3.0.
_isGirder3 = False
try:
from girder.plugin import getPlugin, GirderPlugin, registerPluginStaticContent
_isGirder3 = True
except ImportError:
logger.info('Girder 2.x is detected skipping incompatible entrypoint definition.')
from .api.worker import Worker
from . import event_handlers

logger = logging.getLogger(__name__)

# If girder>=3 is installed, it is safe to continue defining the plugin class, otherwise
# just define a dummy class to prevent error messages from propagating.
if _isGirder3:
from girder import events
from girder.constants import AccessType
from girder_jobs.models.job import Job

from .api.worker import Worker
from . import event_handlers

class WorkerPlugin(GirderPlugin):
DISPLAY_NAME = 'Worker'
class WorkerPlugin(GirderPlugin):
DISPLAY_NAME = 'Worker'

def load(self, info):
getPlugin('jobs').load(info)
def load(self, info):
getPlugin('jobs').load(info)

info['apiRoot'].worker = Worker()
info['apiRoot'].worker = Worker()

registerPluginStaticContent(
plugin='worker',
js=['/girder-plugin-worker.umd.cjs'],
css=['/style.css'],
staticDir=Path(__file__).parent / 'web_client' / 'dist',
tree=info['serverRoot'],
)
registerPluginStaticContent(
plugin='worker',
js=['/girder-plugin-worker.umd.cjs'],
css=['/style.css'],
staticDir=Path(__file__).parent / 'web_client' / 'dist',
tree=info['serverRoot'],
)

events.bind('jobs.schedule', 'worker', event_handlers.schedule)
events.bind('jobs.status.validate', 'worker', event_handlers.validateJobStatus)
events.bind('jobs.status.validTransitions', 'worker', event_handlers.validTransitions)
events.bind('jobs.cancel', 'worker', event_handlers.cancel)
events.bind('model.job.save.after', 'worker', event_handlers.attachJobInfoSpec)
events.bind('model.job.save', 'worker', event_handlers.attachParentJob)
Job().exposeFields(AccessType.SITE_ADMIN, {'celeryTaskId', 'celeryQueue'})
else:
class WorkerPlugin:
pass
events.bind('jobs.schedule', 'worker', event_handlers.schedule)
events.bind('jobs.status.validate', 'worker', event_handlers.validateJobStatus)
events.bind('jobs.status.validTransitions', 'worker', event_handlers.validTransitions)
events.bind('jobs.cancel', 'worker', event_handlers.cancel)
events.bind('model.job.save.after', 'worker', event_handlers.attachJobInfoSpec)
events.bind('model.job.save', 'worker', event_handlers.attachParentJob)
Job().exposeFields(AccessType.SITE_ADMIN, {'celeryTaskId', 'celeryQueue'})
6 changes: 1 addition & 5 deletions girder_worker/girder_plugin/web_client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,5 @@ export default defineConfig({
name: 'GirderPluginWorker',
fileName: 'girder-plugin-worker',
},
},
define: {
__BUILD_TIMESTAMP__: `${+new Date()}`,
'process.env': {}, // for legacy Vue 2
},
}
});
6 changes: 3 additions & 3 deletions requirements-dev.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-e git+https://github.com/girder/girder.git@master#egg=girder
-e git+https://github.com/girder/girder.git@master#egg=girder-jobs&subdirectory=plugins/jobs
-e git+https://github.com/girder/girder.git@master#egg=pytest-girder&subdirectory=pytest_girder
-e git+https://github.com/girder/girder.git@v4-integration#egg=girder
-e git+https://github.com/girder/girder.git@v4-integration#egg=girder-jobs&subdirectory=plugins/jobs
-e git+https://github.com/girder/girder.git@v4-integration#egg=pytest-girder&subdirectory=pytest_girder
coverage
coveralls
flake8
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#
# pip-compile --output-file=requirements.txt requirements-dev.in requirements.in
#
-e git+https://github.com/girder/girder.git@master#egg=girder
-e git+https://github.com/girder/girder.git@v4-integration#egg=girder
# via
# -r requirements-dev.in
# girder-jobs
# pytest-girder
-e git+https://github.com/girder/girder.git@master#egg=girder-jobs&subdirectory=plugins/jobs
-e git+https://github.com/girder/girder.git@v4-integration#egg=girder-jobs&subdirectory=plugins/jobs
# via -r requirements-dev.in
-e git+https://github.com/girder/girder.git@master#egg=pytest-girder&subdirectory=pytest_girder
-e git+https://github.com/girder/girder.git@v4-integration#egg=pytest-girder&subdirectory=pytest_girder
# via -r requirements-dev.in
alabaster==0.7.13
# via sphinx
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def run(self, *args, **kwargs):
install_reqs = f.readlines()

extras_require = {}
extras_require['girder'] = ['girder>=3.0.1', 'girder-jobs>=3.0.1']
extras_require['girder'] = ['girder>=5', 'girder-jobs>=5']

# perform the install
setuptools.setup(
Expand Down

0 comments on commit 2f39300

Please sign in to comment.