Software Architect at Genzeon Corporation in Malvern, Pennsylvania, Microsoft .NET MVP, Husband, Dad and Geek.
26415 stories
·
21 followers

JupyterHub 0.9

2 Shares

We are pleased to announce the latest release of JupyterHub. JupyterHub is the multi-user server for Jupyter notebooks, allowing students or researchers to have their own workspace. This release has lots of improvements, especially for stability and performance with large numbers of users.

The biggest change is probably the adoption of asyncio coroutines throughout instead of tornado coroutines and improved support for asyncio coroutines in general, adopting async def coroutine syntax. This means that JupyterHub 0.9 requires Python ≥ 3.5 and tornado ≥ 5.0.

There are lots of improvements to the REST API, including more detailed time information and token management.

There are also several improvements to the ability to customize JupyterHub’s HTML templates.

See the changelog for a more detailed list of changes.

Make sure to backup your jupyterhub database prior to upgrade, and then upgrade with pip:

python3 -m pip install --upgrade 'jupyterhub==0.9.*'

or conda:

conda install -c conda-forge jupyterhub=0.9

For Kubernetes users, we will have an 0.7 release of the helm chart before too long.

Thanks to everyone who has contributed to JupyterHub!


JupyterHub 0.9 was originally published in Jupyter Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.

Read the whole story
alvinashcraft
3 minutes ago
reply
West Grove, PA
sbanwart
7 hours ago
reply
Akron, OH
Share this story
Delete

Binding a FlexLayout to a Collection II

1 Share

Previously, I explained how to extend the FlexLayout class with ItemsSource and ItemTemplate properties, so that it can bind to data stored in a collection. However, the resulting ExtendedFlexLayout class is only a minimally viable implementation as it omits a number of required features.

One of the missing features is that it doesn’t allow a DataTemplateSelector to choose a DataTemplate at runtime based on the value of a bound property. Instead it only permits a single defined DataTemplate to be used.

The purpose of this blog post is to further extend the ExtendedFlexLayout class so that it does allow a DataTemplateSelector to choose a DataTemplate at runtime. This enables scenarios such as the ExtendedFlexLayout binding to a collection of objects where the appearance of each object can be chosen at runtime by a data template selector returning a particular DataTemplate.

The sample this code comes from can be found on GitHub.

Adding DataTemplateSelector Support

As I explained previously, the ExtendedFlexLayout class has a CreateChildView method, which is called for each item in the collection that the ItemsSource property binds to, to load the DataTemplate referenced by the ItemTemplate property and set its binding context:

View CreateChildView(object item)
{
ItemTemplate.SetValue(BindableObject.BindingContextProperty, item);
return (View)ItemTemplate.CreateContent();
}

This method can be extended to support a DataTemplateSelector choosing a DataTemplate at runtime:

View CreateChildView(object item)
{
if (ItemTemplate is DataTemplateSelector)
{
var dts
= ItemTemplate as DataTemplateSelector;
var itemTemplate
= dts.SelectTemplate(item, null);
itemTemplate.SetValue(BindableObject.BindingContextProperty, item);
return (View)itemTemplate.CreateContent();
}
else
{
ItemTemplate.SetValue(BindableObject.BindingContextProperty, item);
return (View)ItemTemplate.CreateContent();
}
}

This additional code checks if the ItemTemplate property references a class that inherits from DataTemplateSelector. If it is, it calls the DataTemplateSelector.SelectTemplate method to return the particular DataTemplate. Then, as before, the DataTemplate is loaded and its binding context is set.

Consuming the ExtendedFlexLayout

A data template selector is implemented by creating a class that inherits from DataTemplateSelector. The OnSelectTemplate method is then overridden to return a particular DataTemplate, as shown in the following code example:

public class MonkeyDataTemplateSelector : DataTemplateSelector
{
public DataTemplate NormalMonkeyTemplate { get; set; }
public DataTemplate CynicalMonkeyTemplate { get; set; }

protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
{
return ((Monkey)item).Name.Contains("Face-Palm") ? CynicalMonkeyTemplate : NormalMonkeyTemplate;
}
}

Here, the OnSelectTemplate method returns the appropriate template based on the value of the Name property. The template to return is the template referenced by the NormalMonkeyTemplate property or the CynicalMonkeyTemplate, which are set when consuming the MonkeyDataTemplateSelector.

The MonkeyDataTemplateSelector is instantiated by declaring it as a resource:

<ContentPage.Resources>
<Style x:Key="normalMonkeyFrame" TargetType="Frame">
<Setter Property="BackgroundColor" Value="LightYellow" />
<Setter Property="BorderColor" Value="Blue" />
<Setter Property="Margin" Value="10" />
<Setter Property="CornerRadius" Value="15" />
</Style>

<Style x:Key="cynicalMonkeyFrame" TargetType="Frame">
<Setter Property="BackgroundColor" Value="Red" />
<Setter Property="BorderColor" Value="Black" />
<Setter Property="Margin" Value="10" />
<Setter Property="CornerRadius" Value="15" />
</Style>
...

<DataTemplate x:Key="normalMonkeyTemplate">
<Frame WidthRequest="300"
HeightRequest
="480"
Style
="{StaticResource normalMonkeyFrame}">
...
</Frame>
</DataTemplate>

<DataTemplate x:Key="cynicalMonkeyTemplate">
<Frame WidthRequest="300"
HeightRequest
="480"
Style
="{StaticResource cynicalMonkeyFrame}">
...
</Frame>
</DataTemplate>

<local:MonkeyDataTemplateSelector x:Key="monkeyDataTemplateSelector"
NormalMonkeyTemplate
="{StaticResource normalMonkeyTemplate}"
CynicalMonkeyTemplate
="{StaticResource cynicalMonkeyTemplate}" />
</ContentPage.Resources>

The ResourceDictionary above defines two DataTemplate instances, and a MonkeyDataTemplateSelector instance. The MonkeyDataTemplateSelector instance sets its NormalMonkeyTemplate and CynicalMonkeyTemplate properties to the appropriate DataTemplate instances through the StaticResource markup extension. The two DataTemplates are largely identical, aside from setting different colours on the Frame instances.

The MonkeyDataTemplateSelector instance is consumed by assigning it to the ExtendedFlexLayout.ItemTemplate property:

<local:ExtendedFlexLayout ItemsSource="{Binding Monkeys}"
ItemTemplate
="{StaticResource monkeyDataTemplateSelector}" />

At runtime, the MonkeyDataTemplateSelector.OnSelectTemplate method is called (by the ExtendedFlexLayout class via the DataTemplateSelector.SelectTemplate method call) for each of the items in the underlying collection, with the call passing the data object as the item parameter. The DataTemplate that is returned by the method is then applied to that object.

The following screenshots show the result of the ExtendedFlexLayout applying the MonkeyDataTemplateSelector to each object in the underlying collection:


Simulator Screen Shot - iPhone 8 - 2018-06-18 at 16.09.05Simulator Screen Shot - iPhone 8 - 2018-06-18 at 16.09.10Simulator Screen Shot - iPhone 8 - 2018-06-18 at 16.09.15

Any Monkey object that has a Name property that contains “Face-Palm” is displayed with a red background, as a warning to be wary of cynical monkeys, with the remaining objects being displayed with a a light yellow background.

Summary

This blog post has explained how to further extend the ExtendedFlexLayout class so that it allows a DataTemplateSelector to choose a DataTemplate at runtime. This enables scenarios such as the ExtendedFlexLayout binding to a collection of objects where the appearance of each object can be chosen at runtime by the data template selector returning a particular DataTemplate. My next blog post will look at further extending the ExtendedFlexLayout class with additional functionality.

The sample this code comes from can be found on GitHub.

Read the whole story
alvinashcraft
3 minutes ago
reply
West Grove, PA
Share this story
Delete

Using Github GraphQL Search API in Android App with Apollo

1 Share
Github GraphQL with Android Apollo

Introduction

GraphQL had gained popularity in recent years, it makes querying data from API becomes much more expressive, customisable, and flexible because of its strongly typed system, function to resolve that can be defined on each fields and types, and supports for nested types. It also makes querying data become much more efficient between client and server because the server can resolve the function by querying the data from multiple data source into one single request.

In this article, we will build an Android app that lists all the current trending repositories in GitHub by calling Github GraphQL API endpoint using Apollo Android GraphQL library.

What we will build:

  • Integrating Apollo Android dependencies into our project.
  • Import schema from Github GraphQL into our project.
  • GraphQL query file for searching repository that will be used by Apollo Android to build generated Java class.
  • Data Repository class as an interface to get the latest repository from Github using the generated Java class and Apollo Client.
  • ViewModel class that retrieves the data from the Data Repository class that is observed by the Activity/Fragment then display the result to UI.

Apollo Android Integration

To use Apollo Android in our project we need to add dependencies to our app and module build gradle file.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.apollographql.apollo:apollo-gradle-plugin:0.5.0'
}
}

dependencies {
compile 'com.apollographql.apollo:apollo-runtime:0.5.0'
}

Import GitHub GraphQL API Schema

We also need to import the GitHub GraphQL API schema into our app. To access the GitHub API we need to generate access token for our app from GitHub homepage, then we can use apollo-codegen npm package to download the schema passing our access token.

apollo-codegen introspect-schema https://api.github.com/graphql --output schema.json --header "Authorization: Bearer <token>

After the schema json file has been downloaded, we need to import it to our app project directory.

Schema.json in project directory

Creating GitHub GraphQL query file

We need to create a file with a .graphql extension inside the same directory as our schema.json file, in this case we named it github.graphql then we will put our GitHub GraphQL repositories query inside this file. Apollo Android will generate Java class for each query specified inside this file.

query GetLatestTrendingRepositoriesInLastWeek($first: Int, $query: String!, $type: SearchType!) {
search(first: $first, query: $query, type: $type) {
edges {
node {
... on Repository {
name
owner {
login
}
description
stargazers {
totalCount
}
primaryLanguage {
name
}
}
}
}
}
}

Try to rebuild the project and then take a peek inside the build generated directory, there will be a Java class named GetLatestTrendingRepositoriesInLastWeekQuery that is generated based on the schema and query file in our project.

Data Repository class as a layer to get data from GraphQL API

We create DataRepository class that will be used as a layer to get access to the GitHub GraphQL API using Apollo Client. We use okhttp library as the HTTP client and also add network interceptor that will set the HTTP header with the GitHub Access Token that we generate from GitHub.

we expose public method getLatestTrendingRepositories that returns list of repositories from Github GraphQL API. Inside this method we build the query using the generated class builder. We get last week date and format it to match the GitHub date query format, then we pass the query containing the created date is later than last week and for the results to be sorted my most stars in descending order. We also set the builder to get only 25 first result and the type of the search to be Repository type.

We won’t build our HTTP request by ourselves because Apollo Android has generate the java class for us to query repository with strongly typed parameter and return type without caring about the underlying HTTP request.

With the generated java class we can create a Builder for the query containing the parameters that can be passed to the Query such as limit for pagination. The parameter type are also strongly typed based on the schema.json Github API we have imported to our project directory.

Repository View Model

Our RepositoryViewModel class exposes reposResult LiveData that will be observed by the Activity/Fragment that will display the result in UI. The loadRepos call the DataRepository getLatestTrendingRepositories method that returns the repositories or error and update the LiveData that will trigger update with the results to all of the observers and then use the data to update UI using RecyclerView or ListView.

import GetLatestTrendingRepositoriesInLastWeekQuery
import com.alfianlosari.graphql_github.api.DataRepository

class TrendingRepositoriesViewModel: ViewModel() {

private val dataRepository = DataRepository()

var reposResult = MutableLiveData<Pair<List<GetLatestTrendingRepositoriesInLastWeekQuery.Edge>?, Error?>>()

init {
loadRepos()
}

fun loadRepos() {
dataRepository.getLatestTrendingRepositoriesInLastWeek {
val handler = Handler(Looper.getMainLooper())
handler.post {
reposResult.value = it
}
}
}

}

Note that the Github GraphQL API returns Edges and Nodes for the result, inside our query file we have specified the return to be casted as Repository type so Apollo can generate the class for us. To access the repository type we can easily cast the node into the AsRepository class then access the repository data from there.

class RepositoryViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) {

fun bindRepository(repo: GetLatestTrendingRepositoriesInLastWeekQuery.Node) {
if (repo is GetLatestTrendingRepositoriesInLastWeekQuery.AsRepository) {
itemView.name.text = repo.name()
itemView.owner.text = repo.owner().login()
itemView.description.text = repo.description()
itemView.star_count.text = "${repo.stargazers().totalCount()} ✭"
itemView.language.text = repo.primaryLanguage()?.name()
}
}
}

Conclusion

Using GraphQL API in an Android app become more easier and simpler with Apollo GraphQL. Apollo also supports customised response caching mechanism , custom scalar type adapter mapping. GitHub GraphQL API make querying data to GitHub much more flexible and customisable. I think GraphQL really improve the process of communication between client and server that can improve rapid development time for developers.

Read the whole story
alvinashcraft
4 minutes ago
reply
West Grove, PA
Share this story
Delete

Supporting iOS 11 and iPhone X in Xamarin.iOS Apps

1 Share

Apple has indicated that starting in July 2018 all new apps and app updates submitted to the App Store must be built with the iOS 11 SDK and support the iPhone X Super Retina display.

The following resources describe how to make sure Xamarin.iOS apps look and work great with iOS 11 and iPhone X:

Starting this July, be sure that all new apps and app updates that are submitted to the App Store include support for iOS 11 and iPhone X.

To discuss this post, head on over to the Xamarin Forums!

The post Supporting iOS 11 and iPhone X in Xamarin.iOS Apps appeared first on Xamarin Blog.

Read the whole story
alvinashcraft
4 minutes ago
reply
West Grove, PA
Share this story
Delete

Unity ML-Agents Toolkit v0.4 and Udacity Deep Reinforcement Learning Nanodegree

1 Share
We are happy to announce the release of the latest version of ML-Agents: v0.4. It contains a number of features, which we hope everyone will enjoy. It includes the option to train your environments directly from the editor, rather than as built executables, making iteration time much quicker. In addition, we are introducing a set […]
Read the whole story
alvinashcraft
4 minutes ago
reply
West Grove, PA
Share this story
Delete

The Evolution of the .NET Framework with Kathleen Dollard

1 Share
The .NET Framework continues to evolve! Carl and Richard talk to Kathleen Dollard about her work at Microsoft - helping to provide tooling and new features for maintaining existing applications and creating new ones. Kathleen is also responsible for Visual Basic .NET, and talks about how it's being maintained based on the needs of VB.NET developers - stability is a focus! The upcoming Core 3 offers some interesting opportunities for existing applications to get new features, and Kathleen talks about how the team will integrate the new features. The framework continues to evolve!



Download audio: https://traffic.libsyn.com/dotnetrocks/dotnetrocks_1555_framework_evolution.mp3
Read the whole story
alvinashcraft
4 minutes ago
reply
West Grove, PA
Share this story
Delete
Next Page of Stories