Skip to content

Commit

Permalink
[TypeSpec CI] Ensure TypeSpec sources are formatted according to "tsp…
Browse files Browse the repository at this point in the history
… format" (#24041)
  • Loading branch information
mikeharder authored Jun 14, 2023
1 parent e2b5f93 commit 8783ae5
Show file tree
Hide file tree
Showing 28 changed files with 713 additions and 640 deletions.
7 changes: 3 additions & 4 deletions eng/pipelines/templates/steps/typespec-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ steps:
fi
# Pass "--no" to ensure npx does not install anything (TypeSpec compiler should already be installed)
if test -f main.tsp; then
npx --no tsp compile . --warn-as-error || exit_code=1
fi
if test -f client.tsp; then
npx --no tsp compile client.tsp --no-emit --warn-as-error || exit_code=1
fi
# Format parent folder to include shared files (disabled until formatting diffs are fixed)
# npx tsp format ../**/*.tsp
# Format parent folder to include shared files
npx tsp format ../**/*.tsp
popd
Expand Down
2 changes: 1 addition & 1 deletion specification/cognitiveservices/AnomalyDetector/client.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import "./main.tsp";

using Azure.ClientGenerator.Core;

@@convenientAPI(AnomalyDetector.Univariate.detectUnivariateEntireSeries, false)
@@convenientAPI(AnomalyDetector.Univariate.detectUnivariateEntireSeries, false);
9 changes: 6 additions & 3 deletions specification/cognitiveservices/AnomalyDetector/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ using TypeSpec.Http;
using TypeSpec.Versioning;

@versioned(APIVersion)
@service({title: "Anomaly Detector"})
@service({
title: "Anomaly Detector",
})
@useAuth(AnomalyDetectorApiKeyAuth)
@server(
"{Endpoint}/anomalydetector/{ApiVersion}",
Expand All @@ -20,7 +22,7 @@ Supported Azure Cognitive Services endpoints (protocol and host name, such as
https://westus2.api.cognitive.microsoft.com).
""")
Endpoint: string,

@doc("Api Version")
@path
ApiVersion: APIVersion,
Expand All @@ -47,7 +49,8 @@ discover incidents and establish a logic flow for root cause analysis.
namespace AnomalyDetector;

@doc("The secret key for your Azure Cognitive Services subscription.")
model AnomalyDetectorApiKeyAuth is ApiKeyAuth<ApiKeyLocation.header, "Ocp-Apim-Subscription-Key">;
model AnomalyDetectorApiKeyAuth
is ApiKeyAuth<ApiKeyLocation.header, "Ocp-Apim-Subscription-Key">;

#suppress "@azure-tools/typespec-azure-core/documentation-required" "https://github.com/Azure/typespec-azure/issues/3107"
enum APIVersion {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ namespace AnomalyDetector.Multivariate;
#suppress "@azure-tools/typespec-azure-core/documentation-required" "MUST fix in next update"
@doc("Field that indicates how missing values will be filled.")
enum FillNAMethod {
"Previous",
"Subsequent",
"Linear",
"Zero",
"Fixed",
Previous,
Subsequent,
Linear,
Zero,
Fixed,
}

#suppress "@azure-tools/typespec-azure-core/documentation-required" "MUST fix in next update"
Expand All @@ -29,25 +29,29 @@ enum MultivariateBatchDetectionStatus {
@doc("Data schema of the input data source. The default is OneTable.")
enum DataSchema {
@doc("OneTable means that your input data is in one CSV file, which contains one time stamp column and several variable columns. The default DataSchema value is OneTable.")
"OneTable",
OneTable,

@doc("MultiTable means that your input data is separated in multiple CSV files. Each file contains one time stamp column and one variable column, and the CSV file name should indicate the name of the variable. The default DataSchema value is OneTable.")
"MultiTable",
MultiTable,
}

#suppress "@azure-tools/typespec-azure-core/documentation-required" "MUST fix in next update"
enum AlignMode {
"Inner",
"Outer",
Inner,
Outer,
}

#suppress "@azure-tools/typespec-azure-core/documentation-required" "MUST fix in next update"
enum ModelStatus {
@doc("The model has been created. Training has been scheduled but not yet started.")
Created: "CREATED",

@doc("The model is being trained.")
Running: "RUNNING",

@doc("The model has been trained and is ready to be used for anomaly detection.")
Ready: "READY",

@doc("The model training failed.")
Failed: "FAILED",
}
Expand Down Expand Up @@ -75,6 +79,7 @@ model MultivariateBatchDetectionResultSummary {

@doc("Error message when detection fails.")
errors?: ErrorResponse[];

@doc("Variable status.")
variableStates?: VariableState[];

Expand All @@ -88,7 +93,6 @@ will need another API to get detection results.
@doc("Error information that the API returned.")
@error
model ErrorResponse {

@doc("Error code.")
code: string;

Expand Down Expand Up @@ -154,6 +158,7 @@ be in ISO 8601 format.
model AnomalyState {
@doc("Time stamp for this anomaly.")
timestamp: utcDateTime;

@doc("Detailed value of this anomalous time stamp.")
value?: AnomalyValue;

Expand All @@ -180,6 +185,7 @@ Raw anomaly score of severity, to help indicate the degree of abnormality.
@minValue(0.0)
@maxValue(2.0)
score: float32;

@doc("Interpretation of this anomalous time stamp.")
interpretation?: AnomalyInterpretation[];
}
Expand All @@ -194,6 +200,7 @@ This score shows the percentage that contributes to the anomalous time stamp. It
number between 0 and 1.
""")
contributionScore?: float32;

@doc("Correlation changes among the anomalous variables.")
correlationChanges?: CorrelationChanges;
}
Expand Down Expand Up @@ -285,6 +292,7 @@ Field that indicates how missing values will be filled.
model DiagnosticsInfo {
@doc("Model status.")
modelState?: ModelState;

@doc("Variable status.")
variableStates?: VariableState[];
}
Expand Down Expand Up @@ -381,11 +389,11 @@ model VariableValues {
values: float32[];
}


@doc("Results of the last detection.")
model MultivariateLastDetectionResult {
@doc("Variable status.")
variableStates?: VariableState[];

@doc("Anomaly status and information.")
results?: AnomalyState[];
}
Expand All @@ -395,6 +403,6 @@ model MultivariateLastDetectionResult {
model ResponseError {
@header("x-ms-error-code")
@doc("Error code.")
msErrorCode?: string,
...ErrorResponse
msErrorCode?: string;
...ErrorResponse;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ resultId value that the BatchDetectAnomaly API returns.
op getMultivariateBatchDetectionResult(
@format("uuid")
@doc("ID of a batch detection result.")
@path resultId: string,
@path
resultId: string
): MultivariateDetectionResult | ResponseError;

#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Azure core RpcOperation does not support custom error response"
Expand All @@ -57,15 +58,19 @@ op trainMultivariateModel is MultivariateServiceAction<
// TParams
{
@doc("Model information.")
@body modelInfo: ModelInfo,
@body
modelInfo: ModelInfo;
},
// TResponse
{
@statusCode statusCode: 201,
@statusCode statusCode: 201;

@doc("Location and ID of the model.")
@header location: string,
@body result: AnomalyDetectionModel
}>;
@header
location: string;
@body result: AnomalyDetectionModel;
}
>;

#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Does not fit any standard operation pattern"
// This operation does not fit any standard operation pattern.
Expand All @@ -79,10 +84,9 @@ op trainMultivariateModel is MultivariateServiceAction<
@doc("List models of a resource.")
op listMultivariateModels(
...SkipQueryParameter,
...TopQueryParameter,
...TopQueryParameter
): ModelList | ResponseError;


#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Does not fit any standard operation pattern"
// This operation does not fit any standard operation pattern.
// The closest match is probably ResourceDelete, but that can't be used because
Expand All @@ -94,13 +98,12 @@ op listMultivariateModels(
op deleteMultivariateModel(
@doc("Model identifier.")
@path
modelId: string,
modelId: string
): {
@doc("Delete model successfully.")
@statusCode
statusCode: 204
} | ResponseError;

statusCode: 204;
} | ResponseError;

#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Does not fit any standard operation pattern"
// This operation does not fit any standard operation pattern.
Expand All @@ -116,7 +119,7 @@ and variables used in the model.
op getMultivariateModel(
@doc("Model identifier.")
@path
modelId: string,
modelId: string
): AnomalyDetectionModel | ResponseError;

#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Does not fit any standard operation pattern"
Expand All @@ -138,18 +141,23 @@ op detectMultivariateBatchAnomaly(
@doc("Model identifier.")
@path
modelId: string,

@doc("Request of multivariate anomaly detection.")
@body options: MultivariateBatchDetectionOptions,
@body
options: MultivariateBatchDetectionOptions
): {
@statusCode statusCode: 202,
@statusCode statusCode: 202;

@doc("ID of the detection result.")
@header("Operation-Id") operationId: string,
@header("Operation-Id")
operationId: string;

@doc("Location of the detection result.")
@header("Operation-Location") operationLocation: string,
@body result: MultivariateDetectionResult,
@header("Operation-Location")
operationLocation: string;
@body result: MultivariateDetectionResult;
} | ResponseError;


#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Does not fit any standard operation pattern"
// This operation does not fit any standard operation pattern.
// The closest match is probably ResourceAction, but that can't be used because
Expand All @@ -166,6 +174,8 @@ op detectMultivariateLastAnomaly(
@doc("Model identifier.")
@path
modelId: string,

@doc("Request of the last detection.")
@body options: MultivariateLastDetectionOptions,
@body
options: MultivariateLastDetectionOptions
): MultivariateLastDetectionResult | ResponseError;
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ enum ImputeMode {

#suppress "@azure-tools/typespec-azure-core/documentation-required" "MUST fix in next update"
enum AnomalyDetectorErrorCodes {
"InvalidCustomInterval",
"BadArgument",
"InvalidGranularity",
"InvalidPeriod",
"InvalidModelArgument",
"InvalidSeries",
"InvalidJsonFormat",
"RequiredGranularity",
"RequiredSeries",
"InvalidImputeMode",
"InvalidImputeFixedValue",
InvalidCustomInterval,
BadArgument,
InvalidGranularity,
InvalidPeriod,
InvalidModelArgument,
InvalidSeries,
InvalidJsonFormat,
RequiredGranularity,
RequiredSeries,
InvalidImputeMode,
InvalidImputeFixedValue,
}

#suppress "@azure-tools/typespec-azure-core/documentation-required" "MUST fix in next update"
Expand Down Expand Up @@ -176,7 +176,7 @@ severe the anomaly is. For normal points, the severity is always 0.
model AnomalyDetectorError {
@header("x-ms-error-code")
@doc("Error code.")
msErrorCode: string,
msErrorCode: string;

@doc("Error code.")
code: AnomalyDetectorErrorCodes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ op detectUnivariateEntireSeries is UnivariateServiceAction<
// TParams
{
@doc("Method of univariate anomaly detection.")
@body options: UnivariateDetectionOptions,
@body
options: UnivariateDetectionOptions;
},
// TResponse
UnivariateEntireDetectionResult>;
UnivariateEntireDetectionResult
>;

#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Azure core RpcOperation does not support custom error response"
// https://github.com/Azure/typespec-azure/issues/2795
Expand All @@ -46,10 +48,12 @@ op detectUnivariateLastPoint is UnivariateServiceAction<
// TParams
{
@doc("Method of univariate anomaly detection.")
@body options: UnivariateDetectionOptions,
@body
options: UnivariateDetectionOptions;
},
// TResponse
UnivariateLastDetectionResult>;
UnivariateLastDetectionResult
>;

#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Azure core RpcOperation does not support custom error response"
// https://github.com/Azure/typespec-azure/issues/2795
Expand All @@ -60,7 +64,9 @@ op detectUnivariateChangePoint is UnivariateServiceAction<
// TParams
{
@doc("Method of univariate anomaly detection.")
@body options: UnivariateChangePointDetectionOptions,
@body
options: UnivariateChangePointDetectionOptions;
},
// TResponse
UnivariateChangePointDetectionResult>;
UnivariateChangePointDetectionResult
>;
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ import "../healthinsights.openapi/service.tsp";
using Azure.ClientGenerator.Core;

@TypeSpec.Versioning.useDependency(Azure.Core.Versions.v1_0_Preview_1)
@TypeSpec.Versioning.useDependency(AzureHealthInsights.ApiVersion.v2023_03_01_preview)
@TypeSpec.Versioning.useDependency(
AzureHealthInsights.ApiVersion.v2023_03_01_preview
)
namespace ClientForAzureHealthInsights;

@client({
name: "CancerProfilingClient",
service: AzureHealthInsights
name: "CancerProfilingClient",
service: AzureHealthInsights,
})
interface CancerProfilingClient {
interface CancerProfilingClient {
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "https://github.com/microsoft/typespec/issues/2037"
inferCancerProfile is AzureHealthInsights.OncoPhenotype.createJob;
}
Loading

0 comments on commit 8783ae5

Please sign in to comment.