Automation support #10

Merged
nikooo777 merged 31 commits from automation-support into master 2018-07-25 16:37:30 +02:00
nikooo777 commented 2018-04-30 21:28:04 +02:00 (Migrated from github.com)
This addresses https://github.com/lbryio/internal-issues/issues/165
tzarebczan commented 2018-05-02 18:41:51 +02:00 (Migrated from github.com)

@nikooo777 Is this ready for review?

@nikooo777 Is this ready for review?
nikooo777 commented 2018-05-02 23:30:10 +02:00 (Migrated from github.com)

negative Tom :) it's work in progress

negative Tom :) it's work in progress
nikooo777 commented 2018-05-18 00:49:25 +02:00 (Migrated from github.com)

@lyoshenka there is a lot of work in here, It's not yet ready to be merged but if you want you can take a look at it already and let me know what I should change I'm happy with it.

There is some code reuse that I'd like to address and logging is inconsistent: some goes to slack and some doesn't.

@lyoshenka there is a lot of work in here, It's not yet ready to be merged but if you want you can take a look at it already and let me know what I should change I'm happy with it. There is some code reuse that I'd like to address and logging is inconsistent: some goes to slack and some doesn't.
lyoshenka (Migrated from github.com) reviewed 2018-05-23 16:09:00 +02:00
lyoshenka (Migrated from github.com) left a comment

overall these changes look very messy. I know my ytsync code was messy to begin with, so I'm partially to blame as well. but now that we're planning to use the code for a while, we should come up with a coherent structure and move towards cleaner code. i can discuss with you if you want.

overall these changes look very messy. I know my ytsync code was messy to begin with, so I'm partially to blame as well. but now that we're planning to use the code for a while, we should come up with a coherent structure and move towards cleaner code. i can discuss with you if you want.
lyoshenka (Migrated from github.com) commented 2018-05-23 16:07:33 +02:00

this is not common to cmd. this is common to ytsync. you also don't need a separate common.go file. just put it in an existing file

this is not common to `cmd`. this is common to `ytsync`. you also don't need a separate `common.go` file. just put it in an existing file
lyoshenka (Migrated from github.com) commented 2018-05-23 15:42:06 +02:00

what is this?

what is this?
lyoshenka (Migrated from github.com) commented 2018-05-23 15:43:23 +02:00

don't hardcode this url. the API domain and endpoints should be configured somewhere

don't hardcode this url. the API domain and endpoints should be configured somewhere
lyoshenka (Migrated from github.com) commented 2018-05-23 16:06:45 +02:00

keep the cmd package very small. it should just gather the CLI options and call a function in the ytsync package. lbry.go is shared across many different projects. keep your changes in ytsync package as much as possible.

keep the cmd package very small. it should just gather the CLI options and call a function in the ytsync package. `lbry.go` is shared across many different projects. keep your changes in `ytsync` package as much as possible.
lyoshenka (Migrated from github.com) commented 2018-05-23 16:04:02 +02:00

are you making calls to the live API here? this is a very weak test. and you're including the auth_token in public code that's visible on github?

are you making calls to the live API here? this is a very weak test. and you're including the auth_token in public code that's visible on github?
lyoshenka (Migrated from github.com) commented 2018-05-23 15:46:06 +02:00

please avoid having a util package as much as possible. it becomes a dump for random code. this function is only used in the cmd package, so it can just be declared there

please avoid having a util package as much as possible. it becomes a dump for random code. this function is only used in the cmd package, so it can just be declared there
lyoshenka (Migrated from github.com) commented 2018-05-23 15:47:23 +02:00

i think this is gonna be in beamer's PR, but it should not go into util either. we should make our own slack package.

i think this is gonna be in beamer's PR, but it should not go into `util` either. we should make our own `slack` package.
lyoshenka (Migrated from github.com) commented 2018-05-23 15:52:18 +02:00

this should be SendErrorToSlack. and really, it should be it's own package called slack so you can simply slack.Error("stuff") instead of util.SendErrorToSlack("stuff")

this should be SendErrorToSlack. and really, it should be it's own package called `slack` so you can simply `slack.Error("stuff")` instead of `util.SendErrorToSlack("stuff")`
lyoshenka (Migrated from github.com) commented 2018-05-23 16:02:51 +02:00

lbry.go is a general package used in lots of other places. you can't have a general util function called sendToSlack that says YTSYNC in the message. all ytsync-specific stuff should go into the ytsync package

lbry.go is a general package used in lots of other places. you can't have a general util function called sendToSlack that says YTSYNC in the message. all ytsync-specific stuff should go into the ytsync package
lyoshenka (Migrated from github.com) commented 2018-05-23 15:47:57 +02:00

this doesn't test anything

this doesn't test anything
lyoshenka (Migrated from github.com) commented 2018-05-23 15:56:28 +02:00

this needs a better name

this needs a better name
@ -39,1 +42,4 @@
log.Debugf("Source channel has %d videos", numOnSource)
if numOnSource == 0 {
return nil
}
lyoshenka (Migrated from github.com) commented 2018-05-23 15:48:32 +02:00

why?

why?
@ -140,6 +156,7 @@ func (s *Sync) ensureEnoughUTXOs() error {
}
func (s *Sync) waitUntilUTXOsConfirmed() error {
origin := time.Now()
lyoshenka (Migrated from github.com) commented 2018-05-23 15:49:19 +02:00

restarting the daemon should be its own function

restarting the daemon should be its own function
lyoshenka (Migrated from github.com) commented 2018-05-23 15:49:29 +02:00

does this still happen with lbryumx?

does this still happen with lbryumx?
@ -197,3 +206,3 @@
func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string) error {
func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string) (*SyncSummary, error) {
//download and thumbnail can be done in parallel
err := v.download()
lyoshenka (Migrated from github.com) commented 2018-05-23 15:50:27 +02:00

err is not a delete error here, its the publish error

err is not a delete error here, its the publish error
lyoshenka (Migrated from github.com) commented 2018-05-23 15:57:26 +02:00

use errors.Prefix so you don't lose the original trace

use `errors.Prefix` so you don't lose the original trace
@ -254,1 +330,3 @@
log.Println(err.Error())
s.grp.Stop()
SendErrorToSlack("Failed to setup the wallet for a refill: %v", err)
break
lyoshenka (Migrated from github.com) commented 2018-05-23 15:54:49 +02:00

what i meant was, why not just download the thumbnail from youtube to s3. why do we need some remote JS function running to do this?

also, if you're gonna answer questions in comments, delete the question and simply explain what the code is doing.

what i meant was, why not just download the thumbnail from youtube to s3. why do we need some remote JS function running to do this? also, if you're gonna answer questions in comments, delete the question and simply explain what the code is doing.
nikooo777 (Migrated from github.com) reviewed 2018-05-25 02:15:33 +02:00
nikooo777 (Migrated from github.com) commented 2018-05-25 02:15:33 +02:00

just to make this clear. the first parameter is the auth token, which is just a number as I'm using this "test" locally. The second parameter is a channel ID.

I basically wrote tests to run the portion of code without having to compile and run the whole program, I believe more code should be tested in a better way. I don't think any of the tests here actually test anything.

Also yesh, I'm calling a local API, not the live API, but the right approach would be to mock the API.

just to make this clear. the first parameter is the auth token, which is just a number as I'm using this "test" locally. The second parameter is a channel ID. I basically wrote tests to run the portion of code without having to compile and run the whole program, I believe more code should be tested in a better way. I don't think any of the tests here actually test anything. Also yesh, I'm calling a local API, not the live API, but the right approach would be to mock the API.
nikooo777 (Migrated from github.com) reviewed 2018-05-25 02:18:00 +02:00
@ -39,1 +42,4 @@
log.Debugf("Source channel has %d videos", numOnSource)
if numOnSource == 0 {
return nil
}
nikooo777 (Migrated from github.com) commented 2018-05-25 02:18:00 +02:00

The main reason is that while we publish for 0.01 LBC, the fees are up to 0.1LBC.
In a future approach we'll have to change this to just calculate the fees and add 0.01LBC on top of it

The main reason is that while we publish for 0.01 LBC, the fees are up to 0.1LBC. In a future approach we'll have to change this to just calculate the fees and add 0.01LBC on top of it
nikooo777 (Migrated from github.com) reviewed 2018-05-25 02:28:18 +02:00
nikooo777 (Migrated from github.com) commented 2018-05-25 02:28:18 +02:00

the other solution we discussed worked too :)

the other solution we discussed worked too :)
lyoshenka (Migrated from github.com) reviewed 2018-05-25 16:59:31 +02:00
@ -39,1 +42,4 @@
log.Debugf("Source channel has %d videos", numOnSource)
if numOnSource == 0 {
return nil
}
lyoshenka (Migrated from github.com) commented 2018-05-25 16:59:31 +02:00

oh, that makes sense. when i wrote this, we did not have fees based on claim name length

oh, that makes sense. when i wrote this, we did not have fees based on claim name length
nikooo777 (Migrated from github.com) reviewed 2018-05-29 19:49:42 +02:00
nikooo777 (Migrated from github.com) commented 2018-05-29 19:49:42 +02:00
https://github.com/lbryio/lbry/issues/1192#issuecomment-392816078
kauffj commented 2018-07-11 16:57:20 +02:00 (Migrated from github.com)

@lyoshenka if @nikooo777 is using this in production does it really make sense to continue to block merging this?

@lyoshenka if @nikooo777 is using this in production does it really make sense to continue to block merging this?
nikooo777 (Migrated from github.com) reviewed 2018-07-17 20:30:16 +02:00
nikooo777 (Migrated from github.com) commented 2018-07-17 20:30:16 +02:00
https://github.com/lbryio/lbry.go/issues/22
lyoshenka (Migrated from github.com) reviewed 2018-07-19 17:09:22 +02:00
lyoshenka (Migrated from github.com) commented 2018-07-19 16:37:46 +02:00

why the switch from ytsync to selfsync. This package is called lbry.go, so its very general. selfsync is too generic a name.

why the switch from `ytsync` to `selfsync`. This package is called `lbry.go`, so its very general. `selfsync` is too generic a name.
@ -37,8 +46,11 @@ func SendToSlackChannel(channel, username, message string) error {
}
lyoshenka (Migrated from github.com) commented 2018-07-19 16:41:38 +02:00

these functions should not be in slack.go. first of all, they log the error twice, since sendToSlack already calls log.Debugln. second, all they do is add an emoji. you can put these functions someplace in the ytsync package if they are used a lot there, but they should not be out here.

however, using fmt.Sprintf is a nice touch. i support adding that to the existing Send functions.

these functions should not be in slack.go. first of all, they log the error twice, since `sendToSlack` already calls log.Debugln. second, all they do is add an emoji. you can put these functions someplace in the ytsync package if they are used a lot there, but they should not be out here. however, using `fmt.Sprintf` is a nice touch. i support adding that to the existing Send functions.
lyoshenka (Migrated from github.com) commented 2018-07-19 16:45:23 +02:00

name is not that clear. if you saw two functions InSlice and ContainedInSlice, could you tell what the difference was?

I'd call this something like SubstringInSlice

also please use the same var names as InSlice (str, values) for consistency, unless different names would add clarity.

name is not that clear. if you saw two functions `InSlice` and `ContainedInSlice`, could you tell what the difference was? I'd call this something like `SubstringInSlice` also please use the same var names as InSlice (`str`, `values`) for consistency, unless different names would add clarity.
lyoshenka (Migrated from github.com) commented 2018-07-19 16:46:20 +02:00

perhaps these constants should be shared with internal-apis? then they're not defined in two places.

perhaps these constants should be shared with internal-apis? then they're not defined in two places.
lyoshenka (Migrated from github.com) commented 2018-07-19 16:48:27 +02:00

maybe include the erroneous response in the error?

maybe include the erroneous response in the error?
lyoshenka (Migrated from github.com) commented 2018-07-19 16:50:00 +02:00

os.Getenv() should not be used here. that should happen in cmd. syncmanager should be initialized with the correct keys. that way it can be used in tests, in other packages, etc

os.Getenv() should not be used here. that should happen in `cmd`. syncmanager should be initialized with the correct keys. that way it can be used in tests, in other packages, etc
lyoshenka (Migrated from github.com) commented 2018-07-19 16:50:42 +02:00

blobfiles dir should be configurable

blobfiles dir should be configurable
@ -37,6 +40,9 @@ func (s *Sync) walletSetup() error {
}
lyoshenka (Migrated from github.com) commented 2018-07-19 16:52:18 +02:00

fyi this can happen if the channel owner also publishes other videos into the channel

fyi this can happen if the channel owner also publishes other videos into the channel
lyoshenka (Migrated from github.com) commented 2018-07-19 16:55:25 +02:00

checking the message is not the right way to detect if the dir exists. google it or ask me if you're not sure

checking the message is not the right way to detect if the dir exists. google it or ask me if you're not sure
lyoshenka (Migrated from github.com) commented 2018-07-19 16:56:53 +02:00

v.dir+"/"+v.id should be a function, since its used in multiple places. maybe videoDir()?

`v.dir+"/"+v.id` should be a function, since its used in multiple places. maybe `videoDir()`?
@ -195,3 +204,3 @@
}
func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string) error {
func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string) (*SyncSummary, error) {
lyoshenka (Migrated from github.com) commented 2018-07-19 16:58:42 +02:00

why are we ignoring the error? do errors happen here? i'd at least log it. same above.

why are we ignoring the error? do errors happen here? i'd at least log it. same above.
@ -116,3 +170,4 @@
logShutdownError(processDeathError)
} else {
walletErr := os.Rename(defaultWalletDir, walletBackupDir)
if walletErr != nil {
lyoshenka (Migrated from github.com) commented 2018-07-19 17:04:09 +02:00

this is pretty confusing. id rather put the rest of FullCycle into another function, call that function, then check the error message and run this deferred stuff on it

this is pretty confusing. id rather put the rest of FullCycle into another function, call that function, then check the error message and run this deferred stuff on it
lyoshenka (Migrated from github.com) commented 2018-07-19 17:05:46 +02:00

its kinda redundant to have two Prefix-ings. you can just do e = errors.Prefix(msg + ":" + err.Error(), e)

its kinda redundant to have two Prefix-ings. you can just do `e = errors.Prefix(msg + ":" + err.Error(), e)`
lyoshenka (Migrated from github.com) commented 2018-07-19 17:07:30 +02:00

since you now have a SyncManager that gets configured, this stuff should come from the SyncManager. it should not be set here. as before, calling os.Getenv() here is weird. I know my code did this before, but that should be changed now.

since you now have a SyncManager that gets configured, this stuff should come from the SyncManager. it should not be set here. as before, calling os.Getenv() here is weird. I know my code did this before, but that should be changed now.
lyoshenka (Migrated from github.com) commented 2018-07-19 17:08:29 +02:00

👍

the other functions you added to util/slack.go should go here as well

:+1: the other functions you added to util/slack.go should go here as well
lyoshenka (Migrated from github.com) commented 2018-07-19 17:08:52 +02:00

fatalErrorSubstrings

`fatalErrorSubstrings`
nikooo777 (Migrated from github.com) reviewed 2018-07-19 17:17:39 +02:00
nikooo777 (Migrated from github.com) commented 2018-07-19 17:17:38 +02:00

you're right. I had this built when ytsync was still there, that's why it had a different name. I will change it back.

you're right. I had this built when ytsync was still there, that's why it had a different name. I will change it back.
nikooo777 (Migrated from github.com) reviewed 2018-07-19 17:21:27 +02:00
nikooo777 (Migrated from github.com) commented 2018-07-19 17:21:27 +02:00

good idea! should i put them in a package of their own?

good idea! should i put them in a package of their own?
nikooo777 (Migrated from github.com) reviewed 2018-07-19 17:22:11 +02:00
nikooo777 (Migrated from github.com) commented 2018-07-19 17:22:11 +02:00

Ok! I'll move them there

Ok! I'll move them there
nikooo777 (Migrated from github.com) reviewed 2018-07-19 17:22:27 +02:00
nikooo777 (Migrated from github.com) commented 2018-07-19 17:22:27 +02:00

Will export it to an env var

Will export it to an env var
nikooo777 (Migrated from github.com) reviewed 2018-07-19 17:23:50 +02:00
@ -37,6 +40,9 @@ func (s *Sync) walletSetup() error {
}
nikooo777 (Migrated from github.com) commented 2018-07-19 17:23:50 +02:00

yes if we'll allow publishing to channels while we also keep them in sync then this will be the case. otherwise this happens when channel owners delete videos from their youtube channel

yes if we'll allow publishing to channels while we also keep them in sync then this will be the case. otherwise this happens when channel owners delete videos from their youtube channel
nikooo777 (Migrated from github.com) reviewed 2018-07-19 17:25:44 +02:00
@ -195,3 +204,3 @@
}
func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string) error {
func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string) (*SyncSummary, error) {
nikooo777 (Migrated from github.com) commented 2018-07-19 17:25:44 +02:00

the error is logged within the function. I had the same thoughts the other day and couldn't understand my reasoning until when I checked the function itself. Perhaps I should drop logging within the function and log it here? Also we ignore the error because deleting is not something that will compromise publishing and we can take care of that "offline"

the error is logged within the function. I had the same thoughts the other day and couldn't understand my reasoning until when I checked the function itself. Perhaps I should drop logging within the function and log it here? Also we ignore the error because deleting is not something that will compromise publishing and we can take care of that "offline"
nikooo777 (Migrated from github.com) reviewed 2018-07-24 01:14:14 +02:00
nikooo777 (Migrated from github.com) commented 2018-07-24 01:14:14 +02:00

Actually, the way they reside in the code will make them available through the ytsync package once this is merged in master. So nothing to change here I believe

Actually, the way they reside in the code will make them available through the ytsync package once this is merged in master. So nothing to change here I believe
nikooo777 (Migrated from github.com) reviewed 2018-07-24 01:32:02 +02:00
nikooo777 (Migrated from github.com) commented 2018-07-24 01:32:02 +02:00

Actually, this is not meant to check if a directory exists, instead it's meant to report any error other than "file exists". This is due to the fact that each video has its own subdirectory to avoid name conflicts and if for some reasons the video was previously downloaded (ie on a retry attempt) the directory doesn't have to be re-created.

If however you think I should check for the directory before calling mkdir then I will adapt the code.

Actually, this is not meant to check if a directory exists, instead it's meant to report any error other than "file exists". This is due to the fact that each video has its own subdirectory to avoid name conflicts and if for some reasons the video was previously downloaded (ie on a retry attempt) the directory doesn't have to be re-created. If however you think I should check for the directory before calling mkdir then I will adapt the code.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/lbry.go#10
No description provided.