-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add optimizations list #114
Conversation
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.
Ok that's pretty interesting
<td><%= optimization_request.owner.login %></td> | ||
<td><%= optimization_request.kind %></td> | ||
<td><%= optimization_request.outputs["status"] ? optimization_request.outputs["status"] : "Empty" %></td> | ||
<td><%= optimization_request.inputs.empty? ? "0" : optimization_request.inputs["x"].length %></td> |
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.
You should create a method nb_of_evaluations
in the Optimization
model
app/models/optimization.rb
Outdated
@@ -154,4 +154,18 @@ def log_error(err_msg) | |||
def raise_error(err_msg) | |||
raise OptimizationError.new(err_msg) | |||
end | |||
|
|||
def nb_points | |||
return self.inputs.empty? ? "0" : self.inputs["x"].length |
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.
Hi Nicolas. You can remove return
. In Ruby, the return
keyword is optional when returning at the end of a function and in practice is only used when returning earlier.
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.
Yes, I forgot, thank you for reminding me, I will fix this.
Removed the returns in the optimization model
app/models/optimization.rb
Outdated
self.inputs.empty? ? "0" : self.inputs["x"].length | ||
end | ||
|
||
def status_text |
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.
Actually this kind of methods are helpers for views and are rather located in a Ruby module under app/helpers
.
app/models/optimization.rb
Outdated
|
||
def status_text | ||
status_text = { | ||
-2 => "Unkown_Error", |
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.
It is better to create ruby constants in Optimization like (UNKNOWN_ERROR_STATUS = -2
, etc.) to avoid "magic number" effect. It appears much verbose at first but definitely better in the long run.
@@ -21,3 +21,8 @@ user4: | |||
login: davina | |||
email: davina.davis@onera.fr | |||
api_key: FriendlyApiKeyUser4 | |||
|
|||
user5: |
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.
By adding this user, it changes the result of the test related to the search of candidates for being added as a member of an analysis among the available users.
You have to modify the test controllers/api/v1/user_roles_controller_test.rb
line 34: assert_equal [admin.id, user5.id, user2.id], resp.map{|u| u["id"]}
with adding before user5 = users(:user5)
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.
Thank you for the fix, it worked.
test/fixtures/users_roles.yml
Outdated
@@ -58,6 +58,14 @@ users_roles_optim_ackley2d: | |||
user: user1 | |||
role: owner_optim_ackley2d_role | |||
|
|||
users_roles_optim_unexpected_id: | |||
user: user5 | |||
role: owner_optim_unexpected_id_role |
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.
This role and the one below are mentioned here but not defined in roles.yml
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.
It escaped my search, thank you, they are now properly defined.
test/fixtures/optimizations.yml
Outdated
@@ -1,3 +1,13 @@ | |||
optim_ackley2d: | |||
id: 2 |
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.
There is,no need to specify id
. Ids are assigned automatically.
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.
Good to know, thank you !
test/fixtures/optimizations.yml
Outdated
|
||
optim_unexpected_id: | ||
id: -2.28 |
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.
Indeed there is no such thing as an id
being equal to -2.28
! Not sure why you need that.
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.
I tried to find every test i could think of, but if the ids are completely secure, no need to check for unexpected id, I agree.
This PR adds information about optimizations run by the user as a list.