Skip to content

chore(dtdl-parser): cleaning up and fixing bugs#20300

Merged
YoDaMa merged 4 commits intoAzure:mainfrom
YoDaMa:dtdl-parser/fix-readme
Feb 22, 2022
Merged

chore(dtdl-parser): cleaning up and fixing bugs#20300
YoDaMa merged 4 commits intoAzure:mainfrom
YoDaMa:dtdl-parser/fix-readme

Conversation

@YoDaMa
Copy link
Copy Markdown
Contributor

@YoDaMa YoDaMa commented Feb 9, 2022

Some incremental changes:

  • Fix integration with iot-modelsrepository parser
  • Update readme

@azure-sdk
Copy link
Copy Markdown
Collaborator

API changes have been detected in @azure/dtdl-parser. You can review API changes here

API changes

- export declare type DtmiResolver = (identifiers: string[]) => Promise<string[] | null>;
+ export declare type DtmiResolver = (dtmis: string, options?: GetModelsOptions) => Promise<{
+     [dtmi: string]: unknown;
+ } | null>;

@check-enforcer
Copy link
Copy Markdown

check-enforcer Bot commented Feb 9, 2022

This pull request is protected by Check Enforcer.

What is Check Enforcer?

Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass.

Why am I getting this message?

You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged.

What should I do now?

If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows:
/check-enforcer evaluate
Typically evaulation only takes a few seconds. If you know that your pull request is not covered by a pipeline and this is expected you can override Check Enforcer using the following command:
/check-enforcer override
Note that using the override command triggers alerts so that follow-up investigations can occur (PRs still need to be approved as normal).

What if I am onboarding a new service?

Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment:
/azp run prepare-pipelines
This will run a pipeline that analyzes the source tree and creates the pipelines necessary to build and validate your pull request. Once the pipeline has been created you can trigger the pipeline using the following comment:
/azp run js - [service] - ci

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a change that needs to be taken to the parser node repo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but we will integrate it into the monorepo to make the changes more permanent and easier to manage.

Copy link
Copy Markdown
Member

@xirzec xirzec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple remarks

Comment thread sdk/digitaltwins/dtdl-parser/README.md Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top level await requires Node 14+, our min bar is presently Node 12

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove top level await

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@azure/iot-modelsrepository is added as a dev dependency, but this looks like a runtime dependency?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this is something definitely need to sort out before GA. For now I'll move to dependencies to get the package working.

Comment on lines 209 to 211
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mixing await and promise chaining is weird

Suggested change
const additionalJsonTexts = await this.dtmiResolver(undefinedIdentifiers).then((value: {[dtmi: string]: unknown}) => {
return Object.values(value).map((value) => JSON.stringify(value))
});
const value:{[dtmi: string]: unknown} = await this.dtmiResolver(undefinedIdentifiers);
const additionalJsonTexts = Object.values(value).map((value) => JSON.stringify(value));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a general preference between { [dtmi: string]: unknown } and Record<string, unknown>? In this particular case IMO the former syntax is a little harder to parse with the promise and union.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair. for now going to add this to the issue created to handle more feedback on the Parser before GA, to get this sorted out fully across the library.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented on the feedback issue, agreed we can sort this out more later since I don't think it would be considered breaking

@YoDaMa
Copy link
Copy Markdown
Contributor Author

YoDaMa commented Feb 17, 2022

There are unresolved q's / comments in this PR that are out of scope of the work here. They've been moved to the issue tracking Preview Feedback. Other than that I hope to merge this and release the update today.

@azure-sdk
Copy link
Copy Markdown
Collaborator

API changes have been detected in @azure/dtdl-parser. You can review API changes here

API changes

- export declare type DtmiResolver = (identifiers: string[]) => Promise<string[] | null>;
-     dtmiResolver?: DtmiResolver;
+     getModels?: ModelsRepositoryClient["getModels"];

@YoDaMa
Copy link
Copy Markdown
Contributor Author

YoDaMa commented Feb 17, 2022

@xirzec I'll need an approval from someone. @olivakar doesn't look to have the right permissions yet.

@YoDaMa
Copy link
Copy Markdown
Contributor Author

YoDaMa commented Feb 17, 2022

I'm noticing errors on the build pipeline for browser tests in digital-twins-core.

TOTAL: 70 FAILED, 58 SUCCESS
Returned error code: 1
"@azure/digital-twins-core" failed to build.



==[ SUCCESS: 2 projects ]======================================================

These projects completed successfully:
  @azure/arm-digitaltwins    0.04 seconds
  @azure/dtdl-parser         15.08 seconds

==[ FAILURE: 1 project ]=======================================================

--[ FAILURE: @azure/digital-twins-core ]--------------------[ 34.32 seconds ]--

Invoking: karma start --single-run 
Projects failed to build.


17 02 2022 22:05:41.141:INFO [preprocessor.env]: Publishing variables:  [
  'AZURE_DIGITALTWINS_URL',
  'AZURE_CLIENT_ID',
  'AZURE_CLIENT_SECRET',
  'AZURE_TENANT_ID',
  'TEST_MODE'
]

  ...2520 lines omitted...
        at async tryGetAccessToken (../../core/core-http/src/policies/bearerTokenAuthenticationPolicy.ts:85:26 <- dist-test/index.browser.js:32880:33)
        at async beginRefresh$2 (../../core/core-http/src/policies/bearerTokenAuthenticationPolicy.ts:96:11 <- dist-test/index.browser.js:32888:18)
        at async BearerTokenAuthenticationPolicy.sendRequest (../../core/core-http/src/policies/bearerTokenAuthenticationPolicy.ts:251:23 <- dist-test/index.browser.js:33009:32)
        at async ThrottlingRetryPolicy$1.sendRequest (../../core/core-http/src/policies/throttlingRetryPolicy.ts:69:16 <- dist-test/index.browser.js:33433:27)
        at async AzureDigitalTwinsAPI.sendOperationRequest (../../core/core-http/src/serviceClient.ts:522:23 <- dist-test/index.browser.js:35938:32)
        at async createModel (test/public/testRelationships.spec.ts:122:3 <- dist-test/index.browser.js:84750:10)
        at async setUpModels (test/public/testRelationships.spec.ts:127:3 <- dist-test/index.browser.js:84754:10)
        at async Context.<anonymous> (test/public/testRelationships.spec.ts:1289:5 <- dist-test/index.browser.js:85482:10)

TOTAL: 70 FAILED, 58 SUCCESS

I haven't made any changes to that folder I think. @xirzec am I reading the test failure correctly?

@xirzec
Copy link
Copy Markdown
Member

xirzec commented Feb 17, 2022

I haven't made any changes to that folder I think. @xirzec am I reading the test failure correctly?

Hm looks like it's caused by the recorder not handling requests to identity during playback:

AuthenticationError: invalid_request Status code: 400
    More details:
    AADSTS90002: Tenant '12345678-1234-1234-1234-123456789012' not found. Check to make sure you have the correct tenant ID and are signing into the correct cloud. Check with your subscription administrator, this may happen if there are no active subscriptions for the tenant.
    Trace ID: 442a862c-6c4a-415d-9956-ab246c359b00

My first solution to confusing failures like this is to re-merge main and try again.

@YoDaMa YoDaMa force-pushed the dtdl-parser/fix-readme branch from 3090881 to c4df98b Compare February 17, 2022 22:32
@YoDaMa
Copy link
Copy Markdown
Contributor Author

YoDaMa commented Feb 17, 2022

My first solution to confusing failures like this is to re-merge main and try again.

yep I've force pushed a freshly rebased branch with two commits now for the changes. Let's see if that sorts it out...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants