Finite morphism is affine local on target According to Vakil, a scheme morphism $\pi: X \to Y$ is finite if for every affine open subset $\operatorname{Spec} B$ of $Y$, $\pi^{-1}(\operatorname{Spec} B) = \operatorname{Spec} A$ with $A$ a finite $B$-algebra. Then the reader is asked to prove that if $Y$ admits an open cover $\{\operatorname{Spec} B_i\}$ such that $\pi^{-1}(\operatorname{Spec} B_i)$ is the spectrum of a finite $B_i$-algebra, then $\pi$ is finite (c.f. Exercise 7.3.G).
My guess is to apply the Affine Communication Lemma 5.3.2 (similar to Exercise 7.3.C), so I have to show that
(i) If $\operatorname{Spec} B \subseteq Y$ such that $\pi^{-1}(\operatorname{Spec} B)$ is the spectrum of a finite $B$-algebra, then $\pi^{-1}(\operatorname{Spec} B[g^{-1}])$ is the spectrum of a finite $B[g^{-1}]$-algebra.
(ii) If $\operatorname{Spec} B \subseteq Y$ and $(g_1, \cdots, g_n) = B$ such that $\pi^{-1}(\operatorname{Spec} B[g_i^{-1}])$ is the  spectrum of a finite $B[g_i^{-1}]$-algebra, then $\pi^{-1}(\operatorname{Spec} B)$ is the spectrum of a finite $B$-algebra.
Well, (i) is easy, but I don’t see a way to prove (ii). Since $\operatorname{Spec} B$ is covered by the distinguished open subset $D_B(g_i)$, it follows that the restriction of $\pi$ to a morphism $\pi^{-1}(\operatorname{Spec} B) \to \operatorname{Spec} B$ is affine (by Proposition 7.3.4), so $\pi^{-1}(\operatorname{Spec} B)$ is the spectrum of a ring $A$. Since $\operatorname{Spec} A \to \operatorname{Spec} B$ corresponds to a ring morphism $B \to A$, this gives $A$ the structure of a $B$-algebra. But how can I show that it is a finitely generated $B$-module? I know I didn’t used all the hypothesis, But I honestly don’t see a way to put them together to get the desired conclusion.
Any help is appreciated.
 A: For (ii) we need to show for $\pi^{-1}(\operatorname{Spec} B)=\operatorname{Spec} A$, $A[g_i^{-1}]$ is a finite $B[g_i^{-1}]$-algebra for all $i$, implies that , $A$ is a finite $B$-algebra.
Let $A[g_i^{-1}]$ is generated by $\{f_{i1},\dots, f_{in}\}$ as $B[g_i^{-1}]$-module where $f_{ij}\in A$.
Consider $$\phi: B^{\oplus N}\to A$$ sending $$e_{ij}\mapsto f_{ij}.$$
Consider the cokernel $C$ of the map $\phi$. Now the $B$-module $C$ has the property that $C[g_i^{-1}]$ =0. Since $g_i$'s generate the unit ideal, we can conclude $C=0$.
Added: To see $C=0$, let $c\in C$. Then for each $i$, since $c\in C[g_i^{-1}]=0$, we get $g_i^mc=0$ for some $m$. Now $g_i$'s generate unit ideal, implies $g_i^m$'s generate the unit ideal. So 1 is a $B$-linear combination of  $g_i^m$'s. So $c=1\cdot c=\sum g_i^mh_ic=0$.
To put (i) and (ii) together: Using the 'Affine communication lemma', $\operatorname{Spec} B\subset Y$ satisfies the property $P$ if $\pi^{-1}(\operatorname{Spec} B)$ is the spectrum of a finite $B$-algebra.
So you are done.
