In this video we are going to take a short break from the topic of iteration and we will look into another topic that is totally unrelated namely the topic of input validation. So in a couple of previous videos when we defined functions we already could guess that if for example we caught the factorial function with a negative integer or a floating point number that maybe something goes wrong. And therefore in this video we look into ways of how we can ensure that the function gets the input that it needs in order to work. So let's start by creating a new notebook file and call it input validation. And let's briefly review the factorial example. So remember that there are two ways to solve the factorial problem. One way is using a recursion and the other is to use a looping strategy. And here we are going to use the recursive strategy. So I am going to go ahead and write define factorial and the function takes n and we always assume that n is a positive integer. Let's write a little dog string, calculate the factorial of a number. And here we specify under the arcs section that n is supposed to be an integer. And it's the number to calculate factorial 4. And also the function returns the factorial which happens to be also an integer. So we give the function an integer and we get an integer back. Now let's implement the function and using the recursive strategy. So first we go ahead and implement the base case by saying if n double equals zero then we simply return one. And the reason for that is because zero factorial is simply defined to be one. That's a mathematical definition. There is nothing to be calculated here. And then otherwise, so in the else clause, we will go ahead and we'll say return whatever n is times the factorial of n minus one, that is the recursive step. So that is basically when we write that in math notation, this is what we would say when we say n factorial is defined to be n times in parentheses n minus one factorial. So this is usually what mathematicians would write in math notation and in Python code this looks a little bit different. And then also in a previous video on several previous videos we learned that after the return statement the function is done. So in other words, what we do is to simplify this a bit, we get rid of the else clause and unindent the second return statement. And so now how this works is if we call the function with n set to zero, then basically the condition is true. The base case is executed, the function immediately returns by saying return one. Otherwise, if the condition is not true, the code will Python interpreter will jump right to the second return statement and will execute this expression here n times factorial of n minus one. And the second, the right hand side, the factorial of n minus one is what calls or what triggers another function call. So the function calls itself and this is basically what a recursion is. So in layman's words, we said a recursion is a function that calls itself and has a way out. And the way out is of course the base case, okay. So let's define the function and let's quickly check if the function works. For example, for zero, we get back one. And if I want to calculate the factorial of three, I get back six. So what could go wrong here in terms of input? Well, let's play a little bit with what we have here. So maybe let's go ahead and let's call the factorial function not with three, but with 3.0, a floating point number. So let's see what happens. Well, we get back 6.0. So in a way, the function works and we get back a correct result. However, the data type we get back is not the one that is specified in the doc string. Okay, so this is kind of, it's kind of okay, but it's not ideal. Now let's also go ahead and say what happens if we call the factorial function with an argument of 3.1. Before I execute this, let's guess what could happen. Well, what happens is in the first iteration or in the first time the function is called, n is 3.1, so it's not zero. So the second line here is going to be executed. So the function calls itself, which triggers another function call for n minus one. So for 2.1 then, because 3.1 minus one is 2.1. If the function is called with 2.1, we end up in the last line again. This triggers another function call where n is set to 1.1. So it starts again to run from top to bottom. 1.1 is still not zero. So it happens one more time that we end up in the last line. This calls the function again with 0.1 now. Well, 0.1 is also not zero. So what happens is we reach the last line one more time. And then 0.1 minus one will give me negative 0.9. So the factorial function at some point will be called with negative 0.9. And negative 0.9 is below zero. And from then on, the base case will never be hit. And it's also not theoretically possible to hit the base case. Why? Because once n is negative, it only becomes more negative, because we are subtracting one here, OK? So in other words, this function is going to call itself an infinite number of times, forever, basically. So let's see what's going to happen. So we first see that Python tries to execute the cell, and it takes some time. So we see the star here for calculating. It basically is there. But then at some point, luckily, Python has a built-in detection for finding out infinite recursions. And this gives basically us this red arrow message here, OK? So Python has like a fail-save system built in. It is roughly about 3,000 function calls that can be made simultaneously. And if we exceed this number, then Python basically says, well, this function has been calling itself 3,000 times already, and it has not ended. The process has not ended. Therefore, I just ended for you, OK? If Python would not do that, then we would have basically a case where the cell here would run forever. And then we could only stop it with the stop button to interrupt the processing, OK? So that is important. So now, what we could do is, in order to prevent this infinite recursion case, what we could do is, we could maybe go ahead and replace the double equal sign where we compare n to 0 to smaller than or equal to 0. So what will then happen is the first three function calls are just the same. And the last function call now is going to return us a value instead of raising an arrow message. However, the result is, of course, wrong, OK? So this is not the factorial of 3.1. So in other words, even though in math world, you could calculate the factorial of decimal numbers, but that is not what we want to model here. So according to the doc string, we only want to model the factorial of whole numbers, of integers. Therefore, this result is kind of not good. However, we see that by exchanging a double equals into a lower than or equal to, we can at least prevent the infinite number of times the function is calling itself. So this function will only call itself in total four times. However, that is not good, OK? So this would be a quick fix, so to say, but it's not good. It's not solving the problem really. So what we do is we leave it at the double equals because this code, basically, we know it's correct. It does what we want it to do. But then we go ahead and we make ourselves a little bit of space before the if statement here. And what we are going to do here is we are going to implement some input validation. So that means we first want to make sure that below here where the problem is actually solved, the program has the data type that we expect. And there are a couple of strategies. So let's, first of all, introduce a couple of words. So when we saw here, when we called the factorial function with 3.0 instead of just 3, the integer, it works. And the reason is because the 3.0 integer behaves like the 3 as an integer type. So 3.0 as a float behaves like 3 as the integer type. That is why this function called here works. And that is an example of what we refer to as duck typing. And what do I mean with the term duck typing? Well, this is a term that is often used in the Python words, probably also in some other programming languages. But duck typing basically means if it works like a duck and it works like a duck, it must be a duck. So in other words, if something, so in this case, the floating point object behaves like the other object, then it must be the other object. So that is usually a strategy used. So in other words, when we say the function needs an integer, then we are not so strict, really. We only say the function needs something that behaves like an integer. It walks and walks like an integer, so to say. And because I pass in 3.0, the 3.0 as a float, as we can guess, behaves like 3 as an integer, so we don't get a big problem here. So sometimes, this solution approach is enough, so doing nothing, basically, and saying, OK, this is just an example of duck typing. However, we saw that in general, this does not work. So we want to use a different strategy here. And a different strategy is we want to make sure that n down here, so maybe let's say here, we know that n is a positive integer. That's what we want to do here. This is input validation. So let's look at a couple of strategies of how we can do that. So the first one is what we refer to as type checking. So type checking basically means we go ahead and check the type of something. So let me maybe do that below here in another cell. So let's say if I have the number 3 as an integer, and I want to ask Python, hey, Python, is this actually an integer? How can I do that? Well, Python has a built-in function called isInstance. And the function takes two arguments, the first one being the object, which we want to check, so 3 in this case. And the second one being the constructor or the class of what we want to check if it's a type of. So in this case, the function gives me back true. And that basically means, yes, 3 is an integer. So let's do the same thing again. But let's input 3.0. Then the function gives me back false because 3.0 is a floating point object. It's not an integer. Therefore the function returns false. So now what we can do is to implement type checking, what we can do is we go ahead and write if isInstance or if not isInstance. And this is the object that we want to check. And we want to check if it's an integer. Then let's go ahead and say, we want to raise an error here, okay? So what is raising an error mean? Well, we have seen a couple of times these red error messages. This is always when JupyterLab shows us that Python couldn't deal with something when some error occurred. In a real program, this would mean the program would just crash. This is what the red error messages mean. And we can generate these red error messages ourselves. So let's see also in an example down here how we can do that. We can use the raise statement. And the raise statement basically generates an error. So let's do an example. Let's go ahead and create a so-called type error. And let's give it a message by simply saying wrong type. And this way we can generate these red error messages ourselves. And here we see the message, wrong type here. So what we can do here is if the function is called with an n that is not an integer in the type checking strategy, what you want to do is we want to simply raise an error. So, and of course we raise a type error because if we entered the wrong type, then it is a type error. And then we put a nice message in here. And we could say factorial is only defined defined for whole numbers, okay? Now let's go ahead. I redefined the function. Let's call it for with a argument of zero, it works. With an argument of three, it also works. And now let's go ahead and call the function with 3.0, a floating point number. And all of a sudden we see the red error message here. And also of course for 3.1, we also see the red error message, okay? So this is already an improvement because now we don't get back a wrong result and unmeaningful result here, but we get back an error message in return. So in other words, we know now as the user of the function that something must be wrong. However, what I don't like about the function here is this case because of the idea of duct typing that 3.0 behaves like a three. This ideally should not raise an error here. Ideally, I get back a six here, right? Okay, so ideally in an ideal world scenario, I want the function to accept and float and handle it and then give me back six as an integer. And before we saw that, I got back 6.0 as a float here and not the six that I get back when I pass in three as an integer. So let's continue. Another case where we need to model this is the following. Another example would be, let's call the factorial function with a negative number. So let's, for example, calculate the factorial of negative one. So what would you expect to happen? Well, negative one is an integer, okay? So in other words, our type checking here will not fire, okay? So we will end up down here. And what is going to happen down here? Well, if n is already negative to begin with, then the base case will never be reached. So in other words, we are going to run into an infinite recursion again. So let's go down and prove that. I execute factorial of negative one and we see that I also get a recursion error. So this is again, Pythons built in fail-save system so that the computer program here does not just run forever, okay? It just stops it on purpose here. So here, I would also like to have a nice error message because recursion error can be anything. I don't know what happens. As the user of the function here, I don't know what is going wrong here. So let's also include this in the input validation. So let's go ahead and say, L if, so if the first condition here is not true, then we know it's down here, we know it's an integer, then we could say, L if n is strictly smaller than zero, then we are also going to raise an error. But this time we are not going to raise a type error, but we are going to raise a so-called value error because the semantic value, so to say, of the object is wrong, okay? Negative one does not make sense for factorial, semantically speaking, so for us humans speaking. And therefore, we will go ahead and say, factorial is defined only for non-negative numbers. Okay, and let's go back down to the case where we have factorial of negative one. Last time I executed this, we got a recursion error. If I execute this one more time, I now get a value error and it gives me back our own custom error message. Okay, so this is already an improvement because as the user, I now know what did I do wrong. Okay, as a user, when I get an error message, I wanna know what did I do wrong. So here I know it, okay? So this is one strategy. So now we have a full-fledged input validation scheme. So this is now okay. However, as I just said before, what I don't like is the fact that I cannot call the function with 3.0, okay? So because of that, what we can do is, we can use another strategy. And the other strategy, so this current strategy here is an example of type checking, I'm checking the type, but the other strategy I mean that I am now introducing is the strategy called type casting. To cast an object basically means, we make sure that it is of a certain data type. Or in other words, if it is not, then we convert it into this data type. And how can we do that? Well, let's get rid of this if check here, the first line. Then of course, we have to go ahead and we have to change the LF into an if. And now we have to make sure that N is an integer. How can we do that? Well, very easy. We can simply go ahead and use the built-in int constructor and pass N to it. So in other words, if I now pass in N and it is a float, it will be converted into an integer. And from then on it works. So let's see what difference does that make. So factorial of zero works as before, factorial of three works as before. And the factorial of 3.0, that before that gave me a type error, will now give me six. And now let's check what does the factorial of 3.1 do. Well, unfortunately now it will also give me a six. And factorial of negative one will still give me the error message because the number is negative. So now I have basically changed my problem, so to say. So now factorial of 3.0, which implements tug-diving, basically accepts a float and gives us back a correct result. However, for 3.1, it also gives us back six. Why is that?  Also, if I call it with, let's say 3.9, I also get back three. So no matter what the decimal is, the decimal is just cut off by the int constructor. So we shouldn't leave the function like this, okay? Because if we did, then this would be a semantic error here, okay? If this worked here, then this would be an example of a semantic error, a case where a computer program does not give us a red error message, but still something is wrong, so-called semantic error. So now let's go back up and see how else could we deal with that. So there are a couple of strategies, but now I show you one that you could use here and this already gets a bit complicated, but it's just to illustrate a point. So instead of saying we go ahead and we set n equal to an integer of n to the constructor of the return value of the constructor, what we do is, I now go ahead and I will say if n double equals int n, but then the double equals will be changed into a not equal to. So in other words, if n does not compare equal to the integer value of n, then we know we must have, basically we passed in something that cannot be read as an integer, that cannot be transformed without loss of precision. And in this scenario, we would also give back a type error because this is already an indication that this can only happen if the user passed in some other type and the object of the other type could be converted into an integer. However, it gave us, it lost some decimals and therefore it changed the value of the input and this is what we don't want. So here I can, I write an error message like n is not integer like. And also as an explanation, it has non-zero decimals. And now we can go ahead and below this line, what we do is I simply go ahead and now I set n to whatever int of n gives me back. Okay, so this is now a more sophisticated approach. So now the function basically takes any kind of input. It first tries to make it an integer. If it does not work without losing decimals, it gives me an error message. And then it also checks if n is negative. And then if everything passes the tests up here, then we know that the calculation down here will give me back the correct result. So let's try that. So let's see if factorial of zero gives me back the correct result. Factorial of three gives me also back the correct result. Factorial of 3.0 also gives me back the correct result and also the correct data type. Now not 6.0, but six, this is what I get back.  It says n is not like an integer. It has non-zero decimals, okay? And the type error tells me as a programmer, okay, something is wrong with the data type. So I should have passed in something that is an integer or something that walks and quarks like an integer, like a float that has no decimals, okay? And also the negative one still does not work, okay? So now this is basically a full-fledged example of how far you can go with input validation. Now the question is in the real world, how often do you do that? Well this really depends on who defines the function and who uses the function. If both people are the same person and this is often the case, then it is often worthwhile to simply get rid of the entire input validation and leave it just like this. Because I know if I call the function in the wrong way, since I am also the author of the function, I can either go ahead and adapt my function to work with the bad input or I can change the bad input into good input. If I'm the same person defining the function and calling the function, then usually I can deal with that. However, if I'm developing code that someone else is going to use, so if I assume that someone else is going to call my function, then it is always worthwhile to make sure that the input gets validated and in case something goes wrong, the user of the function who does not necessarily know me gets a clear error message that really tells the user what to do or what is wrong. Otherwise, I would get a recursion error as we saw before, but the recursion error simply doesn't tell me anything. It simply tells me that the function runs forever and at some point it's just cut off by Python, but here in this example, this would now deal with all the bad inputs. So this is different strategies of how to handle input, of how to validate input and sometimes you will do that and sometimes you won't do that. It really depends on where the data in here at the parameter, where this is coming from. If it's coming from a trustworthy source or some user that does not know the code has to enter the data, okay? So this is really it, but these are the kind of strategies. So the important takeaways from this video is the term duck typing, of course, and it's of course also type checking and here in this case, this would be value checking. And in general, we call that together input validation, okay? So I will see you in the next video.


Hello my Nakamotachi, this is Joygirl and we are going to discuss all the new One Piece goodness that we have to look forward to. We are in the year of One Piece. Seriously, 2021 is the year of One Piece. This year we've reached various milestones with the series reaching 1000 chapters and 100 volumes in the manga and then also 1000 episodes of the anime in the same year. And then on top of these impressive milestones, the One Piece live action by Netflix and a new One Piece movie have also been announced to come in 2022. What a time to be alive.  So we're going to spend some time discussing these two sources of One Piece media that we have to look forward to for next year, which is a topic that many of you have requested that I share my thoughts on, which I really appreciate seeing because I know a lot of my fellow content creators have covered this topic before so I wasn't actually planning on discussing this, but to know that you guys are interested in and value my thoughts too really means a lot to me. And I love the community. Okay, first I was getting emotional about what a great year we've had and now this. Let's get into the discussion before I get proper sappy. So the news for the casting for the live action has been highly anticipated since the adaptation was announced to be in the works in 2020. And now that the cast is announced, it makes it feel like the live action is now soon upon us and the first thing that I want to say is I'm just super happy because apart from the fact that it's just more One Piece content that I can consume, the fact that it's being done by Netflix means that the live action will get a whole lot more people interested in and hearing the good news of One Piece. And this could translate to new manga readers, which is just great news for the world because One Piece is such an amazing series and deserves all the love, especially for someone like me who grew up around kids who like Naruto and Bleach. But One Piece wasn't as widely talked about because it wasn't seen as cool, given its goofy aesthetics. The live action could potentially break the barrier of why people don't want to get started on the series. I imagine the audience that Netflix has is different from usual Crunchyroll or other strictly anime streaming site members and One Piece will surely be trending upon its release and will spike curiosity for those who've never seen the series before. And I do have high hopes about this because I saw that Cowboy Bebop, which has also recently been released in live action form, has been trending on Netflix so I think regardless of the reception, it will at the least introduce a lot of people to the series. And based on the episode list that Netflix released, we've known for a while that it will cover East Blue up to the end of the Arlong Park arc. And this is perfect because I think Arlong Park is the arc that really captivated most viewers. I'll admit for me that I knew I was hooked in the series earlier than that, but when sharing One Piece journey stories with other fans, I often hear that it was Arlong Park when they got invested and it's understandable because we've got Nami's Help Me moment and of course, The Walk. And because it seems like the live adaptation is only planned for the East Blue saga at this stage, we've only had the casting news for the East Blue 5. And it's exciting to see that Oda released a statement about the actors and the adaptation because I feel like he must have felt that these characters that he created were being well represented and being embodied by the selected actors, so that alone already gives me some faith. And the cast members themselves really do excite me. Looking at the cast as a whole, I love that they're already in character. Makenyu Arata, who's playing Zoro, tagged everyone but Taz Skylar, the actor playing Sanji, in his Instagram post announcing the cast. It reminds me of when the Seiyu for Sanji for the One Piece anime, Hiroaki Hirata, wished Zoro a happy birthday with a blank message, and then the Seiyu for Zoro, Kazuya Nakai, returned the favor by addressing Sanji as bastard chef in his birthday message for the straw hat cook this time. But speaking of the chef, we've seen Taz Skylar cooking for everyone and true to staying in character when the whole crew was hanging out with the directors Matt Owens and Steve Meider, Makenyu wasn't there, which makes me assume that he probably got lost. Such a Zoro thing to do. Now looking at the individual cast members, it's not hard to picture the actors playing their respective East Blue Five character. Firstly, in Aki Godoy, he has the very goofiness and childlike quality needed for Luffy's character. Seeing him rolling around in the grass really captured Luffy's carefree nature and how curious he is about the world. And I don't know if it's just because of his age, but in Aki's eyes, I think they really play a big role in why I see him nailing this role because they really possess the very pure, adventure-loving curiosity of Luffy's character. And on the flip side, I've also seen a clip of Inaki being serious and I have a good feeling that he'll also be able to portray the sheer ferocity Luffy exudes when he's angry. The balance between pure childlikeness and aggression is important to capturing Luffy, and I see that both in Aki Godoy. Now onto Makenyu, we didn't really see much of him in the official announcement, but it's probably the actor people are most familiar with, given some of his other important roles such as in the live-action Ruron Ikenchi movie. Now from that clip alone, I'd say that I am pretty confident in this casting as well, especially the stoic badass quality of the sort spin. I hope that we'll actually get to see the goofiest side of Zoro that we saw in the earlier days of One Piece, but we may have to wait for Netflix to extend the live-action past the first season to see all of those moments. Emily Rudd as Nami is the fan-favorite for the role even before the announcement was released, and you can easily see her as Nami. I've watched bits and pieces of her other stuff such as Fear Street, and from this, I can see her pull off Nami quite well, particularly in the emotional scenes, which is fitting because for the content planned to be covered for the live-action, Nami will be somewhat of a great character, and that Help Me scene is going to be that turning point for everyone to fall in love with Nami. And if you weren't convinced about Emily Rudd, just look at this. Now Jacob Romero Gibson, who'll be playing Usopp, is an intriguing and exciting choice in my opinion. I can see the Usopp in him, but I particularly see a lot of post-timeskip Usopp in Jacob. I also saw a photo of Jacob hanging out with Emily, and the two looked very close and cozy together, and it really reminded me of the reunion between Nami and Usopp, again after the timeskip, but I suppose it could also be seen as reminiscent of the very unique bond that these two weaker members of the crew share with each other, which has persisted throughout the story. But anyways, in some ways, just looking at the appearance alone, Jacob also looks more like Usopp. But I can also see the young look in Jacob as well, and I think that Jacob playing Usopp may actually make people warm to Usopp faster in the adaptation because I know many people dismissed him and only grew to love Usopp as the series continued in the manga or the anime. And I think Jacob, who does at face value, resemble the cooler, more mature Usopp of the post-timeskip era more, could mean that it's easier for people to become invested into how Usopp could grow. As for Tascaila, he is, as for now, the cast member who least resembles his character counterpart, just speaking in terms of appearance. But I think this is largely owed to his buzz-cut hairstyle, which understandably garnered some Eminem comments by the fans, but despite this, I don't feel very concerned about him playing Sanji at all. According to my research, his very experience, he's an award-winning writer, actor, and producer, so I'm pretty confident. Also, I've seen him practicing his kicks and his skydiving, and so my brain already made jumps to Sanji's abilities. Now these are just my first impressions and what I could gather, but obviously I'll have to wait for the teaser or a proper trailer to see how the cast fit in with their characters. It seems we may also have to wait until when to see the casting for Shanks because that hasn't been announced yet, and I'm super excited for this reveal because Shanks is a character who is just as important to the story as the East Blue Five for that first leg of the series, and so if the live adaptation plans to follow that same timeline, then Shanks is going to be one of the very first characters we're going to see in the live-action series. And now that we're on the topic of Shanks, that does bring us to the topic of the one-piece film, Red. Oda announced during Jump Fiesta 2021 that a red-haired man will be making his move in 2021, which is something which spurred heaps of excitement and discussions, and given that 2021 is now almost over and we haven't seen any big move made by Shanks yet, or any other redhead character, unless you count a certain awakening, which I don't believe received the necessary level of hype to be the source of Oda's cryptic message, I am inclined to think that this new one-piece film is what Oda was talking about. Although of course we may still get something else, but realistically we have less than 10 chapters left before the promised year of move-making ends. So based on the ending of this trailer and the title, it is going to heavily feature Shanks, which is of course exciting because he is probably one of, if not the most anticipated character fans are waiting for a deeper delve into, and based on the statistics of one-piece films, it's probably even more likely that the film won't be canon, but I think we may toe the line with this one, because I have high hopes that film Red may border the line of some canon material. The reason I say this is because based on my understanding, film Red will be created by Oda himself, and I know that there was a bit of confusion here because of the English translation in the trailer saying that it was written by Oda, whereas some of our Japanese droid fleet members told me that's not really what that means. So based on my understanding, as of now, it seems that we may have a similar situation to the film Strong World, where the story was created by Oda, including the script, whereas in the past he'd only supplied character designs and the approval for the story. And I think the film Strong World was written by Oda because it was the 10th anniversary of One Piece. Now, what do we have here? Film Red will be released in 2022, the 25th anniversary for One Piece, so I think this could raise the chances of Oda, again, having a much bigger hand in this film compared to some others of the past. Now, given that we also saw a musical girl in the trailer for Film Red, I don't think that Oda's greater involvement will mean that the whole film will be canon, and I know that there are high hopes in the community that the film will explain lots of things like the events at God Valley and such, but I really do see it being more like a Strong World scenario where the film itself wasn't strictly considered canon, but it did directly link to Chapter Zero, which is canon. And in that case, I would still be great news for us because then we could still get some more answers and a look at the very mysterious history of our enigmatic red-haired captain. But going back to that girl, I am excited to see a film focused on a girl because it seems like this was an active decision by Oda based on his comments that he released alongside the trailer that he was sick of drawing legendary old men so he wanted to draw this girl instead. But in terms of characters, what I'm also really intrigued by is the lack of the straw hats in this trailer. Now, of course, this was only the first very short teaser and we may see the straw hats appear later, but I am partly intrigued with the idea of a one-piece film which will actually be a deeper dive into non-straw hat characters. And I do think that if fans were going to be interested in a non-straw hat crew movie, then it's going to be one about the legendary shanks. But it goes without saying that we are still in the very early days and I'm just super excited. This is the first one-piece film that I'll be seeing released at the same time as everyone else because the last time when Stan Pete came out, I was still in Fishman Island and my friend wouldn't let me go watch because at that time I didn't know Sabo was alive. So this really is the best time to be a one-piece fan and it seems that the year of one piece isn't over because we also have so many milestones and exciting things to look forward to for next year. And I, for one, am just so grateful that I have you guys to enjoy this journey with. But now that you've heard my thoughts, let me know yours by leaving a comment below. Don't forget to like and share the video and please do subscribe if you'd like more one-piece discussions. You can also join our Joyfleet Discord server for more one-piece fun and even become a Patreon member for special roles and powers within that server. Thank you to our patrons who help support the channel. This is Joygirl and I'll see you again soon.


This morning, more than 200 people gathered for a press conference held by Pikeville Medical Center, where details were announced for investing over $52 million in upcoming projects and improvements. You know, Pikeville Medical Center represents and services over 450,000 patients throughout our region and to not only make investments on our main campus and to provide the needed services but also to expand and to go out into the communities to make it more convenient for those that we serve. We want to make certain that we're providing the best possible care and we're able to do that through the bricks and mortar movement that we announced today. The biggest monetary project announced today was a $32 million investment to build a new Heart and Vascular Institute with a projected completion date of August of 2020. But the announcement of a new children's hospital definitely drew the most attention. The people of this region for years have had to send our children to Lexington, to Cincinnati, to West Virginia and those are great hospitals, there's no denying that. But the burden that it puts upon the people of this region is unreal. Phase one of that project will be the relocation and expansion of a pediatrics clinic with the completion date of March of 2019. Phases two and three will include inpatient beds and services. PMC CEO Donovan Blackburn says he is proud to be able to announce so many new projects after laying off more than a hundred employees earlier this year. In February we did a realignment of the hospital, we refocused our mission, we were struggling with some finances and that's been well known. We've been able to shore all that up, we've made some good financial decisions with the board's direction, we're now operating very nicely, we're in the black and now we're making investments to serve the area so we can continue to grow. Pikeville Medical Center currently employs about 3,000 people but officials say that number will grow as these projects are completed. In Pikeville, I'm Shannon Deskins, EKB News.


みなさんこんにちは。クバネテススレッジマネジメントの 経験についてお伺いします。クバネテススレッジアサイメントの オプテミゼーションをお話しします。クバネテススケジューションを 使用しています。クバネテススケジューションを 使用しています。まず、私を紹介します。私はケンジモリモトです。サイボーズを使用しています。私はモリモトサイボーズの アイデアのインタビューを使用しています。サイボーズは日本の IT 公司です。クラウドサービスに グループウェアコミュニケーションを作りましょう。私はクラウドサービスに アンクエンジニアを作りました。クラウドサービスに 多くの2,000 人がいます。この様にあるインタビューの デュースを作ったものもツールとなったものが コレクションのコメントで作りましょう。私は最近 目 Johnson のマニュアルを作りました。私がクバネテススと カラーネティープの技術を使用しています。私が今、 今のアジェントを紹介します。まず、私が最初に 試していきました。私はクバネテススケジューション ステップを設定してみました。I'll recap the basic of volume management in Kubernetes and define the problem.I'll describe a basic idea for the problem and then inspect troubles in implementation.We got an unexpected result under the real-world disturbance, so we tuned the kube scheduler configuration. finally, I'll give a demonstration how our tuning improves the placement.First of all, let's take a look at what is a distributed storage system.A distributed storage system organizes node local storage devices in the computer clusterand provides a unified storage resource for users.In the case of SEF, for example, the administrator defines object storage devices or OSDs in short using local disksand SEF gathers OSDs into a storage resource.The management of the element disks in the distributed storage is very tedious work.Before seeing root and SEF on Kubernetes, let's recap the storage architecture of Kubernetes.On Kubernetes, storage is abstracted as persistent volumes.The storage can be local disks, network storage in the cluster, or cloud storage.Pos can define the volumes by using persistent volume claims as dead sources.Pos isn't volume claims specify their requirements for underlying storages through storage class names, resource requests, selectors, and so on.Kubernetes finds or creates a matching PV for PVC and bind them together.We use Rook to deploy a SEF storage cluster.Rook has a mode to configure OSDs through persistent volume claims.Rook configures acquired PVs as OSDs for SEF and then SEF constructs a unified storage resource.What we wanted to do was to deploy a distributed storage system on our on-premise servers.We had experienced that the management of thousands of servers and disks was an awful task if done manually.So we needed Kubernetes help for automatic management.However, there was no standard profile to deploy distributed storage system on Kubernetes.We can expect that SEF is responsible for replicating data across failed domains for robustness.On the other hand, distributing local disks evenly is a task for the administrators.So the challenge here is that we need to distribute persistent volumes for local disks evenly through persistent volume claims.It's easy to achieve even distribution if all disks, all servers, and all racks evenly available.Let's take six disks evenly from these.It's easy.But in reality, this is often not true because, for example, a server node may have broken disks.Some disks of a server may already be assigned for other use, or a rack may have fewer healthy servers than other racks.So in the real world, we need to consider about uneven availability of local disks.This makes our challenge a hard one.In order to achieve even distribution automatically, we need help of Kubernetes.The Kubernetes does not directly schedule storage devices.In contrast to storage handling, Kubernetes provides a very rich set of features to schedule pods.CoupScheduler is a Kubernetes component to schedule pods or nodes.It can schedule pods based on several criteria, including resource requirements, node vectors, pod affinity and anti-affinity, and taint concentrations.Now jump into the basic idea.Our basic idea is to specify wait for first consumer for the volume binding mode in a storage class.But what is the volume binding mode exactly?It can take a value of immediate or wait for first consumer.Let's see the behavior of Kubernetes for each mode in the following slides.The volume binding mode affects the timing when the binding of a PVC and a PV is determined.The default volume binding mode is immediate.In this mode, when the PVC is created, Kubernetes immediately finds or creates a matching PV and binds them together.This binding will work as a topology constraint for CoupScheduler when it schedules the pod that uses this PVC.In our case, the PVC is bound to a local disk, so the consumer pod is bound to the disk's node in effect.The problem here is that we cannot control the matching of a PVC and a PV in terms of even distribution.Another volume binding mode is wait for first consumer.In this mode, a PVC is not bound to a PV until a pod that uses the PVC is scheduled.We can control the pod scheduling by several means.When binding a PVC to a PV, there is a constraint that a PV must be available from the node.As a PV is not local in our case, scheduling a pod is equal to scheduling a PV.So we can control the location of a local storage through pod scheduling.Go back to our basic idea.By specifying wait for first consumer for the volume binding mode, we can translate the problem of storage allocation into the problem of pod scheduling.And as for the pod scheduling, Kubernetes provides a rich set of features and we can utilize those features.Now our challenge is translated to distributing pods with PVCs evenly.Well, which type of scheduling criteria should we use to distribute pods evenly?One candidate is anti-affinity.We can distribute one pod per node by using anti-affinity, but we want to use multiple PVs on one node.Anti-affinity does not distinguish whether there are two pods or three pods or four, five, blah, blah, blah.Much appropriate criterion is pod topology spread constraints.This feature was introduced in Kubernetes 1.16, became better in 1.18, and is now stable in 1.19.A set of pod topology spread constraints compute the scheduling school based on the skew.So we can put a cap on the difference of the numbers of pods.This feature shows how pod topology spread constraints work.This is cited from Kubernetes blog.You can specify max skew to describe the degree to which pods may be unevenly distributed.Topology key to group pods by node levels.When unsatisfiable to indicate what to do if the constraints are not satisfiableand level selector to find target pods.In this example, zone 1 has two pods and zone 2 has one pod.The skew between zones is one.Now here comes a new pod.If this new pod is scheduled to zone 1, the skew becomes three.This breaks the constraint.If the pod is scheduled to zone 2, the skew becomes zero.This satisfies the constraint.So the new pods should be scheduled to zone 2.As a result, we can achieve even pod distribution.We can now distribute pods evenly.But when implementing distribution, we need to consider the case where the constraints are not satisfiable.Let's see the details.NAS3ctree may not be desirable in the real world.As described before, there may be uneven availability of local disks.Sever node may have broken disks.Some disks over server may already be assigned for other use,or a rack may have fewer healthy servers than others.In this example, there are six servers. Each server has four disks.Sever3a has broken disks.It has one healthy disk and three broken disks.Let's start assignment.Lap1.I can assign six pods with six disks, one per node.Lap2.I can assign five pods with five disks.As you can see,Sever3a has no available disk.I cannot start lap3 because assigning a pod and a disk will break the constraints no matter which server I choose.Do I need to stop assignment here?It's not desirable.I want to use as many disks as I can.We can relax the pod-topology-spread constraints by using the parameter of when unsatisfiable.This parameter indicates what to do if a pod does not satisfy the constraints.According to the official document,the behavior is described like this.If the constraints are not satisfiable and do not schedule is specified,CubeScheduler does not schedule the pod.This is the default behavior.If the constraints are not satisfiable and the schedule anyway is specified,CubeScheduler still schedules the pod while prioritizing nodes that minimize the skew.Scheduler anyway seemed optimal for us if it really worked as advertised.So, we tried schedule anyway not to limit resource usage due to uneven local disks.We expected the behavior like this.If the constraints are satisfiable,CubeScheduler always schedules the pod within the constraints.Sounds obvious?Unfortunately,it did not work as expected.Let's start with several pods already running in the cluster.Red-leveled pods are running not on all nodes.Four nodes are used and the other two nodes are completely free.The existing pods consume CPU resource to some extent, say 60%,and there is enough room for the new pods we are now distributing.The new pod will consume CPU resource 5%.The constraint we use here is a simple one.Keep the skew less than or equal to 1 among all nodes.Please note that this constraint is not applied for the existing red pods.We applied the constraint in order to distribute storage management pods evenly.The existing pods are just computing.They are not working for storage management.Then deploy six pods for storage management.The expected placement is like this.Because the constraint is satisfiable,six pods would be distributed evenly.The skew would be zero here.But the actual placement is like this.All new pods are assigned to the unused two nodes.The max skew is three.This breaks the constraint even though it seems satisfiable.Why are the new storage management pods scheduled in such a way?We inspected the source code of kube scheduler and find the actual behavior.What we expected had two if-closes.If satisfiable blah blah blah and if not satisfiable blah blah blah.The actual behavior is whether the constraints are satisfiable or not.Kube scheduler does not treat the constraining conditions as real constraints.Instead, the conditions are treated as a part of the squaring factors.So as a result,flattering CPU resource usage took a higher priority.Even though the spread constraint was satisfiable,the existing computing pods prevented even distribution.This came from the prioritizing algorithm of kube scheduler.So we need to tune it.The most important criteria in pod scheduling for our case is the topology spread constraints.So we tuned kube scheduler to weigh the constraints more heavily.Because kube scheduler is rapidly evolving,it requires different tuning configuration for its versions.For Kubernetes 1.17,we adjusted the scheduling policy.There is a weight parameter named even pod spread priority and its default value is 1.We increased the weight to 500.The scheduling policy is a global configuration,so this modification requires extreme caution.In Kubernetes 1.18,the feature of scheduling profiles is introduced.Kube scheduler handles multiple profiles now.We can create a new profile and apply it only to the storage management pods.From among the parameters in the profile,we said pod topology spreads weight to 500 in Kubernetes 1.18.In 1.19,the parameters are slightly tuned by default.So disabling node resources' balanced allocation is suitable for us.I attached our tuning configurations in this slide.Please check them from theskiz.com link.Now I'll give a demonstration.I prepared two environments.One with default kube scheduler and the other with tuned kube scheduler.Let's see the default one first.This is not tuned environment.This is the default kube scheduler.This is demonstration environment.Well,first let's see the nodes.There are four nodes here.And two computing pods are running.They are running on two nodes.They consume city resource.On this cluster,I deploy a distributed storage system,look and safe.I already have deployed them because it takes too long.There are many pods running for look and safe, including non-operator,manager,monitors,and so on.Possessive volumes are assigned for OSD pods.I requested five persistent volumes through five pods and five claims.Five OSD pods and five PVCs.Well,let's see where the OSD pods are running along with where the computing pods are.Five OSD pods and two computing pods.As you can see,five OSD pods are distributed only to three nodes,although there are four available nodes.It seems that the OSD pods avoided to coexist with the computing pods.This is because kube scheduler put a higher priority on flattening CPU resource usage.This is not desirable for distributed storage system.Now let's move into another environment.The tune kube scheduler is running here.Let's see where the OSD pods are running along with where the computing pods are.Five OSD pods and two computing pods.Five OSD pods are distributed well onto four nodes.Some of them coexist with the computing pods.This is what I wanted to do.Let's wrap up with key takeaways.In order to deploy a distributed storage system using Rook and Sep on our on-premise cluster,we translate the problem of local storage distribution into the pod scheduling problem using Word for fast consumer volume binding mode.As for pod scheduling,we use the pod technology spread constraints for better distribution.In order to cope with kube scheduler scoring,we tune it to prioritize the constraints.Our configuration for Rook and Sep is open source in GitHub.Please take a look.That's all.Thank you.


23 January 1-15, 1916, and epilogue January 1. Today is New Year's Day. At this time last year this peninsula was as peaceful a part of the world as one could find in any neutral country, though its rulers were allies of our chief enemies. Today, a year after, we are nearing the fall of the curtain on the final act of one of the greatest tragedies of history. The curtain of the first act was run up on a scene beautiful and romantic in its setting eight months ago, which changed as the play developed to scenes of gallant endeavour and death in all its nakedness. The final act, the tragic last scene of defeat without disgrace, is full of sadness, and the great audience, although held spellbound watching and waiting, will be full of relief when the curtain drops for good. It is strange to think, as I walk about once more on W. Beach, that Souvla and Anzac no longer harbor British ships or house British troops, and that Turks now walk unmolested in our late trenches and shelter themselves at night in our late dugouts. In a few days now Turks will be sitting in the place in which I am writing these notes. They are welcome, for our attempts to open their gates have failed. We have lost the game, but we have not been beaten by the Turks. They are no match for our troops. We have been beaten by nature or the geographical fastness of this impregnable peninsula and the storms of winter. The New Year is heralded in on W. Beach by the shells of a big howitzer on the left shoulder of Achibaba, bursting with a deafening crash on the high ground of the beach, throwing large jagged splinters within a radius of two hundred yards. When such a shell bursts, all within that radius drop flat to earth or dive into a dugout. I am sure that people living further inland or in the trenches, if they have not lived on the beach, do not realize the great strain on the nerves that work under steady, effective shellfire is on this beach, cooped up as we are in such a small space, which is all a target, not to say the chief target of the Turkish gunners. The 29th Army Service Corps men are sticking it well. I think they guess that we are evacuating and are therefore cheery. Issuing by day, as in the early days, is now out of the question. We issue a dusk and even then in danger of a shell in our depot. But the Army Service Corps, or the Army Safety Corps as it is turned by many in France, must never cease doing its job, for a man in the front line is hungry three times a day. As senior supply officer, my job now is to see that the four supply officers' indents are satisfied in full, namely the supply officers of the 86th, 87th, 88th brigades, and the divisional artillery. I must get the food ready at our depot for the night's issue for each group, out of which the four service officers must see that their troops and animals get their full ration. Their respective jobs are far more trying than is mine now, for the difficulties of getting the supplies from the beach to the troops have increased a hundredfold. The main supply depot is still in the same spot as in the days of May, and there they must see that my indents are satisfied. Now they are drawing on their reserve, and as in the case of the evacuation of Suvla, they are issuing from the inside of the large stacks of supplies. For to the Turk, these stacks must not appear to grow smaller. The outside walls must be kept standing, and when the time comes the depot officers will set them ablaze with hay and petrol, and long before the Turk can reach the beaches they should be raging furnaces. The main supply depot office is still in the same place as of old, built out of supply boxes, several times it has been blown down by a Turkish shell, and why it has not been shifted I cannot think. More shells are bursting daily round this depot during these days than burst in a week of June on the whole of W. Beach. If the Turks then had half the artillery they have now, I do not think that we would be here today. Smart the depot supply officer who was wounded in August and who is now back sitting in the same old place holds up his ruler to me this morning, the same ruler which was the stakes of the bet I had with him in the early days, that Archibaba would be taken by June 30th, and says with a smile, this ruler is still mine, and Archibaba still belongs to Turkey. Outside, Archibaba looks more forbidding than ever, like the head of a huge vulture waiting to spring. Howitzer shells are dropping along the road, and as I want to go up to the 86th and 88th Brigade Headquarters with Horn, we go along the cliff's edge by the Greek camp, still in the same place. The two Brigade Headquarters are in a delightful spot, dug in on the side of the cliff just this side of X Beach. I have a chat with General Williams and Sinclair Thompson. I enjoy going there. It is absolutely off the target, though as things are now one would think that there could be no spot on this tiny tip of land where one could live at all for long. Back for lunch. At three o'clock we are shelled badly in our quarter by Howitzer's from the hill and by Asia's quick dick, which is on you before you can duck, almost. General Birdwood has been here and had to look round, as before mentioned the 29th are to be last. It is rather a lot to ask of the 86th and 88th after that storm and the strain of one evacuation, but it shows General Headquarters put a great value on us. Up to midnight I am at the main supply depot, drawing the remainder of reserve supplies for six days for the division, which are being put up in Leithwalk and Clapham Junction, respectively, for the 87th and 88th Brigades. As in the case of the evacuation at Suvla, the 86th Brigade leaves shortly. Officers and men on W. Beach are falling sick fast, with the continual strain of shelling, and in view of the evacuation are being sent off at once. There are one or two cases of men losing their reason. January 2nd. The sea was very rough last night, and in consequence the evacuation was very much delayed. We are now being subjected to very severe shelling. From three o'clock yesterday to nine o'clock this morning, three howitzers, two from behind Chrithia, and one on the right shoulder of Achie, have been throwing big, high explosive shells over to us on the beaches, steadily. This is the severest spell on record, and it is evident that they are expecting us to go soon and are making it as hard as possible. Afterwards we were shelled in jerks to midday. At seven o'clock tonight Horn and I go up to Chrithia and Nulla, or Clapham Junction. It is very dark, and the road is pockmarked with shell holes. I miss the familiar landmark of the White Pillars. I remember now that they told me while I was at Suvla that they had been demolished by our engineers. We have a forward reserve dump at Clapham Junction, which we start eating into tomorrow. 88th Brigade headquarters is just nearby, dug in, in trenches, and on calling there we are invited to dinner. We have a Christmas pudding which is brought in, a light with brandy. It seems strange following this old custom in a dugout, with bullets zipping over outside, and within eight hundred yards of the turks. Coming out of the dugout onto the road I notice bullets flying about much freer than usual, the turks being more energetic over their practice of firing their rifles at night than they ever were before. All the time as we walk back we hear the Turkish howitzers sending over their consignment of high explosives to W. Beach. After ten minutes walk we hear a shell coming, bang at us, firing at a battery close by, but it is a small dud and it goes foot into the ground. As we approach nearer and nearer to W. Beach we hear their howls whining away overhead. They sound so harmless and seem to take quite a time sailing through the air, but the sound of them crashing on the beach rather inclines us to slacken our pace. On arriving the main supply depot, however, we quicken our pace and, passing through it, arrive at the wood stacks when we hear one of their whiners sailing over. Quickly we duck behind the wood as it bursts short of the supply depot. We get up and walk briskly to our dugout, and just as we descend the steps on the cliffside we hear another. We dive into Hislop's dugout precipitously as it bursts with a crash forty yards behind us.  Bed and we go to sleep hearing the shells explode in various parts of the beach at short intervals. Fortunately these shells do not reach the water's edge and cannot impede the final stage of the evacuation. It is only Asia that upsets this. January 3rd. Some of the staff of the main supply depot have now left. Last night some animals, including the army transport cart mules were evacuated. They are lead, coaxed, and whipped on to the lighters from the piers. The lighters are then towed out to the waiting ships, which have come in under the cover of darkness, and the animals are slung on board. It is strenuous work for those detailed for the job, especially with a heavy swell. The personnel are sent off from the beach and they do not waste time hanging about the open spaces of the beach, but make for the cover of the river Clyde and the fort as soon as possible. The man with the trumpet is kept busy giving warning against Asia's shells. Weekly men are being hurried off. Surplus kit, office records also. Forward reserves of ammunition are being placed in the Eski lines, which run across the peninsula, and each man and machine gun has a reserve of small ammunition. Also a reserve is kept on the beaches. On the last day our division will have about three thousand men left. We start eating into our seven days forward reserves today. The Egyptian shepherds who provided meat for the drabbies of the mule corps with their sheep have left today. The casualties from shellfire are becoming more and more frequent on the beaches now. The eighty-sixth brigade leave tonight, and the balance of those men who were prevented from getting off by the rough sea of last night. In fact, many men had to leave by daylight this morning, risking the Turks' observation. The French try a very clever ruse by lighting a stack of hay, which, smoldering only, causes heavy columns of smoke to drift over Seidel Bar and away out over the straits, which enables them to ship quite a lot of animals under its screen in broad daylight. Enemy aeroplanes are busy trying to get over to the beaches all day, but are successfully kept at bay by our anti-aircraft guns and aeroplane patrols. A strong wind is blowing from the northeast, and it looks like a change in the weather, causing anxiety to us all. As usual, all to-day and continuing tonight, the beaches and their approaches have been heavily shelled. Our monitors have been energetically replying. January 4. This morning we have intermittent shelling in twos and threes and in fits and starts. Just before lunch, while standing at the door of our dugout on the top of the cliff, I see a destroyer come right in shore, and swinging round quickly, she anchors. I see a group of naval and military officers on deck, who climb down the companion into a penis, which takes them to number one pier. I turn my glasses on to them, and see that the party consists of General Birdwood, the army commander, and Admiral, two naval and two army officers. They slowly walk along the pier, and I cannot help feeling anxious for them, for Asia has put one of her beauties close to number one pier a short while before. They turn to the left and walk along the road at the foot of the cliffs. Just as they are passing immediately beneath our bivvy, two Howitzer shells burst with a deafening report on the beach. General Birdwood never turns his head, but I notice that the two other officers following behind look anxiously over their shoulders. They go up to eighth core headquarters, and after lunch a conference is held. Afterwards, General Birdwood sends over to the Mulecart core on the high ground between W and V Beach, for an old native officer whom he has known for many years in India. He is a fine old man, and a splendid type of the loyal native soldier. Of course he was overcome with delight at meeting the general once more, who told him to assure all the native drivers and their non-commissioned officers with the MuleCore that our evacuation was a strategical move made for the best, and not in any way to be interpreted as a disaster. The native mind is so different from our own, and though they are as loyal as any of our troops, one feels anxious to prevent them from losing their confidence. As a result of the conference, the progress of the stages of the evacuation must be speeded up. Personnel and animals must at all costs be dealt with first, and as the sands are running low, it will now be necessary to begin evacuating animals by day and risk the shelling. This morning the sea has been dead calm and perfect for our purpose, but the navies say that they expect a southerly gale. We, of course, dread a southerly gale. It is a very trying and anxious time, and the shelling is now almost continuous. Certainly only a few guns are turned onto the beaches, but sufficient to upset and impede our work. Six shells may come over from the Howitzers on Achi at ten, three from Asia at eleven, four from Achi at eleven thirty, then from twelve to one, probably twenty from Achi and Asia, all onto the camps and depots in the confined space of W. Beach. All the while casualties occur. As a contrast, the evacuations of Suvla and Anzac were child's play to that of Hellas. The monitors are busy replying, and I think cause their guns to stop now and again. All the afternoon the beach gets shelled. Asia now and again puts some very nasty ones over near our Bivouac, and once we all had to take cover in two tunnels in the side of the cliff to our left, where they have been quarrying for stone. At eight p.m. a gale springs up, and the embarkation is greatly hampered. They found it impossible to embark the mules on the transport when the lighters arrived alongside. One lighter, loaded with mules, carts, and drivers, breaks away and quickly goes drifting out to sea towards Asia, becoming lost in the darkness of the night. All night we get shelled every quarter of an hour. January 5. It is very windy and the sea rough, yet the evacuation of animals proceeds by day as well as by night, regardless of whether we are seen or not. But a large number of animals will, I am afraid, have to be left, and in consequence will be killed on the last day. I do not know which day Z-day is, but I hear that it has been postponed in consequence of the rough sea. The shelling is as bad as ever on the beaches. Now, in addition to guns on Achi and on the Asiatic side opposite Morto Bay, a four-gun Turkish battery comes into position by Khamkali and manages to reach the water's edge of W-beach and V-beach with Shrapnel. But a monitor quickly getting onto it very soon silences it. No enemy gun can ever be in position on this point for long. Asia gives us a bad time in the afternoon, and puts some nasty ones near our Bivouac, and again we have to take refuge in the tunnel. Monitors are busy bombarding Achi and a cruiser with an airplane up, spotting for her, his hard at work trying to find the Asiatic gun. Enemy airplanes as usual make persevering endeavors to come over W-beach, but each time are driven off by our airmen. Our anti-aircraft guns never hit anything. The enemy aircraft now try to fly over W-beach by approaching it from the sea, and many an exciting chase and duel is daily witnessed between our planes and theirs, ours always holding mastery of the air. The sea is getting calmer, and at night an odd shell comes over at intervals of half an hour or so. The lighter loaded with the mules and their drivers, which broke a drift yesterday owing to the rough sea, drifted fortunately onto rabbit islands, and her freight was picked up by a monitor. January 6. A lovely calm morning. The shelling has quieted down considerably. I think the monitors have been frightening the Turkish gunners somewhat. Also Asia is not worrying us, thank God, and yesterday's bombardment from the cruiser has probably done a lot of good. The sea is like glass, and the conditions are perfect for evacuation. The same policy is being followed in getting the last troops off on z-night, as was followed at Suvla, but quantities of material, ordinance, and Royal Engineer's stores will have to be left. The reserve ammunition in the keeps on the beaches on the last night will be blown up just before we leave. Enemy airplanes are over in the morning, showing great daring and keeping our airmen very busy. The beaches are crowded with mules, wagons, and fatigue parties, hard at work at loading the lighters. There is no attempt at concealing what we are doing, but the Turk does not know which night is our last, and if we can manage to keep him in ignorance, then we can get off the last night without a rear-guard action being fought, for John Turk does not like leaping over the top. Our monitors, destroyers, and two cruisers keep the Turkish artillery much quieter than they were a few days ago, though at intervals they give us a very bad time on the beaches.  Only myself, the adjutant, and one or two other officers, and a handful of men are left to stand by, in case the last day is delayed, and troops require food. At present all on shore are rationed up to next Tuesday night. All the Greeks have left. January 7. It is another beautiful morning, and the wind is in the northeast. We had some rain in the night, and in consequence the ground is rather muddy. All transport is now under the control of the Eighth Core Transport Depot. The shooting of those animals, which it will not be possible to get off tonight, will be begun and finished off tomorrow, and all vehicles left will be destroyed. This morning I walk up with Hislop to Division headquarters. As we pass the stationery hospital, we see a cluster of mules wandering about, grazing on the scanty grass that is still growing in odd patches on the plateau. We hear the whistle of a shell, which proves a very small one and a dud, and which falls in the middle of them with a foot.  Soon after another follows, also a dud. Evidently the Turkish gunner who has fired is a sportsman, and has made a bet with another that he will get a bullseye first shot. Soon after we hear the whine overhead of the Howitzer shells, traveling seemingly to W. Beach, fired in grim earnest, and not as a sporting shot, like the two duds at the mules. Looking at the gunnery from the Turkish gunner's point of view, it must have been all through this campaign a sort of series of field days for them, with their guns in position on commanding heights, and with the targets nearly always open sights and on the lowlands. It is fortunate for us that only lately they have been receiving regular supplies of good ammunition. If they had had the artillery that the Germans had before Ypres, 24 hours on any single day throughout the eight months that we have been here would have turned the campaign in favor of Turkey, and meant utter defeat and unconditional surrender for us, as we are therefore at the end of it all, and shall soon once more hand back to Turkey the remaining insignificant few acres of ground that we had captured and held after so much gallantry, endurance, and bloodshed, we must be thankful and congratulate ourselves that we are disentangled from the quagmire with our army intact. I may have spoken too soon, but if we are as fortunate as we were at Suvla, we can disappear in a night, although the enemy knows we are going. We expect him to attack shortly to test our strength. If we hold him and inflict losses on him, that will keep him quiet for a day or so. During these days we have our great chance to evacuate without loss, and with our army intact. We get very busily shelled in the afternoon, several from Asia bursting within a few yards of our office, and one actually at the mouth of the tunnel which was crowded with men taking cover. While this is going on, the enemy make a concentrated bombardment on a part of our front line held by the Thirteenth Division and a part of the Eighty-Seventh Brigade. It lasts continuously from 3.30 p.m. to 5.30 p.m. and caused about a hundred and fifty casualties. At the end they made half-hearted attempts to leave their trenches to attack ours, but the few small parties that had the bravery to get out into no man's land were stopped dead by our machine-gun fire, and the show petered out. Now therefore is our chance, either to night or to-morrow. This afternoon's attack was probably made to test our strength, and as they suffered as much as we did, if not more, they will pause a while before attacking again. After this attack finished, the shelling on the beaches almost entirely ceased, and when night fell I was able in peace to start a job which proved very tedious, namely of putting operations, ammunition, and water in petrol cans into a dugout on W. Beach, where it would be useful in case of a rearguard action. The filling of the petrol cans is the tedious part of the job, the cans having to be let down by rope into the reservoir, which lies twenty yards from our dugout on the top of the cliff. While I am in the middle of this job, an order from Eight Corps Headquarters comes that I am to leave with all the Army Service Corps details tonight. As I have already received an order from Division Headquarters to go off to-morrow night, I reply that I am sending the men with remaining officers and am going with Division Headquarters to-morrow. I get two gallons of water, some bully, biscuits and cheese put in my dugout. I send all my kit off with my servant, who places some hay on the floor for my bed for this, my last, night, and go back to finish the job I am on. Tomorrow will be monotonous waiting for the evening with nothing to do, but I have a good book to read and plenty of tobacco, and the day will soon pass. I am to go off at six p.m. At ten p.m. a written order comes down from Eight Corps that I am to go off tonight with the others, for tomorrow is z-night, and the beaches must be cleared as far as possible of noncombatant details. I go to Eight Corps Signals and Telephone Division Headquarters, who say I can go. I finish the job of putting the water in cans in the keep at twelve midnight and go back to my dugout. All have left except five men. Two of them landed with me on W. Beach on the first day. January 8. It is now the beginning of z-day, and we three stand on W. Beach, waiting orders to go on number one pier. As we stand in the heavy sand, my thoughts immediately go back to the night of April 25, where in the same place as I am now standing we were laboring carrying boxes of supplies up the beach. I feel as if I have gone round in a complete circle. This is what has happened with the Gallipoli Campaign. It has indeed gone round in a complete circle. The beaches alive with troops and animals are being feverishly embarked. About two hundred have been shot tonight, though, and some men actually cried as they performed that horrid task. Fortunately there is little shelling. One now and again bursts on the high ground of the beach. A military landing officer comes along the pier and instructs us to file along on board. We pass up the pier, up a gangway, over one of the sunken ships, and onto a small ship moored on the further side. The five non-commissioned officers go to their quarters, and I go to the ward room, where my name and particulars of my command, strength numbering five, are taken. And then I have a whiskey and soda and a cigar. Phew! The relief. W. Beach, the last few weeks. Let's forget about it. 2.30 am. The ship is now nearly full up with troops, and an officer comes in to say we are off. I go up on deck and find that they are just weighing anchor. It is tricky work getting a ship away from improvised piers. The captain is the same naval officer who used to command the Whitby Abbey, which took me to Lemnos and back in July last. Tomorrow night will be his last trip to Gallipoli. At last, after a lot of maneuvering, he shouts from the bridge, all clear aft, and a voice answers, I, I, sir, then full steam ahead, and we swing round and head out to sea. I watch the lights on shore gradually disappear, one I notice by eighth-core headquarters being at the top of a post flickers out and on as regularly as the ticking of a clock. What it means I don't know. I have noticed it before during the past few days. Asia fires to V. Beach, and Achi sends a couple which burst on the high ground at the back of W. Beach. The lights and the outskirts of the shore disappear. I still see the starlight sailing in the darkness of the night. These soon disappear. For me, the adventures of Gallipoli are no longer realities, but bad memories, and I turn into the wardroom to sleep. 8 a.m. We enter Mudos Harbor, chock full of warships and transports, those on board leaning over the side and marching us with interest. Eight and a half months have passed since those days in April before the landing, and the scenes are almost the same today. It seems eight and a half years ago. I go ashore and meet a friend at one of the supply depots who makes me a guest of the mess. We have a cheery evening. January 9. We hear the good news that the evacuation went off splendidly. It was a perfect day. The beaches were shelled as usual at intervals by day, but our monitors, destroyers, and two cruisers kept their fire under. The Turks apparently appeared to have expended their energies on the seventh and kept quiet. The program followed at Suvala was followed at Helis. At 6 p.m. the final stage of getting the men off was started, and they were rapidly shipped immediately as they arrived at the forming of posts. The beaches were shelled fitfully, and casualties in consequence occurred, but they can only be put down as normal casualties, which have been daily occurring through the enemy artillery activity. The last parties in the line were got away by the same procedure as was followed at Suvala, passing down the roads, their passage being telephoned to the beaches by the officers on duty at the gates. So well managed was it, that it was found possible to get many troops off in advance of the scheduled time of departure. Division headquarters embarked by motor launch on to the HMS Prince George, an enemy submarine was about, and discharged a torpedo at the Prince George, but by wonderful luck it failed to explode, but shook the ship from bow to stern. At 2.30 a.m. all men had gone, only animals were left and vehicles, and I think some animals were left to fall into the Turks' hands alive. January 10. Go on board the Scotian with division headquarters, 29th Division, and part of the 29th Division. January 11. Leave Mudros Harbor at 8. They find and comfortable boat, troops in good spirits, boat-drill at 10.30 a.m., submarine look out all round ship, boat-drill at 4.00 p.m., three spy prisoners on board, two Greeks and one other, one Greek sitting in corner of deck telling his beads all the time, the others walk up and down looking very serious. Serious cases and things look very black for them. January 12. Beautiful day, zigzagging a lot to avoid submarines, doing fifteen knots, steer cast in mourning towards Palestine, afternoon head for Alexandria with a zigzagging course. January 13. Arrive Alexandria Harbor at 6 o'clock in the morning, Arabs come on board and sell papers, have a curiously delightful feeling of homecoming. Alexandria seems just like home now after all those months in Gallipoli, harbor full of troop ships, go into the town in the afternoon, delightful walking about the shops and civilization again, send cable home, back on ship again for dinner. 8.30 p.m., embark on troop train, cattle trucks mostly, I sleep with Grant and Firth divisional signal officer in luggage van, damned uncomfortable journey. January 14. We arrive at a junction at 9 a.m. and hear that an engine is off the line at the next station, broken down dirty Arab village just opposite and an oasis, nothing else but sandy desert. Wait all day and have to wire for rations. New Zealand Army Service Corps comes to our rescue with supplies. Issue same to troops on our train and also to another troop train behind us with troops on board from Ypres. Troops amuse themselves with football in the afternoon, much to the native's interest. Arab boys now and again join in, causing amusement. 8 o'clock in the evening we get up a smoking concert on the side of the line. I have been to some curious smoking concerts during the war, but this one, now on, will live in my memory. Desert, moonlight, troop trains lit up, a bit of a fire, and around, Tommy's fresh from Gallipoli enjoying the fun to the full. What a nation! We never had a chance at Gallipoli. Let's forget about it. 10 p.m. God save the king's song and then off to bed. January 15. Woke up at 12 midnight. Ration train arrives with rations for tomorrow in case we cannot get on. 2 a.m. Train ordered to move. Get up and load rations on to the train. Arrive Suez, 10 a.m., and go on to new camp. For last hour I did a bit of stoking on engine. Rather unique stoking an engine in an Egyptian desert. Arrive at large camp, the largest that I have ever been into. Tents everywhere laid out in perfect order. Coolies, Arabs, and Hindus unloading stores from trains, which arrive at frequent intervals on the single line running through the camp. Epilogue, January 20. Finds me in camp with a tent to myself and things working smoothly. Everything, as far as humanly possible, is ready for any eventuality. And the Turk, if he tries any tricks, will get his knuckles badly wrapped. The King's Own Scottish borders go by to the wild, inspiring strains of the pipes. Everything is bustle. Trained shunting, stores coming up, horsemen and guns moving into position. And there is an air of expectancy over everything. And so these random notes come to an end. I am back in camp with the horrors of the peninsula left behind me forever. Of those who sailed from England so lightheartedly in March, few are left, but those that remain are attached to each other by invisible fetters. Those strange months, dull and exciting, tragic and numerous, spent under the eye of the enemy on an alien shore, form a common bond between us. All of us now know the full meaning of life, and all of us have walked, not once, but many times, with death on the grim peninsula. We have been beaten, not so much by the enemy as by climatic and geographical conditions. But, beaten we are, and nothing remains but to accept defeat like sportsmen.