Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync the whole resource provider directory in azure-sdk-for-net #5807

Closed
wants to merge 1 commit into from

Conversation

chunyu3
Copy link
Member

@chunyu3 chunyu3 commented Mar 24, 2023

Fix #5808

  • sync the whole resource directory in azure-rest-api-specs, so that all the dependency directories are synced together.

@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@@ -93,7 +97,15 @@ $configuration = Get-Content -Path $typespecConfigurationFile -Raw | ConvertFrom
$pieces = $typespecConfigurationFile.Path.Replace("\","/").Split("/")
$projectName = $pieces[$pieces.Count - 2]

$specSubDirectory = $configuration["directory"]
# clone the whole RP directory which is the parent of $configuration["directory"]
if ($configuration["directory"] -match "^[^/\\]+[\\/]+[^/\\]+")
Copy link
Member

Choose a reason for hiding this comment

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

What kind of pattern is this supposed to match?

Copy link
Member

Choose a reason for hiding this comment

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

Should we just walk up the parents until we hit the "specification" folder?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. It will get the top-level directory under specification.

Copy link
Member

Choose a reason for hiding this comment

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

This regex doesn't say to me that it is looking for specification folder. What do we expect the values of $configuraion["directory"] to be? Are they relative paths from the specification folder? or from the root of the repo? If they are from the root I would expect this regex to have the work "specification" in it somewhere.

Write-Host "Copying spec from $source to $dest"
# $mainSpecDir is the PR folder, we just need to copy its subfolders which include the typespec project folder
Get-ChildItem –Path "$source" -Exclude @("data-plane", "resource-manager")|
Copy link
Member

Choose a reason for hiding this comment

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

I think we can also sync these folders there isn't any real value in excluding them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hello @weshaggard data-plane and resource-manager is useless for generating SDK from typespec, and it is huge, so we skip to copy them to our template folder.

Copy link
Member

Choose a reason for hiding this comment

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

I know they have specs but are they really that big? Do we have any real data that says they make it take too much time? It just feels like if we can eliminate this special case it might make things easier.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we decide to exclude them after all, I think adding a comment explaining why is that would be worthwhile. Would be nice if it would say how big is the slowdown.

Get-ChildItem –Path "$source" -Exclude @("data-plane", "resource-manager")|
Foreach-Object {
Copy-Item -Path $_.FullName -Destination $dest -Recurse -Force
}

foreach ($additionalDir in $specAdditionalSubDirectories) {
Copy link
Member

Choose a reason for hiding this comment

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

Now that we are copying the entire rp folder do we even need additional directories any longer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. We will copying entire rp folder. The dependency usually be defined via import *** in a .tsp file, now we have no way to identify what directories are needed for this typespec project, so the possible solution (maybe workaround now) is to sync down the entire rp folder.

Copy link
Member

@m-nash m-nash left a comment

Choose a reason for hiding this comment

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

I definitely don't want to download huge directories to cover an issue in how to tell the CI the additionalDirectories

@weshaggard
Copy link
Member

I definitely don't want to download huge directories to cover an issue in how to tell the CI the additionalDirectories

@m-nash Can you give me more data on how long it takes to get the entire spec folder vs just the one TypeSpec folder? The sparse-checkout scoping to the one spec folder seems like it should be pretty quick. Do you have an example of what you are worried about?

One of the issues we are trying to fix here is that new services that have shared libraries don't have a place to provide those additionalDirectories purely in the Spec PR (for example Azure/azure-rest-api-specs#23168). We want to enable those new specs to be able to generate without needing to commit changes into the sdk repo to make that happen.

@weshaggard
Copy link
Member

@m-nash and I chatted more about this and agreed that we don't think we need to support syncing the whole directory and using AdditionalDirectories should still work fine. However in order for that to work for new projects like my sample we need a couple of changes to how things are working today. First we need a way to specify those AdditionalDirectories in the tspconfig.yaml file in the specs repo similar to other package settings. Then we need to have the sdk automation in the specs repo start to generate a tsp-location.yaml file with this and the other sha information in it and pass that file to the language repository scripts that do the generation. We also need to add support for passing in the path to the already cloned specs repo to those language generation scripts as we shouldn't need to pull those files again since we already have the specs repo cloned.

@raych1 can you please help work on this approach?

@chunyu3
Copy link
Member Author

chunyu3 commented Apr 3, 2023

We also need to add support for passing in the path to the already cloned specs repo to those language generation scripts as we shouldn't need to pull those files again since we already have the specs repo cloned.

Hello @weshaggard will the AdditionalDirectories specified in tspconfig.yaml consumed by emitter as other package settings (when call tsp compiler), or it is just retrieved out to create tsp-location.yaml before generate sdk? I think, it is the second one. SDK automation pipeline(Unified pipeline) will has the response to create/update the tsp-location.yaml for all sdk language.

We also need to add support for passing in the path to the already cloned specs repo to those language generation scripts as we shouldn't need to pull those files again since we already have the specs repo cloned.
@weshaggard What's the real scenario for this? When use the local specs, can we just directly update the tspconfig.yaml to include the AdditionalDirectories?

Thanks

@m-nash
Copy link
Member

m-nash commented Apr 3, 2023

We also need to add support for passing in the path to the already cloned specs repo to those language generation scripts as we shouldn't need to pull those files again since we already have the specs repo cloned.

Hello @weshaggard will the AdditionalDirectories specified in tspconfig.yaml consumed by emitter as other package settings (when call tsp compiler), or it is just retrieved out to create tsp-location.yaml before generate sdk? I think, it is the second one. SDK automation pipeline(Unified pipeline) will has the response to create/update the tsp-location.yaml for all sdk language.

We also need to add support for passing in the path to the already cloned specs repo to those language generation scripts as we shouldn't need to pull those files again since we already have the specs repo cloned.
@weshaggard What's the real scenario for this? When use the local specs, can we just directly update the tspconfig.yaml to include the AdditionalDirectories?

Thanks

The second one. This will only be consume in the case where we are generating from the spec repo and the project does not exist at all. Otherwise we wouldn't be creating a tsp-location but there could be an edge case where the additional directories change between spec PRs.

@weshaggard
Copy link
Member

Yes I agree this would only be done from the specs repo (or in cases where we are starting from the spec repo). In the case of the spec change we would always need to create/update the tsp-location.yaml file with any new changes to AdditionalDirectories as well as update to the new sha which the spec is currently based on.

@raych1
Copy link
Member

raych1 commented Apr 6, 2023

It sounds good to me. I created above linked issue for tracking. I talked to other SDK owners and they would turn to use common scripts for sdk generation once they're ready.

@Marina1933
Copy link

Nice 👍

Copy link

@Marina1933 Marina1933 left a comment

Choose a reason for hiding this comment

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

excellent

@m-nash
Copy link
Member

m-nash commented May 23, 2023

Can we close this PR since additionalDirectories will now be handled outside of this script? Or can we update the description to reflect the new approach if there is one?

@weshaggard
Copy link
Member

@m-nash I think so. I'm going to close but @chunyu3 or @raych1 feel like we need any of this still we should talk about that and create a new PR.

@weshaggard weshaggard closed this May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Defect] Failed to generate .NET sdk for contosowidgetmanager
8 participants