Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Migrate import disambiguation to Python MVVM #1243

Merged
merged 5 commits into from
May 18, 2017

Conversation

evaogbe
Copy link
Contributor

@evaogbe evaogbe commented May 4, 2017

Ports the disambiguation functionality from the PythonImport into the PythonTypeTable for MVVM. Should also fix disambiguation for test gen.

@geigerj
Copy link
Contributor

geigerj commented May 4, 2017

Can you add/modify a .baseline test case that captures the failure that originally prompted this?

@evaogbe
Copy link
Contributor Author

evaogbe commented May 4, 2017

I don't think it needs a baseline if the unit tests sufficiently cover it. I can't migrate the main imports to MVVM without migrating everything to MVVM.

@codecov-io
Copy link

codecov-io commented May 4, 2017

Codecov Report

Merging #1243 into master will increase coverage by 0.06%.
The diff coverage is 94%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master   #1243      +/-   ##
===========================================
+ Coverage     86.14%   86.2%   +0.06%     
- Complexity     3770    3801      +31     
===========================================
  Files           380     380              
  Lines         14967   15089     +122     
  Branches       1666    1690      +24     
===========================================
+ Hits          12893   13008     +115     
- Misses         1624    1629       +5     
- Partials        450     452       +2
Impacted Files Coverage Δ Complexity Δ
...om/google/api/codegen/util/py/PythonTypeTable.java 89.85% <94%> (+12.07%) 21 <15> (+10) ⬆️
.../java/com/google/api/codegen/discovery/Method.java 90.32% <0%> (-9.68%) 8% <0%> (+2%)
...ava/com/google/api/codegen/discovery/Document.java 90.38% <0%> (-9.62%) 11% <0%> (+3%)
.../google/api/codegen/util/DynamicLangTypeTable.java 75% <0%> (-6.25%) 12% <0%> (-1%)
.../java/com/google/api/codegen/discovery/Schema.java 89.39% <0%> (-3.2%) 8% <0%> (+4%)
.../transformer/go/GoGapicSurfaceTestTransformer.java 98.97% <0%> (-1.03%) 12% <0%> (+2%)
...codegen/transformer/csharp/CSharpSurfaceNamer.java 93.24% <0%> (+0.06%) 70% <0%> (ø) ⬇️
...gle/api/codegen/transformer/go/GoSurfaceNamer.java 92.23% <0%> (+0.15%) 54% <0%> (+2%) ⬆️
...oogle/api/codegen/util/csharp/CSharpTypeTable.java 90.38% <0%> (+0.18%) 16% <0%> (ø) ⬇️
...om/google/api/codegen/discovery/DiscoveryNode.java 90.69% <0%> (+3.19%) 20% <0%> (+3%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 79a2750...b88cf5c. Read the comment docs.

}

@Override
public String getAndSaveNicknameFor(TypeAlias alias) {
return dynamicTypeTable.getAndSaveNicknameFor(alias);
if (!alias.needsImport()) {

This comment was marked as spam.

This comment was marked as spam.

@geigerj
Copy link
Contributor

geigerj commented May 4, 2017

Re: baselines -- the baselines shouldn't care whether or not the main imports are migrated, but I think this is fine just being unit tested, as well.

Copy link
Contributor

@geigerj geigerj left a comment

Choose a reason for hiding this comment

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

Minor comments, otherwise looks good

public void testGetAndSaveNicknameFor_disambiguate_movePackage() {
PythonTypeTable typeTable = new PythonTypeTable("foo.bar");
typeTable.getAndSaveNicknameFor(TypeAlias.create("a.c.D", "c.D"));
Truth.assertThat(typeTable.getAndSaveNicknameFor(TypeAlias.create("b.c.E", "c.E")))

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

}

// If all packages are present in the alias, mangle.
return localName + "_";

This comment was marked as spam.

This comment was marked as spam.

String oldModuleName = usedShortNames.get(shortName);
if (moduleName.equals(oldModuleName)) {
// New alias for existing module import, no clash
moduleImports.put(moduleName, alias);

This comment was marked as spam.

This comment was marked as spam.

@lukesneeringer
Copy link
Contributor

@eoogbe Can we merge this so I can re-generate monitoring?

@lukesneeringer
Copy link
Contributor

Wait, I just remembered that @eoogbe is OOO also. Merging. :-)

@lukesneeringer lukesneeringer merged commit 0d3d4cb into googleapis:master May 18, 2017
garrettjonesgoogle added a commit that referenced this pull request May 27, 2017
* Fix JSON pretty print in Ruby sample (#1254)

* Ruby: README Overhaul (feat. examples) (#1245)

* go: use new metadata methods (#1262)

Updates googleapis/google-cloud-go#624.

metadata.FromContext and metdata.NewContext
are replaced by metadata.{New,From}{Incoming,Outgoing}Context.

Generated unit tests now verify that x-goog-api-client header
is inserted.

Additionally, clients now save a string slice containing x-goog-api-client
header value instead of the value by itself.
This is a small optimization so that we don't create a new slice every time.

* Change media body from an object to a string (#1256)

Samples fail before sending a request if the media body is an object.

* Fix NONE auth Go sample (#1261)

* Change Node.js unit test require. (#1264)

* Ruby: Allow doc gapic generation to generate tests. (#1266)

* Ruby: Remove aliasing from method samples and tests (#1253)

* Ruby: Fix broken baselines from aliasing fix (#1269)

* Remove unused code (#1270)

* Python: README overhaul. (#1263)

* Ruby: Update gemspec and add useful metadata files (#1258)

* Ruby: Update gemspec and add useful metadata files

* Specify HTTP client when constructing client (#1275)

If a HTTP client is not passed to `build`, the Google API Python client
will create a default one and attempt to authenticate it. This causes
failures in environments where ADC auth is not available (Travis).

In any case, it's not useful to access any auth code in the mock tests.
This commit removes that possibility.

* Fix JSON print in Ruby (#1274)

It turns out that `to_h` is not a method available on every object
returned by the samples at the moment. Also, there's some kind of
decoding bug showing up in certain samples where the JSON module is
unable to unparse the response.

It's troublesome to have so much boilerplate just to pretty print. This
commit removes the pretty calls in favor of the vanilla `to_json` method
implemented by the base model class in the Ruby client. In the future,
once the bugs w.r.t `pretty_generate` have been resolved, we can revert.

* NodeJS: Update version index to support partial veneers (#1267)

* NodeJS: Updates to package.json (#1268)

* Migrate import disambiguation to Python MVVM (#1243)

* Fix Node package.json (#1282)

* go: use time.UnixNano instead of testutil.UIDSpace (#1279)

Since generated code should be testable from api-client-staging repo,
we want to reduce dependency on other cloud.google.com/go packages,
especially internal ones.

Clients will still depend on testutil for ProjID and TokenSource.
This is OK, since they can be easily reimplemented in google-client-staging
repo itself.

* Update Java grpc metadata for new staging structure (#1265)

* PHP: share credentials with operations client (#1283)

* java: move CredentialProvider up to ClientSettings (#1251)

This implements the client side changes to support
googleapis/gax-java#305.

* NodeJS: generate readme. (#1240)

* NodeJS: Small additions to the package.json (#1289)

* NodeJS: Use fileheader for copyright lines. (#1293)

* NodeJS: Use correct casing for partial veneers (#1295)

* NodeJS: Small readme fix from GCN reviews (#1294)

* go: make longrunning methods use generated longrunning client (#1288)

The cloud.google.com/go/longrunning package will need to change
slightly to accomodate this change.

xGoogHeader is now gone from the generated longrunnging types,
as the header will be automatically inserted by LROClient itself.

* NodeJS: Update partial veneer surface to add api documentation. (#1296)

* NodeJS: Metadata updates. (#1298)

* Readme: Update readme templates to add api summaries. (#1299)

* Add PHP Exception tests (#951)

* Add exception tests
* Remove unnecessary checks in exception tests

* Process markdown cloud links for PHP (#1091)

* Process markdown cloud links for PHP
* Restructure comment formatting

* go: return error creating LRO client instead of panicking (#1300)
andreamlin added a commit that referenced this pull request Jun 5, 2017
* merge master to Discogapic (#1304)

* Fix JSON pretty print in Ruby sample (#1254)

* Ruby: README Overhaul (feat. examples) (#1245)

* go: use new metadata methods (#1262)

Updates googleapis/google-cloud-go#624.

metadata.FromContext and metdata.NewContext
are replaced by metadata.{New,From}{Incoming,Outgoing}Context.

Generated unit tests now verify that x-goog-api-client header
is inserted.

Additionally, clients now save a string slice containing x-goog-api-client
header value instead of the value by itself.
This is a small optimization so that we don't create a new slice every time.

* Change media body from an object to a string (#1256)

Samples fail before sending a request if the media body is an object.

* Fix NONE auth Go sample (#1261)

* Change Node.js unit test require. (#1264)

* Ruby: Allow doc gapic generation to generate tests. (#1266)

* Ruby: Remove aliasing from method samples and tests (#1253)

* Ruby: Fix broken baselines from aliasing fix (#1269)

* Remove unused code (#1270)

* Python: README overhaul. (#1263)

* Ruby: Update gemspec and add useful metadata files (#1258)

* Ruby: Update gemspec and add useful metadata files

* Specify HTTP client when constructing client (#1275)

If a HTTP client is not passed to `build`, the Google API Python client
will create a default one and attempt to authenticate it. This causes
failures in environments where ADC auth is not available (Travis).

In any case, it's not useful to access any auth code in the mock tests.
This commit removes that possibility.

* Fix JSON print in Ruby (#1274)

It turns out that `to_h` is not a method available on every object
returned by the samples at the moment. Also, there's some kind of
decoding bug showing up in certain samples where the JSON module is
unable to unparse the response.

It's troublesome to have so much boilerplate just to pretty print. This
commit removes the pretty calls in favor of the vanilla `to_json` method
implemented by the base model class in the Ruby client. In the future,
once the bugs w.r.t `pretty_generate` have been resolved, we can revert.

* NodeJS: Update version index to support partial veneers (#1267)

* NodeJS: Updates to package.json (#1268)

* Migrate import disambiguation to Python MVVM (#1243)

* Fix Node package.json (#1282)

* go: use time.UnixNano instead of testutil.UIDSpace (#1279)

Since generated code should be testable from api-client-staging repo,
we want to reduce dependency on other cloud.google.com/go packages,
especially internal ones.

Clients will still depend on testutil for ProjID and TokenSource.
This is OK, since they can be easily reimplemented in google-client-staging
repo itself.

* Update Java grpc metadata for new staging structure (#1265)

* PHP: share credentials with operations client (#1283)

* java: move CredentialProvider up to ClientSettings (#1251)

This implements the client side changes to support
googleapis/gax-java#305.

* NodeJS: generate readme. (#1240)

* NodeJS: Small additions to the package.json (#1289)

* NodeJS: Use fileheader for copyright lines. (#1293)

* NodeJS: Use correct casing for partial veneers (#1295)

* NodeJS: Small readme fix from GCN reviews (#1294)

* go: make longrunning methods use generated longrunning client (#1288)

The cloud.google.com/go/longrunning package will need to change
slightly to accomodate this change.

xGoogHeader is now gone from the generated longrunnging types,
as the header will be automatically inserted by LROClient itself.

* NodeJS: Update partial veneer surface to add api documentation. (#1296)

* NodeJS: Metadata updates. (#1298)

* Readme: Update readme templates to add api summaries. (#1299)

* Add PHP Exception tests (#951)

* Add exception tests
* Remove unnecessary checks in exception tests

* Process markdown cloud links for PHP (#1091)

* Process markdown cloud links for PHP
* Restructure comment formatting

* go: return error creating LRO client instead of panicking (#1300)

* fails b/c Node.empty() uses null params

* one test passes

* all current tests pass

* tests for Node parent()

* Test

* removed Method.empty():

* reordering methods for convention

* made Node.from(Node, path) methods package private

* removed path() from Document, Schema, and Method

* removed static constructors with empty parent node
@evaogbe evaogbe deleted the python-mvvm-imports branch December 11, 2017 21:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants