Last night’s release of fastcore (0.1.14) and namely this commit introduced a new dependency on pytorch. Since fastdot depends on fastcore and imports all its dependencies, I cannot anymore use fastdot to write blogposts without having pytorch installed, which seems a bit excessive.
If you install fastdot by itself, though, the torch dependency will not be pulled, but will be requested at runtime.
In my specific case, since I am using JupyterHub, it means that I have either to modify the JupyterHub deployment and add a torch enabled version of the jupyter image (which is doable, but it gets really large) or have to install pytorch every time I restart my server, which takes a long time or I have to persist the installation, which means that the small volume claim that I use needs to get larger to store an unused dependency
EDIT: I am not entirely sure but I think that a possible solution might be wrapping the import statement into a try-except and then putting everything into the compare function. something like.
def equals(a,b):
"Compares `a` and `b` for equality; supports sublists, tensors and arrays too"
if one_is_instance(a,b,type): return a==b
if hasattr(a, '__array_eq__'): return a.__array_eq__(b)
if hasattr(b, '__array_eq__'): return b.__array_eq__(a)
cmp = (np.array_equal if one_is_instance(a, b, ndarray ) else
operator.eq if one_is_instance(a, b, (str,dict,set)) else
all_equal if is_iter(a) or is_iter(b) else
operator.eq)
try:
import torch
if one_is_instance(a, b, torch.Tensor): cmp = torch.equals
except: pass
return cmp(a,b)
I have no idea what the impact on performance would be though