Skip to content
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

Tests for interactive API #151

Merged
merged 23 commits into from
Aug 24, 2021
Merged

Tests for interactive API #151

merged 23 commits into from
Aug 24, 2021

Conversation

itrushkin
Copy link
Contributor

No description provided.

@itrushkin
Copy link
Contributor Author

Jenkins please retry a build

# Settings for resizing data
self.enforce_image_hw = None
if enforce_image_hw is not None:
self.enforce_image_hw = tuple(int(size) for size in enforce_image_hw.split(','))
Copy link
Contributor

Choose a reason for hiding this comment

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

self.enforve_image_hw is it should be tuple?
enforce_image_hw could we use two different variable with type int in order to avoid this transformation?

if enforce_image_hw is not None:
self.enforce_image_hw = tuple(int(size) for size in enforce_image_hw.split(','))
# Settings for sharding the dataset
self.rank_worldsize = tuple(int(num) for num in rank_worldsize.split(','))
Copy link
Contributor

Choose a reason for hiding this comment

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

self.rank_worldsize is it should be tuple?
rank_worldsize could we use two different variable with type int in order to avoid this transformation?

self.images_names = [
img_name
for img_name in sorted(os.listdir(self.images_path))
if len(img_name) > 3 and img_name[-3:] == 'jpg'
Copy link
Contributor

Choose a reason for hiding this comment

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

To check file extension could be used

os.path.splitext(img_name)[1] == ".jpg"

or

Path(img_name).suffix == '.mp3'

Comment on lines 4 to 5
rank_worldsize: 1,90
enforce_image_hw: '300,400'
Copy link
Contributor

Choose a reason for hiding this comment

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

could this values divided?
could its have the same type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This object reflects 'size' type that by design consists of fixed width and height. For example, the same approach is used for Resize* transforms in torchvision.transforms, where size variable is passed as a tuple or single integer, which means that h=w. In my opinion, these values should be stored together since they are always used together.

Copy link
Contributor

Choose a reason for hiding this comment

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

rank_worldsize and enforce_image_hw have diferent types list and string. It looks like it should be more consistent

self, num_workers=8, batch_size=self.kwargs['train_bs'], sampler=train_sampler
)

def get_valid_loader(self, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

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

kwargs unused


keeper = Envoy(
shard_name=shard_name,
director_uri=director_uri,
Copy link
Contributor

Choose a reason for hiding this comment

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

director_uri was replaced with director_host and director_port

# 1. target_shape - target shape interface unified across the Federation

settings:
sample_shape: ['784']
Copy link
Contributor

Choose a reason for hiding this comment

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

could '784' be number 784

Comment on lines +38 to +41
if index < len(self.X_train):
return self.X_train[index], self.y_train[index]
index -= len(self.X_train) + 1
return self.X_test[index], self.y_test[index]
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be greate if we have the same names for similar variables X_train or train_indices and index or indice


TI = TaskInterface()
# Task interface currently supports only standalone functions.
@TI.register_fl_task(model='model', data_loader='train_dataset', \
Copy link
Contributor

Choose a reason for hiding this comment

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

remove slash

Comment on lines +31 to +33
self.enforce_image_hw = None
if enforce_image_hw is not None:
self.enforce_image_hw = tuple(enforce_image_hw)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we specify enforce_image_hw: Tuple[int] = None to avoid this check?

Copy link
Contributor Author

@itrushkin itrushkin Aug 23, 2021

Choose a reason for hiding this comment

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

To allow using Tuple here we need to parse YAML collections as tuples. But it requires a specific !!python/tuple tag that is not supported by yaml.safe_load function. All collections are parsed as lists, and they need to be converted to tuples inside ShardDescriptor class since the usage of yaml.safe_load is strictly required.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can convert it to Tuple before we are passing the arguments to constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We probably could if we created ShardDescriptor instance manually only. But when we spawn envoy via fx envoy start, it reads Shard Descriptor YAML file, calls the constructor of template class, and passes settings as keyword arguments. In this case, the constructor will always receive collections as lists. We can not access intermediate steps between parsing the config file and calling the constructor because it happens inside the library code.

Comment on lines 136 to 139
tls=False,
root_certificate='./cert/root_ca.crt',
private_key='./cert/one.key',
certificate='./cert/one.crt',
Copy link
Contributor

Choose a reason for hiding this comment

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

root_certificate, private_key, certificate are not required then tls=False

@alexey-gruzdev alexey-gruzdev merged commit 4f48131 into develop Aug 24, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Aug 24, 2021
@alexey-gruzdev alexey-gruzdev deleted the ci_for_interactive_api branch August 24, 2021 13:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants