BundleSchema, BundlePermissionSchema, BUNDLE_CREATE_RESTRICTED_FIELDS, BUNDLE_UPDATE_RESTRICTED_FIELDS, WorksheetSchema, ) from codalab.rest.users import UserSchema from codalab.rest.util import get_bundle_infos, get_resource_ids, resolve_owner_in_keywords from codalab.server.authenticated_plugin import AuthenticatedProtectedPlugin, ProtectedPlugin from codalab.worker.bundle_state import State from codalab.worker.download_util import BundleTarget logger = logging.getLogger(__name__) @get('/bundles/<uuid:re:%s>' % spec_util.UUID_STR, apply=ProtectedPlugin()) def _fetch_bundle(uuid): """ Fetch bundle by UUID. Query parameters: - `include_display_metadata`: `1` to include additional metadata helpful for displaying the bundle info, `0` to omit them. Default is `0`. - `include`: comma-separated list of related resources to include, such as "owner" """ document = build_bundles_document([uuid]) precondition( len(document['data']) == 1, "data should have exactly one element") document['data'] = document['data'][0] # Flatten data list return document
from codalab.model.tables import GROUP_OBJECT_PERMISSION_ALL from codalab.objects.permission import permission_str from codalab.rest import util as rest_util from codalab.server.authenticated_plugin import ProtectedPlugin from codalab.rest.worksheets import get_worksheet_info, search_worksheets from codalab.rest.bundles import search_bundles from codalab.rest.worksheet_block_schemas import ( BlockModes, MarkupBlockSchema, FetchStatusCodes, FetchStatusSchema, ) from codalab.worker.download_util import BundleTarget @post('/interpret/search', apply=ProtectedPlugin()) def _interpret_search(): """ Returns worksheet items given a search query for bundles. JSON request body: ``` { "keywords": [ list of search keywords ], "schemas": { schema_key: [ list of schema columns ], ... }, "display": [ display args ] } ```
from io import StringIO from datetime import datetime, timedelta from oauthlib.common import generate_token import shlex from bottle import abort, httplib, local, post, request from codalab.client.json_api_client import JsonApiClient from codalab.common import UsageError from codalab.lib import bundle_cli from codalab.lib.codalab_manager import CodaLabManager from codalab.objects.oauth2 import OAuth2Token from codalab.server.authenticated_plugin import ProtectedPlugin @post('/cli/command', apply=ProtectedPlugin()) def post_worksheets_command(): """ JSON request body: ``` { "worksheet_uuid": "0xea72f9b6aa754636a6657ff2b5e005b0", "command": "cl run :main.py 'python main.py'", "autocomplete": false } ``` JSON response body: ``` { "structured_result": { ... },
check_worksheet_has_all_permission, check_worksheet_has_read_permission, ) from codalab.objects.worksheet import Worksheet from codalab.rest.schemas import ( WorksheetSchema, WorksheetPermissionSchema, BundleSchema, WorksheetItemSchema, ) from codalab.rest.users import UserSchema from codalab.rest.util import get_bundle_infos, resolve_owner_in_keywords, get_resource_ids from codalab.server.authenticated_plugin import AuthenticatedProtectedPlugin, ProtectedPlugin @get('/worksheets/<uuid:re:%s>' % spec_util.UUID_STR, apply=ProtectedPlugin()) def fetch_worksheet(uuid): """ Fetch a single worksheet by UUID. Query parameters: - `include`: comma-separated list of related resources to include, such as "owner" """ include_set = query_get_json_api_include_set( supported={ 'owner', 'group_permissions', 'items', 'items.bundle', 'items.bundle.owner',
) from codalab.model.tables import GROUP_OBJECT_PERMISSION_ALL from codalab.objects.permission import permission_str from codalab.rest import util as rest_util from codalab.server.authenticated_plugin import ProtectedPlugin from codalab.rest.worksheets import get_worksheet_info, search_worksheets from codalab.rest.worksheet_block_schemas import ( BlockModes, MarkupBlockSchema, FetchStatusCodes, FetchStatusSchema, ) from codalab.worker.download_util import BundleTarget @post('/interpret/search', apply=ProtectedPlugin()) def _interpret_search(): """ Returns worksheet items given a search query for bundles. JSON request body: ``` { "keywords": [ list of search keywords ], "schemas": { schema_key: [ list of schema columns ], ... }, "display": [ display args ] } ```