text stringlengths 5 22M | id stringlengths 12 177 | metadata dict | __index_level_0__ int64 0 1.37k |
|---|---|---|---|
from fastapi import HTTPException, status
from models.schemas.workspace import AuthProvider
from resources import strings
from services.aad_authentication import AzureADAuthorization
from services.access_service import AccessService, AuthConfigValidationError
def extract_auth_information(workspace_creation_properti... | AzureTRE/api_app/services/authentication.py/0 | {
"file_path": "AzureTRE/api_app/services/authentication.py",
"repo_id": "AzureTRE",
"token_count": 792
} | 94 |
import pytest
from mock import patch
from fastapi import HTTPException
from db.errors import UnableToAccessDatabase
from db.repositories.base import BaseRepository
from api.helpers import get_repository
pytestmark = pytest.mark.asyncio
@patch("db.repositories.base.BaseRepository.create")
async def test_get_reposito... | AzureTRE/api_app/tests_ma/test_api/test_helpers.py/0 | {
"file_path": "AzureTRE/api_app/tests_ma/test_api/test_helpers.py",
"repo_id": "AzureTRE",
"token_count": 202
} | 95 |
from unittest.mock import AsyncMock, MagicMock, patch
from azure.core.exceptions import AzureError
import pytest
from db import events
pytestmark = pytest.mark.asyncio
@patch("db.events.get_credential")
@patch("db.events.CosmosDBManagementClient")
async def test_bootstrap_database_success(cosmos_db_mgmt_client_mock,... | AzureTRE/api_app/tests_ma/test_db/test_events.py/0 | {
"file_path": "AzureTRE/api_app/tests_ma/test_db/test_events.py",
"repo_id": "AzureTRE",
"token_count": 341
} | 96 |
import pytest
from models.domain.request_action import RequestAction
from models.domain.resource import Resource, ResourceType
from models.domain.user_resource import UserResource
from models.domain.workspace_service import WorkspaceService
OPERATION_ID = "0000c8e7-5c42-4fcb-a7fd-294cfc27aa76"
STEP_ID = "main"
@py... | AzureTRE/api_app/tests_ma/test_models/test_resource.py/0 | {
"file_path": "AzureTRE/api_app/tests_ma/test_models/test_resource.py",
"repo_id": "AzureTRE",
"token_count": 688
} | 97 |
### Create a workspace (admin)
POST {{baseUrl}}/workspaces
Accept: {{contentType}}
Authorization: Bearer {{token}}
Content-Type: {{contentType}}
{
"templateName": "{{workspaceTemplate}}",
"properties": {
"display_name": "my workspace",
"description": "my workspace",
"client_id": "{{clientId}}",
"v... | AzureTRE/api_http_requests/API Resource Modifying Endpoints.http/0 | {
"file_path": "AzureTRE/api_http_requests/API Resource Modifying Endpoints.http",
"repo_id": "AzureTRE",
"token_count": 611
} | 98 |
import json
import click
import logging
from tre.api_client import ApiClient
from tre.commands.operation import operation_show
from tre.output import output, output_option, query_option
from .contexts import pass_shared_service_context, SharedServiceContext
from .operation import shared_service_operation
from .operat... | AzureTRE/cli/tre/commands/shared_services/shared_service.py/0 | {
"file_path": "AzureTRE/cli/tre/commands/shared_services/shared_service.py",
"repo_id": "AzureTRE",
"token_count": 3171
} | 99 |
import click
from tre.commands.workspaces.contexts import WorkspaceContext
class WorkspaceAirlockContext(object):
def __init__(self, workspace_id: str, airlock_request_id: str):
self.workspace_id = workspace_id
self.airlock_request_id = airlock_request_id
@staticmethod
def add_airlock_id_... | AzureTRE/cli/tre/commands/workspaces/airlock/contexts.py/0 | {
"file_path": "AzureTRE/cli/tre/commands/workspaces/airlock/contexts.py",
"repo_id": "AzureTRE",
"token_count": 267
} | 100 |
import json
import logging
import click
from tre.api_client import ApiClient
from tre.commands.operation import operation_show
from tre.commands.workspaces.workspace_services.contexts import WorkspaceServiceContext, pass_workspace_service_context
from tre.output import output, output_option, query_option
@click.grou... | AzureTRE/cli/tre/commands/workspaces/workspace_services/user_resources/user_resources.py/0 | {
"file_path": "AzureTRE/cli/tre/commands/workspaces/workspace_services/user_resources/user_resources.py",
"repo_id": "AzureTRE",
"token_count": 1202
} | 101 |
# 'External' storage account - drop location for import
resource "azurerm_storage_account" "sa_import_external" {
name = local.import_external_storage_name
location = var.location
resource_group_name = var.resource_group_name
account_tier = "Standard"
accou... | AzureTRE/core/terraform/airlock/storage_accounts.tf/0 | {
"file_path": "AzureTRE/core/terraform/airlock/storage_accounts.tf",
"repo_id": "AzureTRE",
"token_count": 3858
} | 102 |
resource "azurerm_log_analytics_query_pack" "tre" {
name = "querypack-${var.tre_id}"
resource_group_name = var.resource_group_name
location = var.location
tags = var.tre_core_tags
lifecycle { ignore_changes = [tags] }
}
resource "azurerm_log_analytics_query_pack_quer... | AzureTRE/core/terraform/azure-monitor/query.tf/0 | {
"file_path": "AzureTRE/core/terraform/azure-monitor/query.tf",
"repo_id": "AzureTRE",
"token_count": 674
} | 103 |
# For recommended Azure private DNS zone names see https://docs.microsoft.com/azure/private-link/private-endpoint-dns#azure-services-dns-zone-configuration
# Azure Monitor requires 5 DNS zones:
# - privatelink.monitor.azure.com
# - privatelink.oms.opinsights.azure.com
# - privatelink.ods.opinsights.azure.com
# - priva... | AzureTRE/core/terraform/network/dns_zones.tf/0 | {
"file_path": "AzureTRE/core/terraform/network/dns_zones.tf",
"repo_id": "AzureTRE",
"token_count": 3791
} | 104 |
#!/bin/bash
set -e
script_dir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
if [[ -z ${STORAGE_ACCOUNT} ]]; then
echo "STORAGE_ACCOUNT not set"
exit 1
fi
# The storage account is protected by network rules
#
# The rules need to be temporarily lifted so that the script can determine if the index.html file
# alread... | AzureTRE/core/terraform/scripts/letsencrypt.sh/0 | {
"file_path": "AzureTRE/core/terraform/scripts/letsencrypt.sh",
"repo_id": "AzureTRE",
"token_count": 1899
} | 105 |
#!/bin/bash
# This script is designed to be `source`d to create reusable helper functions
# Notes: Before Az CLI 2.37 this would return a json document with .objectId; that is now .id
# This script polls looking for an app registration with the given ID.
# If after the number of retries no app registration is found,... | AzureTRE/devops/scripts/aad/wait_for_new_app_registration.sh/0 | {
"file_path": "AzureTRE/devops/scripts/aad/wait_for_new_app_registration.sh",
"repo_id": "AzureTRE",
"token_count": 331
} | 106 |
#!/bin/bash
set -o errexit
set -o pipefail
# Uncomment this line to see each command for debugging (careful: this will show secrets!)
# set -o xtrace
activeDirectoryUri="$(az cloud show --query endpoints.activeDirectory --output tsv)"
if [ -n "${TEST_ACCOUNT_CLIENT_ID:-}" ] && [ -n "${TEST_ACCOUNT_CLIENT_SECRET:-}" ... | AzureTRE/devops/scripts/get_access_token.sh/0 | {
"file_path": "AzureTRE/devops/scripts/get_access_token.sh",
"repo_id": "AzureTRE",
"token_count": 719
} | 107 |
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/hashicorp/azurerm" {
version = "3.51.0"
constraints = "3.51.0"
hashes = [
"h1:X13zyweEi+honSpCdijEJBawbG6m1NmGyWDccICIKXs=",
"zh:045a56f984882b8cf111301550e14a513... | AzureTRE/devops/terraform/.terraform.lock.hcl/0 | {
"file_path": "AzureTRE/devops/terraform/.terraform.lock.hcl",
"repo_id": "AzureTRE",
"token_count": 693
} | 108 |
# User roles
The Azure TRE solution has 8 different user roles defined. The roles are modeled around a set of tasks for each role. The roles are not mutually exclusive, and one person can have multiple roles assigned to be able to carry out a broader set of tasks.
Before you deploy a Trusted Research Environment base... | AzureTRE/docs/azure-tre-overview/user-roles.md/0 | {
"file_path": "AzureTRE/docs/azure-tre-overview/user-roles.md",
"repo_id": "AzureTRE",
"token_count": 1231
} | 109 |
# Workspace Applications
## Purpose
Access to workspaces is also controlled using app registrations - one per workspace. The configuration of the app registration depends on the nature of the workspace, but this section covers the typical minimum settings.
## Application Roles
| Display name | Description | Allowed ... | AzureTRE/docs/tre-admins/identities/workspace.md/0 | {
"file_path": "AzureTRE/docs/tre-admins/identities/workspace.md",
"repo_id": "AzureTRE",
"token_count": 1161
} | 110 |
# GitHub Actions workflows (CI/CD)
To deploy the Azure TRE using GitHub workflows, create a fork of the repository.
Deployment is done using the `/.github/workflows/deploy_tre.yml` workflow. This method is also used to deploy the dev/test environment for the original Azure TRE repository.
## Setup instructions
Befo... | AzureTRE/docs/tre-admins/setup-instructions/workflows.md/0 | {
"file_path": "AzureTRE/docs/tre-admins/setup-instructions/workflows.md",
"repo_id": "AzureTRE",
"token_count": 2267
} | 111 |
# Pipeline Templates
Occasionally there will be a need for the deployment / update of one resource to affect a change in another. This section outlines how that can be achieved with Pipeline Templates.
## Overview
A pipeline template is an optional `pipeline: {}` block that can be added to the top level of a resource... | AzureTRE/docs/tre-templates/pipeline-templates/overview.md/0 | {
"file_path": "AzureTRE/docs/tre-templates/pipeline-templates/overview.md",
"repo_id": "AzureTRE",
"token_count": 753
} | 112 |
# Setting the logging level to DEBUG on the Resource Processor and API
For security, the API and Resource PRocessor are configured to not show detailed error messages and stack trace when an error occurs.
You can enable debugging on the API and Resource Processor by setting `logging_level=debug` under developer_setti... | AzureTRE/docs/troubleshooting-faq/debug-logs.md/0 | {
"file_path": "AzureTRE/docs/troubleshooting-faq/debug-logs.md",
"repo_id": "AzureTRE",
"token_count": 125
} | 113 |
import asyncio
import logging
from httpx import AsyncClient, Timeout
import os
from urllib.parse import urlparse
from azure.storage.blob import BlobClient
from airlock import strings
from e2e_tests.helpers import get_auth_header, get_full_endpoint
LOGGER = logging.getLogger(__name__)
TIMEOUT = Timeout(10, read=30)
a... | AzureTRE/e2e_tests/airlock/request.py/0 | {
"file_path": "AzureTRE/e2e_tests/airlock/request.py",
"repo_id": "AzureTRE",
"token_count": 1490
} | 114 |
import asyncio
import pytest
import config
from e2e_tests.conftest import disable_and_delete_tre_resource, disable_and_delete_ws_resource
from resources.workspace import get_workspace_auth_details
from resources.resource import post_resource
from resources import strings
from helpers import get_admin_token
pytestmark... | AzureTRE/e2e_tests/test_performance.py/0 | {
"file_path": "AzureTRE/e2e_tests/test_performance.py",
"repo_id": "AzureTRE",
"token_count": 2428
} | 115 |
def get_installation_id(msg_body):
"""
This is used to identify each bundle install within the porter state store.
"""
return msg_body['id']
| AzureTRE/resource_processor/resources/helpers.py/0 | {
"file_path": "AzureTRE/resource_processor/resources/helpers.py",
"repo_id": "AzureTRE",
"token_count": 53
} | 116 |
from mock import patch
import logging
from shared.logging import shell_output_logger
@patch("shared.logging.logger")
def test_shell_output_logger_empty_console_output(mock_logger):
shell_output_logger("", "prefix", logging.DEBUG)
mock_logger.debug.assert_called_once_with("shell console output is empty.")
@p... | AzureTRE/resource_processor/tests_rp/test_logging.py/0 | {
"file_path": "AzureTRE/resource_processor/tests_rp/test_logging.py",
"repo_id": "AzureTRE",
"token_count": 444
} | 117 |
resource "azurerm_service_plan" "notifier_plan" {
name = "airlock-notifier-plan-${var.tre_id}"
resource_group_name = data.azurerm_resource_group.core.name
location = data.azurerm_resource_group.core.location
sku_name = "WS1"
os_type = "Windows"
tags ... | AzureTRE/templates/shared_services/airlock_notifier/terraform/airlock_notifier.tf/0 | {
"file_path": "AzureTRE/templates/shared_services/airlock_notifier/terraform/airlock_notifier.tf",
"repo_id": "AzureTRE",
"token_count": 1292
} | 118 |
#!/bin/bash
set -e
script_dir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
while [ "$1" != "" ]; do
case $1 in
--storage_account_name)
shift
storage_account_name=$1
;;
--fqdn)
shift
fqdn=$1
;;
--keyvault_name)
shift
keyvault_name=$1
... | AzureTRE/templates/shared_services/certs/scripts/letsencrypt.sh/0 | {
"file_path": "AzureTRE/templates/shared_services/certs/scripts/letsencrypt.sh",
"repo_id": "AzureTRE",
"token_count": 1516
} | 119 |
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/hashicorp/azurerm" {
version = "3.5.0"
constraints = "3.5.0"
hashes = [
"h1:T4XsCHDT839VehWKdxbVsLn0ECjcQaUTzbSGW055pgM=",
"zh:0d8ae6d6e87f44ed4a178be03d6466339b0... | AzureTRE/templates/shared_services/cyclecloud/terraform/.terraform.lock.hcl/0 | {
"file_path": "AzureTRE/templates/shared_services/cyclecloud/terraform/.terraform.lock.hcl",
"repo_id": "AzureTRE",
"token_count": 1351
} | 120 |
#!/bin/bash
# See remove_state.sh for the purpose of these scripts
echo "IMPORTING STATE FOR FIREWALL..."
# check for the existence of the RG. If it's not there it's because we're in CI and building from scratch - we can skip this script
set +e
RESOURCE_GROUP_ID="rg-${TRE_ID}"
az group show -n $RESOURCE_GROUP_ID
if [ ... | AzureTRE/templates/shared_services/firewall/terraform/import_state.sh/0 | {
"file_path": "AzureTRE/templates/shared_services/firewall/terraform/import_state.sh",
"repo_id": "AzureTRE",
"token_count": 2344
} | 121 |
data "azurerm_log_analytics_workspace" "tre" {
name = "log-${var.tre_id}"
resource_group_name = local.core_resource_group_name
}
data "azurerm_service_plan" "core" {
name = "plan-${var.tre_id}"
resource_group_name = local.core_resource_group_name
}
data "azurerm_subnet" "shared" ... | AzureTRE/templates/shared_services/gitea/terraform/data.tf/0 | {
"file_path": "AzureTRE/templates/shared_services/gitea/terraform/data.tf",
"repo_id": "AzureTRE",
"token_count": 790
} | 122 |
#!/bin/bash
docker_pull_timeout=10
while true; do
if [ $docker_pull_timeout == 0 ]; then
echo 'ERROR - Timeout while waiting for sonatype/nexus3 to be pulled from Docker Hub'
exit 1
fi
if docker pull sonatype/nexus3; then
echo "Image pulled successfully"
break
else
echo "Failed to p... | AzureTRE/templates/shared_services/sonatype-nexus-vm/scripts/deploy_nexus_container.sh/0 | {
"file_path": "AzureTRE/templates/shared_services/sonatype-nexus-vm/scripts/deploy_nexus_container.sh",
"repo_id": "AzureTRE",
"token_count": 234
} | 123 |
#!/bin/bash
set -o pipefail
set -o nounset
# set -o xtrace
if [ -z "$1" ]
then
echo 'New password to set needs to be passed as argument'
fi
# Get the current password so we can post to the API
# (this is created in /nexus-data mounted volume as part of Nexus container start-up)
password_timeout=300
echo 'Checki... | AzureTRE/templates/shared_services/sonatype-nexus-vm/scripts/reset_nexus_password.sh/0 | {
"file_path": "AzureTRE/templates/shared_services/sonatype-nexus-vm/scripts/reset_nexus_password.sh",
"repo_id": "AzureTRE",
"token_count": 450
} | 124 |
---
schemaVersion: 1.0.0
name: tre-service-azureml
version: 0.8.10
description: "An Azure TRE service for Azure Machine Learning"
registry: azuretre
dockerfile: Dockerfile.tmpl
credentials:
# Credentials for interacting with the AAD Auth tenant
- name: auth_client_id
env: AUTH_CLIENT_ID
- name: auth_client_s... | AzureTRE/templates/workspace_services/azureml/porter.yaml/0 | {
"file_path": "AzureTRE/templates/workspace_services/azureml/porter.yaml",
"repo_id": "AzureTRE",
"token_count": 2888
} | 125 |
Dockerfile.tmpl | AzureTRE/templates/workspace_services/azureml/user_resources/aml_compute/.dockerignore/0 | {
"file_path": "AzureTRE/templates/workspace_services/azureml/user_resources/aml_compute/.dockerignore",
"repo_id": "AzureTRE",
"token_count": 6
} | 126 |
# Contents
## porter.yaml
This is the porter manifest. See <https://porter.sh/author-bundles/> for
details on every field and how to configure your bundle. This is a required
file.
## helpers.sh
This is a bash script where you can place helper functions that you can call
from your porter.yaml file.
## README.md
T... | AzureTRE/templates/workspace_services/databricks/README.md/0 | {
"file_path": "AzureTRE/templates/workspace_services/databricks/README.md",
"repo_id": "AzureTRE",
"token_count": 394
} | 127 |
output "gitea_fqdn" {
value = azurerm_linux_web_app.gitea.default_hostname
}
output "authentication_callback_uri" {
value = "https://${azurerm_linux_web_app.gitea.default_hostname}/user/oauth2/oidc/callback"
}
output "connection_uri" {
value = "https://${azurerm_linux_web_app.gitea.default_hostname}/"
}
output... | AzureTRE/templates/workspace_services/gitea/terraform/outputs.tf/0 | {
"file_path": "AzureTRE/templates/workspace_services/gitea/terraform/outputs.tf",
"repo_id": "AzureTRE",
"token_count": 186
} | 128 |
#!/usr/bin/env sh
echo >&2 "sshd exited. code=${1}"
# terminate other services to exit from the container
exec s6-svscanctl -t /var/run/s6/services | AzureTRE/templates/workspace_services/guacamole/guacamole-server/docker/services/sshd/finish/0 | {
"file_path": "AzureTRE/templates/workspace_services/guacamole/guacamole-server/docker/services/sshd/finish",
"repo_id": "AzureTRE",
"token_count": 53
} | 129 |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... | AzureTRE/templates/workspace_services/guacamole/guacamole-server/guacamole-auth-azure/src/main/java/org/apache/guacamole/auth/azuretre/user/TreUserContext.java/0 | {
"file_path": "AzureTRE/templates/workspace_services/guacamole/guacamole-server/guacamole-auth-azure/src/main/java/org/apache/guacamole/auth/azuretre/user/TreUserContext.java",
"repo_id": "AzureTRE",
"token_count": 1067
} | 130 |
data "azurerm_client_config" "current" {}
data "azurerm_resource_group" "ws" {
name = "rg-${var.tre_id}-ws-${local.short_workspace_id}"
}
data "azurerm_virtual_network" "ws" {
name = "vnet-${var.tre_id}-ws-${local.short_workspace_id}"
resource_group_name = "rg-${var.tre_id}-ws-${local.short_works... | AzureTRE/templates/workspace_services/guacamole/terraform/data.tf/0 | {
"file_path": "AzureTRE/templates/workspace_services/guacamole/terraform/data.tf",
"repo_id": "AzureTRE",
"token_count": 1029
} | 131 |
# GUID to identify the workspace service
ID=__CHANGE_ME__
# GUID to identify the workspace bundle
WORKSPACE_ID="__CHANGE_ME__"
# Service principal client ID & secret used by the inference service to connect to Azure ML
INFERENCE_SP_CLIENT_ID=__CHANGE_ME__
INFERENCE_SP_CLIENT_SECRET=__CHANGE_ME__
| AzureTRE/templates/workspace_services/innereye/.env.sample/0 | {
"file_path": "AzureTRE/templates/workspace_services/innereye/.env.sample",
"repo_id": "AzureTRE",
"token_count": 98
} | 132 |
variable "workspace_id" {
type = string
}
variable "tre_id" {
type = string
}
variable "tre_resource_id" {
type = string
}
variable "arm_tenant_id" {
type = string
}
variable "arm_client_id" {
type = string
}
variable "arm_client_secret" {
type = string
}
variable "arm_use_msi" {
type = bool
}
variable "i... | AzureTRE/templates/workspace_services/innereye/terraform/variables.tf/0 | {
"file_path": "AzureTRE/templates/workspace_services/innereye/terraform/variables.tf",
"repo_id": "AzureTRE",
"token_count": 173
} | 133 |
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/hashicorp/azurerm" {
version = "3.18.0"
constraints = "3.18.0"
hashes = [
"h1:JP1ql3IvCpG1f88Zfb+W0Gm9kRKHg2c+VXOfVKpHZTY=",
"zh:038d308618653e999070f437d42c009d1... | AzureTRE/templates/workspace_services/mysql/terraform/.terraform.lock.hcl/0 | {
"file_path": "AzureTRE/templates/workspace_services/mysql/terraform/.terraform.lock.hcl",
"repo_id": "AzureTRE",
"token_count": 1359
} | 134 |
CREATE ROLE ${OHDSI_ADMIN_ROLE} CREATEDB REPLICATION VALID UNTIL 'infinity';
COMMENT ON ROLE ${OHDSI_ADMIN_ROLE} IS 'Administration group for OHDSI applications';
CREATE ROLE ${OHDSI_APP_ROLE} VALID UNTIL 'infinity';
COMMENT ON ROLE ${OHDSI_APP_ROLE} IS 'Application groupfor OHDSI applications';
CREATE ROLE ${OHDSI... | AzureTRE/templates/workspace_services/ohdsi/sql/atlas_create_roles_users.sql/0 | {
"file_path": "AzureTRE/templates/workspace_services/ohdsi/sql/atlas_create_roles_users.sql",
"repo_id": "AzureTRE",
"token_count": 371
} | 135 |
# The API needs permissions to stop/start VMs
data "azurerm_user_assigned_identity" "api_id" {
name = "id-api-${var.tre_id}"
resource_group_name = "rg-${var.tre_id}"
}
# TODO: the assigned builtin role gives too wide permissions.
# https://github.com/microsoft/AzureTRE/issues/2389
resource "azurer... | AzureTRE/templates/workspaces/base/terraform/api-permissions.tf/0 | {
"file_path": "AzureTRE/templates/workspaces/base/terraform/api-permissions.tf",
"repo_id": "AzureTRE",
"token_count": 339
} | 136 |
import React, { useContext } from 'react';
import { Workspace } from '../../models/workspace';
import { ResourceCardList } from '../shared/ResourceCardList';
import { Resource } from '../../models/resource';
import { PrimaryButton, Stack } from '@fluentui/react';
import { ResourceType } from '../../models/resourceType... | AzureTRE/ui/app/src/components/root/RootDashboard.tsx/0 | {
"file_path": "AzureTRE/ui/app/src/components/root/RootDashboard.tsx",
"repo_id": "AzureTRE",
"token_count": 832
} | 137 |
import React, { useContext, useEffect, useState } from 'react';
import { ComponentAction, VMPowerStates, Resource } from '../../models/resource';
import { CommandBar, IconButton, IContextualMenuItem, IContextualMenuProps } from '@fluentui/react';
import { RoleName, WorkspaceRoleName } from '../../models/roleNames';
imp... | AzureTRE/ui/app/src/components/shared/ResourceContextMenu.tsx/0 | {
"file_path": "AzureTRE/ui/app/src/components/shared/ResourceContextMenu.tsx",
"repo_id": "AzureTRE",
"token_count": 3761
} | 138 |
import { DefaultButton, Dialog, DialogFooter, DocumentCard, DocumentCardDetails, DocumentCardPreview, DocumentCardTitle, DocumentCardType, getTheme, Icon, IDocumentCardPreviewProps, IStackTokens, Panel, PanelType, PrimaryButton, Spinner, SpinnerSize, Stack, TextField } from "@fluentui/react";
import { useCallback, useC... | AzureTRE/ui/app/src/components/shared/airlock/AirlockNewRequest.tsx/0 | {
"file_path": "AzureTRE/ui/app/src/components/shared/airlock/AirlockNewRequest.tsx",
"repo_id": "AzureTRE",
"token_count": 3274
} | 139 |
import React, { useContext } from 'react';
import { WorkspaceContext } from '../../contexts/WorkspaceContext';
import { Resource } from '../../models/resource';
import { Workspace } from '../../models/workspace';
import { useComponentManager } from '../../hooks/useComponentManager';
import { ResourceHeader } from '../s... | AzureTRE/ui/app/src/components/workspaces/WorkspaceItem.tsx/0 | {
"file_path": "AzureTRE/ui/app/src/components/workspaces/WorkspaceItem.tsx",
"repo_id": "AzureTRE",
"token_count": 289
} | 140 |
export interface CostResource {
id: string;
name: string;
costs: Array<CostItem>;
}
export interface CostItem {
cost: number,
currency: string,
date?: string
}
| AzureTRE/ui/app/src/models/costs.ts/0 | {
"file_path": "AzureTRE/ui/app/src/models/costs.ts",
"repo_id": "AzureTRE",
"token_count": 56
} | 141 |
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';
| AzureTRE/ui/app/src/setupTests.ts/0 | {
"file_path": "AzureTRE/ui/app/src/setupTests.ts",
"repo_id": "AzureTRE",
"token_count": 75
} | 142 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os
import sys
import json
import re
data_dir=sys.argv[1]
def unify_ent2id(ent2id, method='max'):
id2ent = {}
for k, v in ent2id.items():
if v in id2ent:
if method == 'min':
id2ent[v] = k if le... | BioGPT/examples/RE-BC5CDR/rebuild_data.py/0 | {
"file_path": "BioGPT/examples/RE-BC5CDR/rebuild_data.py",
"repo_id": "BioGPT",
"token_count": 1519
} | 143 |
# Text Generation
You can use the pre-trained BioGPT model for free text generation, just as how you use GPT models.
## Model Checkpoint
We provide our pre-trained BioGPT model. See [here](../../README.md#pre-trained-models)
## Generation
We here provide an interactive way for generation:
``` bash
python interactive.p... | BioGPT/examples/text-generation/README.md/0 | {
"file_path": "BioGPT/examples/text-generation/README.md",
"repo_id": "BioGPT",
"token_count": 90
} | 144 |
#!/usr/bin/env bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Usage:
# # Do work and commit your work.
# # Format files that differ from origin/main.
# bash format.sh
# # Commit changed files with message 'Run yapf and ruff'
#
#
# YAPF + Clang formatter (if installed). T... | BitBLAS/format.sh/0 | {
"file_path": "BitBLAS/format.sh",
"repo_id": "BitBLAS",
"token_count": 2050
} | 145 |
import torch
import numpy as np
import torch.nn.functional as F
from lm_eval.base import BaseLM
from datasets import load_dataset
def set_seed(seed):
np.random.seed(seed)
torch.random.manual_seed(seed)
def get_test_dataset(dataset_name, tokenizer, seqlen=2048):
if dataset_name == "wikitext2":
t... | BitBLAS/integration/BitNet/eval_utils.py/0 | {
"file_path": "BitBLAS/integration/BitNet/eval_utils.py",
"repo_id": "BitBLAS",
"token_count": 1916
} | 146 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import sys
import os
# installing tvm
install_tvm_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "3rdparty", "tvm", "python")
if os.path.exists(install_tvm_path) and install_tvm_path not in sys.path:
os.environ["PYTHONPA... | BitBLAS/python/bitblas/__init__.py/0 | {
"file_path": "BitBLAS/python/bitblas/__init__.py",
"repo_id": "BitBLAS",
"token_count": 1186
} | 147 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Rasteration Plan For L2 Cache Locality"""
from typing import List
class Rasterization:
def __init__(self) -> None:
pass
def get_code(self) -> List[str]:
raise NotImplementedError()
class NoRasterization(Rasterizat... | BitBLAS/python/bitblas/base/roller/rasterization.py/0 | {
"file_path": "BitBLAS/python/bitblas/base/roller/rasterization.py",
"repo_id": "BitBLAS",
"token_count": 1112
} | 148 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# pylint: disable=invalid-name
"""Reduction rule for operators including softmax, layer norm, RMS norm, etc"""
from typing import List, Union
from functools import reduce
from tvm import tir
from tvm.target import Target
from ..base import norm... | BitBLAS/python/bitblas/gpu/general_reduction.py/0 | {
"file_path": "BitBLAS/python/bitblas/gpu/general_reduction.py",
"repo_id": "BitBLAS",
"token_count": 9221
} | 149 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# pre-transformed tir expression of matmul
import tvm
from tvm import te, tir
def conv2d_nhwc_ohwi(
n,
f,
h,
w,
c,
kh,
kw,
s,
d,
p,
in_dtype="float16",
accum_dtype="float16",
out_dtype="float16... | BitBLAS/python/bitblas/ops/impl/convolution2d_impl.py/0 | {
"file_path": "BitBLAS/python/bitblas/ops/impl/convolution2d_impl.py",
"repo_id": "BitBLAS",
"token_count": 2829
} | 150 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from .annotate_decode_block import AnnotateDecodeInformation
from .weight_only_propagate import WeightOnlyLayoutPropagation
| BitBLAS/python/bitblas/relax/transform/__init__.py/0 | {
"file_path": "BitBLAS/python/bitblas/relax/transform/__init__.py",
"repo_id": "BitBLAS",
"token_count": 51
} | 151 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import tvm
from tvm.script import tir as T
import bitblas
from bitblas.base.roller.policy import TensorCorePolicy, DefaultPolicy
from bitblas.base.roller.arch import CUDA
from bitblas.gpu.matmul_analysis import get_tensorized_func_and_tags
from bi... | BitBLAS/testing/python/type_conversion/test_lop3_type_conversion.py/0 | {
"file_path": "BitBLAS/testing/python/type_conversion/test_lop3_type_conversion.py",
"repo_id": "BitBLAS",
"token_count": 920
} | 152 |
date ; hostname ; pwd
EXP_NODES=1
EXP_IS=384
EXP_PGB=16
EXP_PGEB=16
EXP_LR=4.5e-6
EXP_BS=256
EXP_ME=30
EXP_WS=0.1
EXP_WD=0.01
EXP_LMH=5
EXP_LMC=5
EXP_LP=BridgeTower_pt_base.ckpt
EXP_RGM=blip_randaug_wc
EXP_PGEBT=256
EXP_PGEBI=128
EXP_GWG=True
EXP_GAII=False
EXP_IC=1
export MASTER_ADDR=$HOSTNAME
export MASTER_PORT=198... | BridgeTower/scripts/ftfpt_base_irtr_itm_itc_coco.sh/0 | {
"file_path": "BridgeTower/scripts/ftfpt_base_irtr_itm_itc_coco.sh",
"repo_id": "BridgeTower",
"token_count": 654
} | 153 |
from sacred import Experiment
ex = Experiment("VL")
def _loss_names(d):
ret = {
"itm": 0,
"mlm": 0,
"itc": 0,
"itm_itc": 0,
"irtr_itm_itc": 0,
"vqa": 0,
"nlvr2": 0,
"irtr": 0,
"snli": 0,
}
ret.update(d)
return ret
@ex.config
de... | BridgeTower/src/config.py/0 | {
"file_path": "BridgeTower/src/config.py",
"repo_id": "BridgeTower",
"token_count": 5581
} | 154 |
from .base_dataset import BaseDataset
class F30KCaptionKarpathyDataset(BaseDataset):
def __init__(self, *args, split="", **kwargs):
assert split in ["train", "val", "test"]
if split == "train":
names = ["f30k_caption_karpathy_train", "f30k_caption_karpathy_val"]
elif split == ... | BridgeTower/src/datasets/f30k_caption_karpathy_dataset.py/0 | {
"file_path": "BridgeTower/src/datasets/f30k_caption_karpathy_dataset.py",
"repo_id": "BridgeTower",
"token_count": 316
} | 155 |
import torch
import torch.nn as nn
import torch.nn.functional as F
import json
from tqdm import tqdm
import functools
from torch.utils.data.distributed import DistributedSampler
from einops import rearrange
import torch.distributed as dist
def init_weights(module):
if isinstance(module, (nn.Linear, nn.Embedding))... | BridgeTower/src/modules/objectives.py/0 | {
"file_path": "BridgeTower/src/modules/objectives.py",
"repo_id": "BridgeTower",
"token_count": 41224
} | 156 |
import json
import pandas as pd
import pyarrow as pa
import gc
import random
import os
from tqdm import tqdm
from tqdm.contrib import tzip
from glob import glob
def path2rest(path, iid2captions):
split, _, name = path.split("/")[-3:]
split = split.split("_")[-1]
iid = name
with open(path, "rb") as f... | BridgeTower/src/utils/write_sbu.py/0 | {
"file_path": "BridgeTower/src/utils/write_sbu.py",
"repo_id": "BridgeTower",
"token_count": 900
} | 157 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch.nn as nn
import numpy as np
import torch.nn.functional as F
from models.networks.base_network import BaseNetwork
from models.networks.normalization import get_nonspade_norm_layer
class ConvEncoder(BaseNetwork):
""" Same archite... | Bringing-Old-Photos-Back-to-Life/Face_Enhancement/models/networks/encoder.py/0 | {
"file_path": "Bringing-Old-Photos-Back-to-Life/Face_Enhancement/models/networks/encoder.py",
"repo_id": "Bringing-Old-Photos-Back-to-Life",
"token_count": 942
} | 158 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
def create_model(opt):
if opt.model == "pix2pixHD":
from .pix2pixHD_model import Pix2PixHDModel, InferenceModel
if opt.isTrain:
model = Pix2PixHDModel()
else:
model = InferenceMo... | Bringing-Old-Photos-Back-to-Life/Global/models/models.py/0 | {
"file_path": "Bringing-Old-Photos-Back-to-Life/Global/models/models.py",
"repo_id": "Bringing-Old-Photos-Back-to-Life",
"token_count": 560
} | 159 |
# Ke Chen
# knutchen@ucsd.edu
# HTS-AT: A HIERARCHICAL TOKEN-SEMANTIC AUDIO TRANSFORMER FOR SOUND CLASSIFICATION AND DETECTION
# Model Core
# below codes are based and referred from https://github.com/microsoft/Swin-Transformer
# Swin Transformer for Computer Vision: https://arxiv.org/pdf/2103.14030.pdf
import math
i... | CLAP/msclap/models/htsat.py/0 | {
"file_path": "CLAP/msclap/models/htsat.py",
"repo_id": "CLAP",
"token_count": 19803
} | 160 |
Evaluating Pre-trained Models
=============================
First, download a pre-trained model along with its vocabularies:
.. code-block:: console
> curl https://dl.fbaipublicfiles.com/fairseq/models/wmt14.v2.en-fr.fconv-py.tar.bz2 | tar xvjf -
This model uses a `Byte Pair Encoding (BPE)
vocabulary <https://a... | COCO-LM/fairseq/docs/getting_started.rst/0 | {
"file_path": "COCO-LM/fairseq/docs/getting_started.rst",
"repo_id": "COCO-LM",
"token_count": 2848
} | 161 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import importlib
import os
# automatically import any Python files in the current directory
cur_dir = os.path.dirname(__file__)
for file in o... | COCO-LM/fairseq/examples/adaptive_span/__init__.py/0 | {
"file_path": "COCO-LM/fairseq/examples/adaptive_span/__init__.py",
"repo_id": "COCO-LM",
"token_count": 248
} | 162 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from fairseq.models.bart import BARTModel
import argparse
XSUM_KWARGS = dict(beam=6, lenpen=1.0, max_len_b=60, min_len=10, no_re... | COCO-LM/fairseq/examples/bart/summarize.py/0 | {
"file_path": "COCO-LM/fairseq/examples/bart/summarize.py",
"repo_id": "COCO-LM",
"token_count": 1484
} | 163 |
#!/usr/bin/env python3 -u
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import glob
import numpy as np
DIM = 1024
def compute_dist(source_embs, target_embs, k=5, return... | COCO-LM/fairseq/examples/criss/sentence_retrieval/encoder_analysis.py/0 | {
"file_path": "COCO-LM/fairseq/examples/criss/sentence_retrieval/encoder_analysis.py",
"repo_id": "COCO-LM",
"token_count": 1476
} | 164 |
#!/bin/bash
# Adapted from https://github.com/facebookresearch/MIXER/blob/master/prepareData.sh
URLS=(
"https://s3.amazonaws.com/research.metamind.io/wikitext/wikitext-103-v1.zip"
)
FILES=(
"wikitext-103-v1.zip"
)
for ((i=0;i<${#URLS[@]};++i)); do
file=${FILES[i]}
if [ -f $file ]; then
echo "$... | COCO-LM/fairseq/examples/language_model/prepare-wikitext-103.sh/0 | {
"file_path": "COCO-LM/fairseq/examples/language_model/prepare-wikitext-103.sh",
"repo_id": "COCO-LM",
"token_count": 425
} | 165 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from fairseq.tasks import register_task
from fairseq.tasks.multilingual_translation import MultilingualTranslationTask
from .loss.latent_dept... | COCO-LM/fairseq/examples/latent_depth/latent_depth_src/multilingual_translation_latent_depth.py/0 | {
"file_path": "COCO-LM/fairseq/examples/latent_depth/latent_depth_src/multilingual_translation_latent_depth.py",
"repo_id": "COCO-LM",
"token_count": 4132
} | 166 |
# M2M-100 Tokenization
We apply different tokenization strategies for different languages following the existing literature. Here we provide tok.sh a tokenizer that can be used to reproduce our results.
To reproduce the results, follow these steps:
```
tgt_lang=...
reference_translation=...
cat generation_output | g... | COCO-LM/fairseq/examples/m2m_100/tokenizers/README.md/0 | {
"file_path": "COCO-LM/fairseq/examples/m2m_100/tokenizers/README.md",
"repo_id": "COCO-LM",
"token_count": 207
} | 167 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
import glob
import argparse
from utils.dedup import deup
import sys
WORKDIR_ROOT = os.environ.get('WORKDIR_ROOT', None)
if WORKDI... | COCO-LM/fairseq/examples/multilingual/data_scripts/check_self_overlaps.py/0 | {
"file_path": "COCO-LM/fairseq/examples/multilingual/data_scripts/check_self_overlaps.py",
"repo_id": "COCO-LM",
"token_count": 1752
} | 168 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import argparse
def deup(src_file, tgt_file, src_file_out, tgt_file_out):
seen = set()
dup_count = 0
with open(src_file, encodin... | COCO-LM/fairseq/examples/multilingual/data_scripts/utils/dedup.py/0 | {
"file_path": "COCO-LM/fairseq/examples/multilingual/data_scripts/utils/dedup.py",
"repo_id": "COCO-LM",
"token_count": 713
} | 169 |
# Examples of Training scripts for Non-autoregressive Machine Translation models
### Non-autoregressive Transformer (NAT, Gu et al., 2017)
Note that we need to have an additional module to perform "length prediction" (`--length-loss-factor`) before generating the whole sequence.
```bash
fairseq-train \
data-bin/wm... | COCO-LM/fairseq/examples/nonautoregressive_translation/scripts.md/0 | {
"file_path": "COCO-LM/fairseq/examples/nonautoregressive_translation/scripts.md",
"repo_id": "COCO-LM",
"token_count": 2500
} | 170 |
# Finetuning RoBERTa on RACE tasks
### 1) Download the data from RACE website (http://www.cs.cmu.edu/~glai1/data/race/)
### 2) Preprocess RACE data:
```bash
python ./examples/roberta/preprocess_RACE.py --input-dir <input-dir> --output-dir <extracted-data-dir>
./examples/roberta/preprocess_RACE.sh <extracted-data-dir>... | COCO-LM/fairseq/examples/roberta/README.race.md/0 | {
"file_path": "COCO-LM/fairseq/examples/roberta/README.race.md",
"repo_id": "COCO-LM",
"token_count": 1065
} | 171 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import json
import os
from collections import defaultdict
from examples.simultaneous_translation.eval.eval_latency import LatencyScorer
from ... | COCO-LM/fairseq/examples/simultaneous_translation/eval/scorers/scorer.py/0 | {
"file_path": "COCO-LM/fairseq/examples/simultaneous_translation/eval/scorers/scorer.py",
"repo_id": "COCO-LM",
"token_count": 2964
} | 172 |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from examples.speech_recognition.data.replabels import pack_replabels
from fairseq import utils
from fair... | COCO-LM/fairseq/examples/speech_recognition/criterions/ASG_loss.py/0 | {
"file_path": "COCO-LM/fairseq/examples/speech_recognition/criterions/ASG_loss.py",
"repo_id": "COCO-LM",
"token_count": 2794
} | 173 |
import importlib
import os
for file in os.listdir(os.path.dirname(__file__)):
if file.endswith(".py") and not file.startswith("_"):
model_name = file[: file.find(".py")]
importlib.import_module("examples.speech_recognition.models." + model_name)
| COCO-LM/fairseq/examples/speech_recognition/models/__init__.py/0 | {
"file_path": "COCO-LM/fairseq/examples/speech_recognition/models/__init__.py",
"repo_id": "COCO-LM",
"token_count": 107
} | 174 |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import logging
import os
from pathlib import Path
import shutil
from itertools import groupby
from temp... | COCO-LM/fairseq/examples/speech_to_text/prep_mtedx_data.py/0 | {
"file_path": "COCO-LM/fairseq/examples/speech_to_text/prep_mtedx_data.py",
"repo_id": "COCO-LM",
"token_count": 4504
} | 175 |
# Truncated Backpropagation Through Time (BPTT)
Truncated BPTT is a useful technique for training language models on very long
sequences. Typically a long sequences is split into chunks and a language model
is trained over the chunks sequentially. The LM may condition on previous
chunks, but gradients only flow throug... | COCO-LM/fairseq/examples/truncated_bptt/README.md/0 | {
"file_path": "COCO-LM/fairseq/examples/truncated_bptt/README.md",
"repo_id": "COCO-LM",
"token_count": 1071
} | 176 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
from dataclasses import dataclass, field
from typing import Optional
import numpy as np
import torch
from fairseq.data import ... | COCO-LM/fairseq/fairseq/benchmark/dummy_lm.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/benchmark/dummy_lm.py",
"repo_id": "COCO-LM",
"token_count": 1584
} | 177 |
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import math
from argparse import Namespace
from dataclasses import dataclass, f... | COCO-LM/fairseq/fairseq/criterions/ctc.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/criterions/ctc.py",
"repo_id": "COCO-LM",
"token_count": 5605
} | 178 |
# cython: language_level=3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
cimport cython
cimport numpy as np
from libc.stdint cimport int32_t, int64_t
from libcpp cimpo... | COCO-LM/fairseq/fairseq/data/data_utils_fast.pyx/0 | {
"file_path": "COCO-LM/fairseq/fairseq/data/data_utils_fast.pyx",
"repo_id": "COCO-LM",
"token_count": 3041
} | 179 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import re
from fairseq.data.encoders import register_tokenizer
from fairseq.dataclass import FairseqDataclass
@register_tokenizer("space", ... | COCO-LM/fairseq/fairseq/data/encoders/space_tokenizer.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/data/encoders/space_tokenizer.py",
"repo_id": "COCO-LM",
"token_count": 210
} | 180 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from functools import lru_cache
import numpy as np
import torch
from fairseq.data import Dictionary, data_utils
from . import BaseWrapperDat... | COCO-LM/fairseq/fairseq/data/mask_tokens_dataset.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/data/mask_tokens_dataset.py",
"repo_id": "COCO-LM",
"token_count": 4426
} | 181 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import subprocess
import json
import tempfile
import hashlib
import os
from typing import Hashable
try:
import pyarrow.plasma as plasma
... | COCO-LM/fairseq/fairseq/data/plasma_utils.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/data/plasma_utils.py",
"repo_id": "COCO-LM",
"token_count": 2659
} | 182 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import numpy as np
from . import BaseWrapperDataset
logger = logging.getLogger(__name__)
class SubsampleDataset(BaseWrapp... | COCO-LM/fairseq/fairseq/data/subsample_dataset.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/data/subsample_dataset.py",
"repo_id": "COCO-LM",
"token_count": 890
} | 183 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torch import nn
from fairseq.distributed import utils
class TPUDistributedDataParallel(nn.Module):
def __init__(self... | COCO-LM/fairseq/fairseq/distributed/tpu_distributed_data_parallel.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/distributed/tpu_distributed_data_parallel.py",
"repo_id": "COCO-LM",
"token_count": 598
} | 184 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from .fairseq_encoder import FairseqEncoder
class CompositeEncoder(FairseqEncoder):
"""
A wrapper around a dictionary of :class:`Fai... | COCO-LM/fairseq/fairseq/models/composite_encoder.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/models/composite_encoder.py",
"repo_id": "COCO-LM",
"token_count": 827
} | 185 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import List, Optional
import torch
from torch import Tensor
@torch.jit.script
def script_skip_tensor_list(x: List[Tensor], mask... | COCO-LM/fairseq/fairseq/models/model_utils.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/models/model_utils.py",
"repo_id": "COCO-LM",
"token_count": 1108
} | 186 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
CamemBERT: a Tasty French Language Model
"""
from fairseq.models import register_model
from .hub_interface import RobertaHubInterface
fro... | COCO-LM/fairseq/fairseq/models/roberta/model_camembert.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/models/roberta/model_camembert.py",
"repo_id": "COCO-LM",
"token_count": 880
} | 187 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Dict, Optional
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import utils
from torch imp... | COCO-LM/fairseq/fairseq/modules/learned_positional_embedding.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/modules/learned_positional_embedding.py",
"repo_id": "COCO-LM",
"token_count": 967
} | 188 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
import torch
class ScalarBias(torch.autograd.Function):
"""
Adds a vector of scalars, used in self-attention mechanism to allow
... | COCO-LM/fairseq/fairseq/modules/scalar_bias.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/modules/scalar_bias.py",
"repo_id": "COCO-LM",
"token_count": 333
} | 189 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch.optim
from . import LegacyFairseqOptimizer, register_optimizer
@register_optimizer("adagrad")
class Adagrad(LegacyFairseqOptim... | COCO-LM/fairseq/fairseq/optim/adagrad.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/optim/adagrad.py",
"repo_id": "COCO-LM",
"token_count": 503
} | 190 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from . import LegacyFairseqLRScheduler, register_lr_scheduler
import logging
import ast
logger = logging.getLogger(__name__)
logger.setLevel(... | COCO-LM/fairseq/fairseq/optim/lr_scheduler/manual_lr_scheduler.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/optim/lr_scheduler/manual_lr_scheduler.py",
"repo_id": "COCO-LM",
"token_count": 1882
} | 191 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import unicodedata
from fairseq.dataclass import ChoiceEnum
class EvaluationTokenizer(object):
"""A generic evaluation-time tokenizer, ... | COCO-LM/fairseq/fairseq/scoring/tokenizer.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/scoring/tokenizer.py",
"repo_id": "COCO-LM",
"token_count": 914
} | 192 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
from collections import OrderedDict
from fairseq import utils
from fairseq.data import (
BacktranslationDataset,... | COCO-LM/fairseq/fairseq/tasks/semisupervised_translation.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/tasks/semisupervised_translation.py",
"repo_id": "COCO-LM",
"token_count": 11142
} | 193 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.