Skip to content

Unity SDK Refactor #244

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

Merged
merged 79 commits into from
Aug 31, 2017
Merged

Unity SDK Refactor #244

merged 79 commits into from
Aug 31, 2017

Conversation

mediumTaj
Copy link
Contributor

@mediumTaj mediumTaj commented Jul 13, 2017

Summary

Refactor to use tokens as well as username and password. Missing functionality is being added and m_MemberVariable is being refactored to _memberVariable. High level functionality is also being stripped out in favor of a low level sdk with only service abstractions. Widget and other functionality will be added back via a higher level package to be created from a fork of an earlier commit. Credentials are now accepted in VCAP_SERVICES format. Unnecessary 3rd party plugins are removed and updated versions of the necessary 3rd party plugins are updated.

This will be a major release: v1.0.0 and will be the first release of the Watson Unity SDK in the Unity asset store.

mediumTaj added 30 commits June 27, 2017 13:49
@mediumTaj
Copy link
Contributor Author

@ereneld Do you have time to try this out sometime this week? I want to merge into develop and prep for release.

@ereneld
Copy link
Contributor

ereneld commented Aug 24, 2017

Sorry I missed the initial call but reviewing now. My findings may not be directly related with that refactoring but an overall check. Here are my findings;

  1. After downloading folder and added to my project. In the ReadMe there is statement Rename the SDK directory from unity-sdk to Watson. However, if I am not renaming it there is no error or warning indicating that I need to change to Watson. That would help developers to know what to do and should be provided there as well.

  2. After initial download I saw some error on console. It is not hurting but it is better to have something welcoming developers instead of showing some arbitrary error.

screen shot 2017-08-24 at 4 13 53 pm

  1. I went to examples and open the 'ServiceExamples' scene to see what is going on. My expectation was to see services working or something.
    Run the scene and got the error given below.

screen shot 2017-08-24 at 4 17 14 pm

I think it should give the meaningful error like 'It seems like you didn't configure the services. Please configure services by checking Read me : < read me link here >
  1. There is UnitTests under Watson>Scenes>UnitTest and It might be valuable for everyone but it has the same story with number 3. I hit the TestConversation and see the error below. When I stop running the scene the 3rd log line appeared.

screen shot 2017-08-24 at 4 43 53 pm

  1. This is Rare but it suggest to use namespaces. I created TestConversation.cs to test conversation as my first attempt and got the error since global namespace has that name.
    Assets/Watson/Scripts/UnitTests/TestConversation.cs(28,14): error CS0101: The namespace global:: already contains a definition for TestConversation
    This error suggests that it is better to encapsulate all test cases or example classes under a certain namespace (the other classes are already in good namespace). That might change some documentation as well.

  2. I started testing 'Speech to Text' service, but confused with Read Me file. It shows like 2 lines of code but doesn't show where to provide data and the callback from STT service. The read me points of to Example scene but it uses VCAP which is not mentioned in the ReadMe. Those parts should be checked one more time. It might be valuable to show users how to use microphone with STT service to stream or send WAV file (it exist on read me but can be improved) on that service's read me text.
    I think for each service the credential setting and basic usages should be reviewed one-by-one. I selected the hard-one I guess but it is the most common one.
    exp. _speechToText.StartListening(OnRecognize); was used in example but not visible in Read Me, and I didn't check the documentation since it has a custom viewer and not visible via browser.

  3. That would be nice if you have html version of the documentation, and a public URL for generated codes, so developers can see the link and click to see details like Unity documentation.

  4. On example scenes and scripts. It might be nice to have credential values are defined at top as private serialize field so that developers can edit on inspector or edit internally. It is hard to decide but it might be better to have a variable at top for credentials.

  5. Refactoring did the trick and it looks much more professional then before. Removing widget system and using services in couple line of codes will give the full power to developer.

Briefly, Refactoring looks nice but Developer Experience should be improved. Initial landing to Watson Unity SDK should be smoother. Thanks for the big refactoring work!

@mediumTaj
Copy link
Contributor Author

mediumTaj commented Aug 28, 2017

  1. This is an artifact of when we had filepaths dependent on this directory name. I made the instruction to change the name optional because while it isn't required for the SDK to work, unity-sdk is not very descriptive in a Unity project.

  2. Unity removed the meta file.

  3. I added instructions to the readme about how to add credentials to the call. I commented out the confusing vcap language. An error is thrown if the service isn't instantiated with a u/p, authentication token or apikey.

  4. I do have to leave the vcap code in the integration tests. This is the only testing we can do for Unity since a real testing framework is not available. Now we log that finding credentials through vcap failed and user should add their own credentials to the test.

  5. Good catch! Added namespace to conversation test.

  6. Yeah speech to text is a tough one. I added a section on how to access the microphone and send it to speech to text. I pointed to the ExampleStreaming scene in the readme and commented out the vcap code so we dont confuse the user. There is an example of how to send the wav file under Multipart Requests.

  7. This is something I will work on for a future update. We have the documentation in a chm file now that requires an external application to view. If we had html documentation in this branch it would list about 50% of the code as html. I will need to add functionality to push html documentation to gh-pages on each release and on Master and Develop branches like we do on the .NET SDK. Link to the issue I created.

  8. I think it is better to only provide low level functionality to the SDK. This kind of stuff will belong in the higher level package I am planning on creating.

  9. Thanks! I think this is the right way to go - just low level access to the Watson services. I will build a higher level package on top of this because at the very least the microphone widget was nice to have!

@ereneld
Copy link
Contributor

ereneld commented Aug 29, 2017

Ok I see your changes. Great!
1- It would be good idea to initialize the variables as null otherwise it gives all those warnings each time it compiles.
screen shot 2017-08-29 at 5 58 41 pm

2- I opened the exampled Scenes and entered my credentials and it worked. However after that it did something and stopped working. Is there a recording time to convert to text ?
screen shot 2017-08-29 at 6 00 34 pm

3- I see your VCAP commented-out section. It might be ok for now, but it is better to have something on your end as git-ignore files to use VCAP on your end and using your own credentials. Example.
You can make your example classes as https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/partial-classes-and-methods and add new files on your end (as git ignore) and you can make changes on credentials with VCAP on awake or whatever monobehaviour function, that might help.

4- Examples are looking good, it can be improved for the next iterations. At least there is no UI examples so it helps developers to focus on code instead of UI elements.

@mediumTaj
Copy link
Contributor Author

  1. you're right - I nulled out all variables in the examples. no warnings now.
  2. not really sure what is happening there - can you give me steps to reproduce?
  3. Nice! I didn't realize unity supported partial classes. I removed the vcap code on all examples.

Thanks Khan, can you check out one more time? This is very helpful to get another set of eyes on the sdk.

@ereneld
Copy link
Contributor

ereneld commented Aug 30, 2017

See the namespace changes. 👍
See the variable initialization 👍
Since my concern is mainly related with STT example and other examples, it is not directly related with this PR. After this PR, it might be a good idea to consider a example package.
LGTM

Copy link
Contributor

@ereneld ereneld left a comment

Choose a reason for hiding this comment

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

Good refactoring. 👍
Need improvements on dev experience. (Separate PR for examples and on-boarding)

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

Successfully merging this pull request may close these issues.

3 participants