-
Notifications
You must be signed in to change notification settings - Fork 122
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
vine: serverless import issue #3567
vine: serverless import issue #3567
Conversation
Note that the |
what about?
Using the strings that then get interpreted as modules seems a little clunky to me. |
How about the new feature: # format it as a dictionary supporting comprehensive usage
imports = {
'math': '', # import math
'numpy': 'np', # import numpy as np
'random': {'uniform': ''}, # from random import uniform
'time': {'sleep': 'time_sleep'} # from time import sleep as time_sleep
}
# format it as a list or a string for simple usage
imports = ['os.path', 'sys', 'time'] # import os.path
# import sys
# import time
imports = 'tensorflow' # import tensorflow Also, we support optional usage of the |
Sounds good. I suggest to simplify it, and only accept the list form as: [ ("tensorflow", "tf"), "math" ] This is because entries such as For using |
Thanks! This format looks more beautiful and makes more sense. So whenever we want to use from concurrent.futures import Executor, Future as F
from configuration import training_config, generator_config, discriminator_config We should perform the argument as: ["concurrent.futures.Executor", ("concurrent.futures.Future", "F"), \
"configuration.training_config", "configuration.generator_config", \
"configuration.discriminator_config"] And the parsed statements would be: import concurrent.futures.Executor
import concurrent.futures.Future as F
import configuration.training_config
import configuration.generator_config
import configuration.discriminator_config I think we can definitely do that if it makes sense to you. If we want to keep the
imports = {
'torch': [], # import torch
'torch.nn': [('Conv2d', 'Conv'), 'MaxPool2d'], # from torch.nn import Conv2d as Conv, MaxPool2d
'torch.nn.functional': ['relu', ('sigmoid', 'sig')] # from torch.nn.functional import relu, sigmoid as sig
}
["import torch", \
"from torch.nn import Conv2d as Conv, MaxPool2d", \
"from torch.nn.functional import relu, sigmoid as sig"] How do you think @btovar |
@btovar How do you recommend? |
Definitely we do not want the original I suggest reducing the scope of what can be imported, e.g., this facility should be used only to import modules, and not specific objects of functions. With that, At the end, this is an optimization, so the function should work even when not running with the library. (That is, I'd expect the function to still have a statement like |
This is getting way too complicated. Just translate |
Sounds great! Then let's use this format: imports=["time", "os.path", ("tensorflow", "tf")] We will translate import time
import os.path
import tensorflow as tf |
New argument New format of argument import_modules = ["sys", "os.path", ("numpy", "np")] This will be translated to: import sys
import os.path
import numpy as np
The doc was updated accordingly. |
@JinZhou5042 please review the build failures on osx and conda. |
Sure, how do you think about the errors, I'm confused because it works just well in my environment. |
Ok, the OSX test, we can see that But Conda isn't used at all in this OSX build, and we don't want it packing a conda environment at all for the fast test. The problem is that I think you have a similar problem in the |
Thanks for the information! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor typo, but overall looks good!
RTM? |
RTM! |
Proposed changes
The previous practice to install a library in which a function uses
numpy
was like:It is unnecessary to import packages inside that function if we have
import
statements inserted into the preamble of the serverless library.To achieve this, the following function was modified by adding an additional argument
imports
:The input
imports
argument should be formatted as:so that it can handle various import statements.
The related test examples in
cctools/taskvine/test/vine_python_serverless.py
andcctools/taskvine/src/examples/vine_example_function_call.py
are modified accordingly.Post-change actions
Put an 'x' in the boxes that describe post-change actions that you have done.
The more 'x' ticked, the faster your changes are accepted by maintainers.
make test
Run local tests prior to pushing.make format
Format source code to comply with lint policies. Note that some lint errors can only be resolved manually (e.g., Python)make lint
Run lint on source code prior to pushing.Additional comments
This section is dedicated to changes that are ambitious or complex and require substantial discussions. Feel free to start the ball rolling.