问:
How to make a grid of scaled images match the height of its div sibling?
I'm trying to create a grid composed of a variable number of images, and I want that grid be the same height as its sibling. But it seems like, from all the examples I've seen online, you have to hardcode pixel values for the images. I don't want to do that. In the following example, I just want the images to be arranged in a 3x3 grid that is the exact same height as the div next to it. Does anyone know a way to accomplish this?

.wrapper {
  display: flex;
}

.data table {
  border-collapse: collapse;
}

.data table td {
  border: 1px solid #000;
  height: 100%;
}

.img-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: 100%;
}

img {
  height: 100%;
  width: 100%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><html>

<body>
  <div class="wrapper">
    <div class="data">
      <p>information</p>
      <p>more information</p>
      <table>
        <tbody>
          <tr>
            <td>Field1</td>
            <td>banana</td>
          </tr>
          <tr>
            <td>Field2</td>
            <td>apple</td>
          </tr>
          <tr>
            <td>Field3</td>
            <td>pear</td>
          </tr>
          <tr>
            <td>Field4</td>
            <td>mango</td>
          </tr>
        </tbody>
      </table>
    </div>
    <div class="img-grid">
      <img src="https://cdn.travelpulse.com/images/d3a9edf4-a957-df11-b491-006073e71405/e864929d-127a-4caf-9a15-7f9cd45160f0/630x355.jpg" class="">
      <img src="https://cdn.travelpulse.com/images/d3a9edf4-a957-df11-b491-006073e71405/e864929d-127a-4caf-9a15-7f9cd45160f0/630x355.jpg">
      <img src="https://cdn.travelpulse.com/images/d3a9edf4-a957-df11-b491-006073e71405/e864929d-127a-4caf-9a15-7f9cd45160f0/630x355.jpg">
      <img src="https://cdn.travelpulse.com/images/d3a9edf4-a957-df11-b491-006073e71405/e864929d-127a-4caf-9a15-7f9cd45160f0/630x355.jpg">
      <img src="https://cdn.travelpulse.com/images/d3a9edf4-a957-df11-b491-006073e71405/e864929d-127a-4caf-9a15-7f9cd45160f0/630x355.jpg">
      <img src="https://cdn.travelpulse.com/images/d3a9edf4-a957-df11-b491-006073e71405/e864929d-127a-4caf-9a15-7f9cd45160f0/630x355.jpg">
      <img src="https://cdn.travelpulse.com/images/d3a9edf4-a957-df11-b491-006073e71405/e864929d-127a-4caf-9a15-7f9cd45160f0/630x355.jpg">
      <img src="https://cdn.travelpulse.com/images/d3a9edf4-a957-df11-b491-006073e71405/e864929d-127a-4caf-9a15-7f9cd45160f0/630x355.jpg">
      <img src="https://cdn.travelpulse.com/images/d3a9edf4-a957-df11-b491-006073e71405/e864929d-127a-4caf-9a15-7f9cd45160f0/630x355.jpg"></div>
  </div>
</body>

</html></code>```

EDIT: original example code wasn't a good representation of the issue, so I updated it.

Also, I should point out, that if you run the code snippet in a small enough window, it may look like it's working, but if you open it in fullscreen, it will be clear that it does not work.

Body:
I'm trying to create a grid composed of a variable number of images, and I want that grid be the same height as its sibling. But it seems like, from all the examples I've seen online, you have to hardcode pixel values for the images. I don't want to do that. In the following example, I just want the images to be arranged in a 3x3 grid that is the exact same height as the div next to it. Does anyone know a way to accomplish this?

.wrapper {
  display: flex;
}

.data table {
  border-collapse: collapse;
}

.data table td {
  border: 1px solid #000;
  height: 100%;
}

.img-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: 100%;
}

img {
  height: 100%;
  width: 100%;
}

information

more information

            Field1
            banana

            Field2
            apple

            Field3
            pear

            Field4
            mango

EDIT: original example code wasn't a good representation of the issue, so I updated it.

Also, I should point out, that if you run the code snippet in a small enough window, it may look like it's working, but if you open it in fullscreen, it will be clear that it does not work.


来源: stackexchange

问:
Isolate composer php packages in vendor to parent folder
I want to create multiple plugins in wordpress and I want each of these plugins have their own composer.json and vendor folder.

But I want to Isolate each of it from other classes in other plugin vendor folder.

I want to do this beacuse each of these plugins may depends on different version of a package.

Directory structure eaxmple:

```<code>--plugins
  --plugin1
    --vendor
      --package A v1.0.0
      --package B v1.0.0
  --plugin2
    --vendor
      --package A v1.2.0
      --package C v1.0.0
  --plugin3
    --vendor
      --package A v1.4.0
      --package D v1.0.0
  --plugin4
    --vendor
      --package A v1.7.0
      --package E v1.0.0
</code>```

So How can I do this and isolate each plugin from others?

ContentLicense: CC BY-SA 4.0

Body:
I want to create multiple plugins in wordpress and I want each of these plugins have their own composer.json and vendor folder.

But I want to Isolate each of it from other classes in other plugin vendor folder.

I want to do this beacuse each of these plugins may depends on different version of a package.

Directory structure eaxmple:

--plugins
  --plugin1
    --vendor
      --package A v1.0.0
      --package B v1.0.0
  --plugin2
    --vendor
      --package A v1.2.0
      --package C v1.0.0
  --plugin3
    --vendor
      --package A v1.4.0
      --package D v1.0.0
  --plugin4
    --vendor
      --package A v1.7.0
      --package E v1.0.0

So How can I do this and isolate each plugin from others?


问:
Java - run an executable from a Java class that can be passed a file from memory instead of the filesystem
I'm currently running an executable from a Java class that takes a configuration file as one of it's parameters.

The code, which is working, looks like this:

```<code>String[] params = new String[3];

params[0] = "myProgram.exe";
params[1] = "--cf";
params[2] = "myConfiguration.cf";

Process p = Runtime.getRuntime().exec(params);

BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));

String line;
while ((line = input.readLine()) != null) {
    System.out.println(line);
}

input.close();
</code>```

For security purposes, I'd like to create the configuration file inside the Java class, and provide it to the runtime as an in-memory stream instead of an external file.

Is this possible? I don't have control over the executables code, so I'm not clear if there's a way to make it see the filename as anything different than a file that it has to retrieve from disk.

Body:
I'm currently running an executable from a Java class that takes a configuration file as one of it's parameters.

The code, which is working, looks like this:

String[] params = new String[3];

params[0] = "myProgram.exe";
params[1] = "--cf";
params[2] = "myConfiguration.cf";

Process p = Runtime.getRuntime().exec(params);

BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));

String line;
while ((line = input.readLine()) != null) {
    System.out.println(line);
}

input.close();

For security purposes, I'd like to create the configuration file inside the Java class, and provide it to the runtime as an in-memory stream instead of an external file.

Is this possible? I don't have control over the executables code, so I'm not clear if there's a way to make it see the filename as anything different than a file that it has to retrieve from disk.


问:
Not loading or late loading of photos in V-for
```<code><template>
<table>
  <tr v-for="row in rowCount">
    <td v-for="col in colCount">
      <img :src="'https://picsum.photos/id/'+colCount+'/200/300'" />
    </td>
  </tr>
</table>
</template>

<script>
  export default {
    data(){
      return{
        rowCount:2,
        colCount:15
      }
    }
  };
</script>

<style scoped>

</style>
</code>```

Hey there,

Normally photos are taken statically with require. But I am giving example from lorem pic. My problem is this: Photos are coming late or not downloading. When i click on another photo the undownloaded downloads and appears on the screen. The item is in the dom, but the photo is not downloaded over the network.

Body:
<template>

</template>

Hey there,

Normally photos are taken statically with require. But I am giving example from lorem pic. My problem is this: Photos are coming late or not downloading. When i click on another photo the undownloaded downloads and appears on the screen. The item is in the dom, but the photo is not downloaded over the network.


问:
Java merge list of objects by common field
given a list of interactions for example where two interactions (ones that contain same interactionId) need to be merged

```<code>"interactions": [
        {
            "interactionId": "1",
            "createdAt": "2017-01-13 14:19:09.99",
            "status": "Resolved-Completed",
            "wrapupReasons": [
                {
                    "type": "Billing",
                    "category": "Billing Process",
                    "reasonCode": "inquiry"
                }
            ]
        },
        {
            "interactionId": "1",
            "createdAt": "2017-01-13 14:19:09.99",
            "status": "Resolved-Completed",
            "wrapupReasons": [
                {
                    "type": "Payment",
                    "category": "Payment Process",
                    "reasonCode": "inquiry"
                }
            ]
        },
{
            "interactionId": "2",
            "createdAt": "2017-01-13 14:19:09.99",
            "status": "Resolved-Completed",
            "wrapupReasons": [
                {
                    "type": "Billing",
                    "category": "Billing Process",
                    "reasonCode": "1035 Processing Inquiry"
                }
            ]
        },
]
</code>```

I would need to combine the common interactionId objects into one like so and have a new list - note that the wrapUpReasons have been concatenated

```<code>        {
            "interactionId": "1",
            "createdAt": "2017-01-13 14:19:09.99",
            "status": "Resolved-Completed",
            "wrapupReasons": [
                {
                    "type": "Payment",
                    "category": "Payment Process",
                    "reasonCode": "inquiry"
                },

{
                    "type": "Billing",
                    "category": "Billing Process",
                    "reasonCode": "1035 Processing Inquiry"
                }
            ]
        },
{
            "interactionId": "2",
            "createdAt": "2017-01-13 14:19:09.99",
            "status": "Resolved-Completed",
            "wrapupReasons": [
                {
                    "type": "Billing",
                    "category": "Billing Process",
                    "reasonCode": "rocessing Inquiry"
                }
            ]
        },
]
</code>```

so far i have tried grouping by the interaction and then trying to combine the HashMap key that contains 1 or more InteractionHistory list but the union list is not merging the list of objects

```<code>Map<Object, List<InteractionHistory>> interactionGrouped =
                interactionHistoryList.stream().collect(Collectors.groupingBy(interaction -> interaction.getInteractionId()));

        for (Map.Entry<Object, List<InteractionHistory>> mapElement : interactionGrouped.entrySet()) {
            List<InteractionHistory> union = new ArrayList<>();
            List<InteractionHistory> interactionHistoryList1 = mapElement.getValue();
            union.addAll(interactionHistoryList1);
        }
</code>```

Body:
given a list of interactions for example where two interactions (ones that contain same interactionId) need to be merged

"interactions": [
        {
            "interactionId": "1",
            "createdAt": "2017-01-13 14:19:09.99",
            "status": "Resolved-Completed",
            "wrapupReasons": [
                {
                    "type": "Billing",
                    "category": "Billing Process",
                    "reasonCode": "inquiry"
                }
            ]
        },
        {
            "interactionId": "1",
            "createdAt": "2017-01-13 14:19:09.99",
            "status": "Resolved-Completed",
            "wrapupReasons": [
                {
                    "type": "Payment",
                    "category": "Payment Process",
                    "reasonCode": "inquiry"
                }
            ]
        },
{
            "interactionId": "2",
            "createdAt": "2017-01-13 14:19:09.99",
            "status": "Resolved-Completed",
            "wrapupReasons": [
                {
                    "type": "Billing",
                    "category": "Billing Process",
                    "reasonCode": "1035 Processing Inquiry"
                }
            ]
        },
]

I would need to combine the common interactionId objects into one like so and have a new list - note that the wrapUpReasons have been concatenated

        {
            "interactionId": "1",
            "createdAt": "2017-01-13 14:19:09.99",
            "status": "Resolved-Completed",
            "wrapupReasons": [
                {
                    "type": "Payment",
                    "category": "Payment Process",
                    "reasonCode": "inquiry"
                },

{
                    "type": "Billing",
                    "category": "Billing Process",
                    "reasonCode": "1035 Processing Inquiry"
                }
            ]
        },
{
            "interactionId": "2",
            "createdAt": "2017-01-13 14:19:09.99",
            "status": "Resolved-Completed",
            "wrapupReasons": [
                {
                    "type": "Billing",
                    "category": "Billing Process",
                    "reasonCode": "rocessing Inquiry"
                }
            ]
        },
]

so far i have tried grouping by the interaction and then trying to combine the HashMap key that contains 1 or more InteractionHistory list but the union list is not merging the list of objects

Map<Object, List<InteractionHistory>> interactionGrouped =
                interactionHistoryList.stream().collect(Collectors.groupingBy(interaction -> interaction.getInteractionId()));

        for (Map.Entry<Object, List<InteractionHistory>> mapElement : interactionGrouped.entrySet()) {
            List<InteractionHistory> union = new ArrayList<>();
            List<InteractionHistory> interactionHistoryList1 = mapElement.getValue();
            union.addAll(interactionHistoryList1);
        }


问:
how to convert my append() code into a concat code with Pandas?
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Exit':
break

```<code>if event == 'Clear':
    clear_input()
if  event == 'Submit':
    print(event , values)
    df = df.append(values, ignore_index=True)
    df.to_excel(EXCEL_FILE_1, index=False)
    sg.popup('Data saved!')
    clear_input()
</code>```

window.close()

Whatever I've tried to do with concat() I just get an error

Body:
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Exit':
break

if event == 'Clear':
    clear_input()
if  event == 'Submit':
    print(event , values)
    df = df.append(values, ignore_index=True)
    df.to_excel(EXCEL_FILE_1, index=False)
    sg.popup('Data saved!')
    clear_input()

window.close()

Whatever I've tried to do with concat() I just get an error


问:
New VSIX project in VS2022 has XAML binding failures

First time create a VS extension [VSIX] project in VS2022.

I do not know what is cause of problems below. I do everything like in doc.

I tried to run a simple VSIX project hello world in VS 2022 like in doc: https://learn.microsoft.com/en-us/visualstudio/extensibility/extensibility-hello-world?view=vs-2022

Step 1.
Right-click the project (not the solution). On the context menu, select Add, and then New Item.

Step 2.
Select the Extensibility section, and then choose Command.

Step 3.
Press F5 to debug, check the XAML binding failures:

```<code>using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.ComponentModel.Design;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using Task = System.Threading.Tasks.Task;

namespace VSIXProject2 {
internal sealed class Command1 {
 public
 const int CommandId = 0x0100;

 public static readonly Guid CommandSet = new Guid("f83fb9b7-23b6-4605-bc93-74df2c22ec53");

 private readonly AsyncPackage package;

 private Command1(AsyncPackage package, OleMenuCommandService commandService) {
   this.package = package ??
     throw new ArgumentNullException(nameof(package));
   commandService = commandService ??
     throw new ArgumentNullException(nameof(commandService));

   var menuCommandID = new CommandID(CommandSet, CommandId);
   var menuItem = new MenuCommand(this.Execute, menuCommandID);
   commandService.AddCommand(menuItem);
 }

 public static Command1 Instance {
   get;
   private set;
 }

 private Microsoft.VisualStudio.Shell.IAsyncServiceProvider ServiceProvider {
   get {
     return this.package;
   }
 }

 public static async Task InitializeAsync(AsyncPackage package) {
   await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);

   OleMenuCommandService commandService = await package.GetServiceAsync(typeof (IMenuCommandService)) as OleMenuCommandService;
   Instance = new Command1(package, commandService);
 }

 private void Execute(object sender, EventArgs e) {
   ThreadHelper.ThrowIfNotOnUIThread();
   string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName);
   string title = "Command1";

   VsShellUtilities.ShowMessageBox(
     this.package,
     message,
     title,
     OLEMSGICON.OLEMSGICON_INFO,
     OLEMSGBUTTON.OLEMSGBUTTON_OK,
     OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
 }
}
}
</code>```

System.Windows.Data Error: 17 : Cannot get 'CurrentState' value (type 'Int32') from '' (type 'PolicyBasedDataSource'). BindingExpression:Path=CurrentState; DataItem='PolicyBasedDataSource' (HashCode=8713795); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='' BindingExpression:Path=ToolTip; DataItem='GlyphButton' (Name='MaximizeButton'); target element is 'GlyphButton' (Name='MaximizeButton'); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='' BindingExpression:Path=ToolTip; DataItem='GlyphButton' (Name='CloseButton'); target element is 'GlyphButton' (Name='CloseButton'); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='' BindingExpression:Path=Content; DataItem='Button' (Name=''); target element is 'Button' (Name=''); target property is 'Name' (type 'String') System.Windows.Data Error: 40 : BindingExpression path error: 'Text' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=Text; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'Name' (type 'String') System.Windows.Data Error: 40 : BindingExpression path error: 'Items' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=Items; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'ItemsSource' (type 'IEnumerable') System.Windows.Data Error: 40 : BindingExpression path error: 'PlacementSlot' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=PlacementSlot; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'Band' (type 'Int32') System.Windows.Data Error: 40 : BindingExpression path error: 'BandIndex' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=BandIndex; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'BandIndex' (type 'Int32') System.Windows.Data Error: 40 : BindingExpression path error: 'IsVisible' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=IsVisible; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'Visibility' (type 'Visibility')

I found similar problem here: https://developercommunity.visualstudio.com/t/new-vsix-project-in-vs2022-has-xaml-binding-failur/1580267?viewtype=solutions

Body:
First time create a VS extension [VSIX] project in VS2022.

I do not know what is cause of problems below. I do everything like in doc.

I tried to run a simple VSIX project hello world in VS 2022 like in doc: https://learn.microsoft.com/en-us/visualstudio/extensibility/extensibility-hello-world?view=vs-2022

Step 1.
Right-click the project (not the solution). On the context menu, select Add, and then New Item.

Step 2.
Select the Extensibility section, and then choose Command.

Step 3.
Press F5 to debug, check the XAML binding failures:

using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.ComponentModel.Design;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using Task = System.Threading.Tasks.Task;

namespace VSIXProject2 {
internal sealed class Command1 {
 public
 const int CommandId = 0x0100;

 public static readonly Guid CommandSet = new Guid("f83fb9b7-23b6-4605-bc93-74df2c22ec53");

 private readonly AsyncPackage package;

 private Command1(AsyncPackage package, OleMenuCommandService commandService) {
   this.package = package ??
     throw new ArgumentNullException(nameof(package));
   commandService = commandService ??
     throw new ArgumentNullException(nameof(commandService));

   var menuCommandID = new CommandID(CommandSet, CommandId);
   var menuItem = new MenuCommand(this.Execute, menuCommandID);
   commandService.AddCommand(menuItem);
 }

 public static Command1 Instance {
   get;
   private set;
 }

 private Microsoft.VisualStudio.Shell.IAsyncServiceProvider ServiceProvider {
   get {
     return this.package;
   }
 }

 public static async Task InitializeAsync(AsyncPackage package) {
   await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);

   OleMenuCommandService commandService = await package.GetServiceAsync(typeof (IMenuCommandService)) as OleMenuCommandService;
   Instance = new Command1(package, commandService);
 }

 private void Execute(object sender, EventArgs e) {
   ThreadHelper.ThrowIfNotOnUIThread();
   string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName);
   string title = "Command1";

   VsShellUtilities.ShowMessageBox(
     this.package,
     message,
     title,
     OLEMSGICON.OLEMSGICON_INFO,
     OLEMSGBUTTON.OLEMSGBUTTON_OK,
     OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
 }
}
}

System.Windows.Data Error: 17 : Cannot get 'CurrentState' value (type 'Int32') from '' (type 'PolicyBasedDataSource'). BindingExpression:Path=CurrentState; DataItem='PolicyBasedDataSource' (HashCode=8713795); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='' BindingExpression:Path=ToolTip; DataItem='GlyphButton' (Name='MaximizeButton'); target element is 'GlyphButton' (Name='MaximizeButton'); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='' BindingExpression:Path=ToolTip; DataItem='GlyphButton' (Name='CloseButton'); target element is 'GlyphButton' (Name='CloseButton'); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='' BindingExpression:Path=Content; DataItem='Button' (Name=''); target element is 'Button' (Name=''); target property is 'Name' (type 'String') System.Windows.Data Error: 40 : BindingExpression path error: 'Text' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=Text; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'Name' (type 'String') System.Windows.Data Error: 40 : BindingExpression path error: 'Items' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=Items; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'ItemsSource' (type 'IEnumerable') System.Windows.Data Error: 40 : BindingExpression path error: 'PlacementSlot' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=PlacementSlot; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'Band' (type 'Int32') System.Windows.Data Error: 40 : BindingExpression path error: 'BandIndex' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=BandIndex; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'BandIndex' (type 'Int32') System.Windows.Data Error: 40 : BindingExpression path error: 'IsVisible' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=IsVisible; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'Visibility' (type 'Visibility')

I found similar problem here: https://developercommunity.visualstudio.com/t/new-vsix-project-in-vs2022-has-xaml-binding-failur/1580267?viewtype=solutions


问:
R: Iterating a string element via loop
I am trying to imbed a for loop, within a while loop, that takes the following date "last_contribution_receipt_date=2016-01-01" and increases the last 01 value by a single integer each time a given condition is met. Once the last_indexes value is null, the loop should move on to the next date.

```<code>while (more_pages) {

  # Create the full API URL by combining the base URL, the "last_indexes" object, and the extra parameters
  API_URL= paste0(base,extra, last_indexes)

  # Retrieve and parse the data for each page
  raw_data <- GET(API_URL)
  stuff <- fromJSON(rawToChar(raw_data$content), flatten = TRUE)

  # Bind the results from each iteration to the empty data frame

  dfs = rbind(dfs, stuff$results)

  # Update the "last_index" value in the "last_indexes" object with the latest value
  last_indexes = stuff[["pagination"]][["last_indexes"]][["last_index"]]
  print(stuff[["pagination"]][["last_indexes"]][["last_index"]])
}
print(API_URL)
</code>```

I tried a for loop but couldn't figure out how to isolate part of the string at the end as opposed to cycling through integers in an array.

Title: R: Iterating a string element via loop

Body:
I am trying to imbed a for loop, within a while loop, that takes the following date "last_contribution_receipt_date=2016-01-01" and increases the last 01 value by a single integer each time a given condition is met. Once the last_indexes value is null, the loop should move on to the next date.

while (more_pages) {

  # Create the full API URL by combining the base URL, the "last_indexes" object, and the extra parameters
  API_URL= paste0(base,extra, last_indexes)

  # Retrieve and parse the data for each page
  raw_data <- GET(API_URL)
  stuff <- fromJSON(rawToChar(raw_data$content), flatten = TRUE)

  # Bind the results from each iteration to the empty data frame

  dfs = rbind(dfs, stuff$results)

  # Update the "last_index" value in the "last_indexes" object with the latest value
  last_indexes = stuff[["pagination"]][["last_indexes"]][["last_index"]]
  print(stuff[["pagination"]][["last_indexes"]][["last_index"]])
}
print(API_URL)

I tried a for loop but couldn't figure out how to isolate part of the string at the end as opposed to cycling through integers in an array.


问:
Fail gitlab pipeline when any of the jobs fail instead of showing ‘Blocked’ status
I have a pipeline which contains some manual jobs.
When one of the preceeding job fails, the status of the pipeline is 'Blocked'. Unfortunately, this is the same status that we expect when everything is fine.

I would like to ensure that any failed job makes the entire pipeline red & failed, so that we don't miss out on problems.
In the particular case, the Deploy step is manual which probably makes the pipeline result Blocked.
However, when Pack stage fails, I want to know it.

In short, the pipeline is as follows (stripped down of irrelevant parts)

```<code>
stages:
  - Build and Test
  - Pack
  - Deploy

Build and Test:
  stage: Build and Test
  script:
    # something

NuGets:
  # something

Service:
  stage: Pack
  needs:
    - job: Build and Test
  #bla bla

.Client:
  stage: Pack
  needs:
    - job: Build and Test
  image: $WINDOWS_IMAGE
  allow_failure: false # FAILURE IS NOT ALLOWED
  script:
    # THIS IS THE STEP THAT SOMETIMES FAILS AND YET THE PIPELINE IS NOT RED

Client DEV:
  extends: .Client
  variables:
  # bla bla
</code>```

Body:
I have a pipeline which contains some manual jobs.
When one of the preceeding job fails, the status of the pipeline is 'Blocked'. Unfortunately, this is the same status that we expect when everything is fine.

I would like to ensure that any failed job makes the entire pipeline red & failed, so that we don't miss out on problems.
In the particular case, the Deploy step is manual which probably makes the pipeline result Blocked.
However, when Pack stage fails, I want to know it.

In short, the pipeline is as follows (stripped down of irrelevant parts)

stages:
  - Build and Test
  - Pack
  - Deploy

Build and Test:
  stage: Build and Test
  script:
    # something

NuGets:
  # something

Service:
  stage: Pack
  needs:
    - job: Build and Test
  #bla bla

.Client:
  stage: Pack
  needs:
    - job: Build and Test
  image: $WINDOWS_IMAGE
  allow_failure: false # FAILURE IS NOT ALLOWED
  script:
    # THIS IS THE STEP THAT SOMETIMES FAILS AND YET THE PIPELINE IS NOT RED

Client DEV:
  extends: .Client
  variables:
  # bla bla


问:
Why is Mockk failing and calling real method when doing coVerify(exactly = 0)
I have recently started programming in Kotlin and for writing unit test I am using Mockk library.

I am stuck at a particular point where Mockk fails while mocking a generic class.
I have a class called KafkaService which looks like this and this is also the class which I am trying to mock

```<code>@Service
class KafkaService<P : Any>(private val kafkaTemplate: KafkaTemplate<String, String>) {

    suspend fun send(topic: String, data: P, headers: MutableMap<String, String?>, key: String? = null): SendResult<String, String>? {
        val message: Message<P> = MessageBuilder
            .withPayload(data)
            .copyHeaders(headers)
            .setHeader(KafkaHeaders.TOPIC, topic)
            .setHeader(KafkaHeaders.KEY, key)
            .build()
        return kafkaTemplate.send(message).join()
    }
}
</code>```

There is another service VendorService which I am trying to test and looks somewhat like this

```<code>@Service
class VendorService(
    private val kafkaService: KafkaService<String>
) : Service {

    override suspend fun handle(flowToken: String, request: request) {
        .
        .
        // Some code which returns before kafkaService.send is called

        kafkaService.send(topic, payload, kafkaHeaders)
        .
        .
    }
</code>```

Since I am testing a scenario for function handle of VendorService, in which handle function returns before calling kafkaService.send(topic, payload, kafkaHeaders)
I am doing this

```<code>@ExtendWith(MockKExtension::class)
class Test {
    @MockK
    lateinit var kafkaService: KafkaService<String>

        @BeforeEach
    fun init() {
        vendorService = VendorService(kafkaService)
    }

   @Test
    fun `test handle - should return before calling kafkaService`() = runBlocking {
        .
        .
        vendorService.handle(uuid, request)
        coVerify(exactly = 0) { kafkaService.send(any(), any(), any()) }
        .
        .
    }
}
</code>```

My test fails at step where I do coVerify, the test goes inside the send function of kafkaService as if it were a real object although I have mocked it and fails with a null pointer exception because KafkaService takes KafkaTemplate<String, String> as dependency but since I am mocking KafkaService, I am not providing the dependency i.e. the dependency is null.

Am I not right in thinking that a mocked object should not call its real method, also I receive some warning logs from Mockk library which might be helpful, also in the end of the stack trace we can see the null pointer exception despite KafkaService being mocked

```<code>WARNING: Failed to transform class service/KafkaService
java.lang.IllegalArgumentException: Cannot resolve P from static java.lang.Object service.KafkaService.send$suspendImpl(?)
    at net.bytebuddy.description.TypeVariableSource$AbstractBase.findExpectedVariable(TypeVariableSource.java:174)
    at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:2062)
    at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
    at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable$Symbolic.accept(TypeDescription.java:5931)
    at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor.onParameterizedType(TypeDescription.java:1908)
    at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onParameterizedType(TypeDescription.java:1973)
    at net.bytebuddy.description.type.TypeDescription$Generic$OfParameterizedType.accept(TypeDescription.java:5134)
    at net.bytebuddy.description.method.ParameterDescription$Latent.getType(ParameterDescription.java:805)
    at net.bytebuddy.description.method.ParameterList$AbstractBase.asTypeList(ParameterList.java:107)
    at net.bytebuddy.description.method.MethodDescription$AbstractBase.hashCode(MethodDescription.java:936)
    at java.base/java.util.HashMap.hash(HashMap.java:338)
    at java.base/java.util.HashMap.put(HashMap.java:610)
    at java.base/java.util.HashSet.add(HashSet.java:221)
    at java.base/java.util.AbstractCollection.addAll(AbstractCollection.java:336)
    at java.base/java.util.HashSet.<init>(HashSet.java:121)
    at net.bytebuddy.dynamic.scaffold.MethodRegistry$Default.prepare(MethodRegistry.java:457)
    at net.bytebuddy.dynamic.scaffold.inline.RedefinitionDynamicTypeBuilder.toTypeWriter(RedefinitionDynamicTypeBuilder.java:203)
    at net.bytebuddy.dynamic.scaffold.inline.AbstractInliningDynamicTypeBuilder.toTypeWriter(AbstractInliningDynamicTypeBuilder.java:122)
    at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$UsingTypeWriter.make(DynamicType.java:4050)
    at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:3734)
    at io.mockk.proxy.jvm.transformation.InliningClassTransformer.transform(InliningClassTransformer.kt:78)
    at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:244)
    at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188)
    at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:541)
    at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
    at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:169)
    at io.mockk.proxy.jvm.transformation.JvmInlineInstrumentation.retransform(JvmInlineInstrumentation.kt:28)
    at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation$execute$1.invoke(RetransformInlineInstrumentation.kt:19)
    at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation$execute$1.invoke(RetransformInlineInstrumentation.kt:16)
    at io.mockk.proxy.common.transformation.ClassTransformationSpecMap.applyTransformation(ClassTransformationSpecMap.kt:41)
    at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation.execute(RetransformInlineInstrumentation.kt:16)
    at io.mockk.proxy.jvm.ProxyMaker.inline(ProxyMaker.kt:88)
    at io.mockk.proxy.jvm.ProxyMaker.proxy(ProxyMaker.kt:30)
    at io.mockk.impl.instantiation.JvmMockFactory.newProxy(JvmMockFactory.kt:34)
    at io.mockk.impl.instantiation.AbstractMockFactory.newProxy$default(AbstractMockFactory.kt:24)
    at io.mockk.impl.instantiation.AbstractMockFactory.mockk(AbstractMockFactory.kt:59)
    at io.mockk.impl.annotations.JvmMockInitializer.assignMockK(JvmMockInitializer.kt:163)
    at io.mockk.impl.annotations.JvmMockInitializer.initMock(JvmMockInitializer.kt:41)
    at io.mockk.impl.annotations.JvmMockInitializer.initAnnotatedMocks(JvmMockInitializer.kt:24)
    at io.mockk.junit5.MockKExtension.postProcessTestInstance(MockKExtension.kt:181)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$10(ClassBasedTestDescriptor.java:377)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:382)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$11(ClassBasedTestDescriptor.java:377)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:376)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$6(ClassBasedTestDescriptor.java:289)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:288)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$4(ClassBasedTestDescriptor.java:278)
    at java.base/java.util.Optional.orElseGet(Optional.java:364)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$5(ClassBasedTestDescriptor.java:277)
    at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:105)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:104)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:68)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:62)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    at jdk.proxy1/jdk.proxy1.$Proxy2.stop(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
    at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
    at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
    at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)

Cannot invoke "org.springframework.kafka.core.KafkaTemplate.send(org.springframework.messaging.Message)" because "$this.kafkaTemplate" is null
java.lang.NullPointerException: Cannot invoke "org.springframework.kafka.core.KafkaTemplate.send(org.springframework.messaging.Message)" because "$this.kafkaTemplate" is null
    at service.KafkaService.send$suspendImpl(KafkaService.kt:20)
    at service.KafkaService.send(KafkaService.kt)
</code>```

Here are Mockk dependencies which I am using

```<code>    testImplementation("com.ninja-squad:springmockk:4.0.0")
    testImplementation("io.mockk:mockk:1.13.3")
</code>```

I am working on a Springboot 3.0.1 project which requires JDK 17.

Please help.

Update

I removed the Parameter P from KafkaService and after that the mockk test started running, also changing the class level parameter P to function level parameter of send worked fine i.e.

```<code>suspend fun <P> send(topic: String, data: P, headers: MutableMap<String, String?>, key: String? = null): SendResult<String, String>?
</code>```

Body:
I have recently started programming in Kotlin and for writing unit test I am using Mockk library.

I am stuck at a particular point where Mockk fails while mocking a generic class.
I have a class called KafkaService which looks like this and this is also the class which I am trying to mock

@Service
class KafkaService
(private val kafkaTemplate: KafkaTemplate<String, String>) {

    suspend fun send(topic: String, data: P, headers: MutableMap<String, String?>, key: String? = null): SendResult<String, String>? {
        val message: Message
 = MessageBuilder
            .withPayload(data)
            .copyHeaders(headers)
            .setHeader(KafkaHeaders.TOPIC, topic)
            .setHeader(KafkaHeaders.KEY, key)
            .build()
        return kafkaTemplate.send(message).join()
    }
}

There is another service VendorService which I am trying to test and looks somewhat like this

@Service
class VendorService(
    private val kafkaService: KafkaService<String>
) : Service {

    override suspend fun handle(flowToken: String, request: request) {
        .
        .
        // Some code which returns before kafkaService.send is called

        kafkaService.send(topic, payload, kafkaHeaders)
        .
        .
    }

Since I am testing a scenario for function handle of VendorService, in which handle function returns before calling kafkaService.send(topic, payload, kafkaHeaders)
I am doing this

@ExtendWith(MockKExtension::class)
class Test {
    @MockK
    lateinit var kafkaService: KafkaService<String>

        @BeforeEach
    fun init() {
        vendorService = VendorService(kafkaService)
    }

   @Test
    fun `test handle - should return before calling kafkaService`() = runBlocking {
        .
        .
        vendorService.handle(uuid, request)
        coVerify(exactly = 0) { kafkaService.send(any(), any(), any()) }
        .
        .
    }
}

My test fails at step where I do coVerify, the test goes inside the send function of kafkaService as if it were a real object although I have mocked it and fails with a null pointer exception because KafkaService takes KafkaTemplate<String, String> as dependency but since I am mocking KafkaService, I am not providing the dependency i.e. the dependency is null.

Am I not right in thinking that a mocked object should not call its real method, also I receive some warning logs from Mockk library which might be helpful, also in the end of the stack trace we can see the null pointer exception despite KafkaService being mocked

WARNING: Failed to transform class service/KafkaService
java.lang.IllegalArgumentException: Cannot resolve P from static java.lang.Object service.KafkaService.send$suspendImpl(?)
    at net.bytebuddy.description.TypeVariableSource$AbstractBase.findExpectedVariable(TypeVariableSource.java:174)
    at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:2062)
    at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
    at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable$Symbolic.accept(TypeDescription.java:5931)
    at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor.onParameterizedType(TypeDescription.java:1908)
    at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onParameterizedType(TypeDescription.java:1973)
    at net.bytebuddy.description.type.TypeDescription$Generic$OfParameterizedType.accept(TypeDescription.java:5134)
    at net.bytebuddy.description.method.ParameterDescription$Latent.getType(ParameterDescription.java:805)
    at net.bytebuddy.description.method.ParameterList$AbstractBase.asTypeList(ParameterList.java:107)
    at net.bytebuddy.description.method.MethodDescription$AbstractBase.hashCode(MethodDescription.java:936)
    at java.base/java.util.HashMap.hash(HashMap.java:338)
    at java.base/java.util.HashMap.put(HashMap.java:610)
    at java.base/java.util.HashSet.add(HashSet.java:221)
    at java.base/java.util.AbstractCollection.addAll(AbstractCollection.java:336)
    at java.base/java.util.HashSet.<init>(HashSet.java:121)
    at net.bytebuddy.dynamic.scaffold.MethodRegistry$Default.prepare(MethodRegistry.java:457)
    at net.bytebuddy.dynamic.scaffold.inline.RedefinitionDynamicTypeBuilder.toTypeWriter(RedefinitionDynamicTypeBuilder.java:203)
    at net.bytebuddy.dynamic.scaffold.inline.AbstractInliningDynamicTypeBuilder.toTypeWriter(AbstractInliningDynamicTypeBuilder.java:122)
    at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$UsingTypeWriter.make(DynamicType.java:4050)
    at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:3734)
    at io.mockk.proxy.jvm.transformation.InliningClassTransformer.transform(InliningClassTransformer.kt:78)
    at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:244)
    at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188)
    at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:541)
    at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
    at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:169)
    at io.mockk.proxy.jvm.transformation.JvmInlineInstrumentation.retransform(JvmInlineInstrumentation.kt:28)
    at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation$execute$1.invoke(RetransformInlineInstrumentation.kt:19)
    at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation$execute$1.invoke(RetransformInlineInstrumentation.kt:16)
    at io.mockk.proxy.common.transformation.ClassTransformationSpecMap.applyTransformation(ClassTransformationSpecMap.kt:41)
    at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation.execute(RetransformInlineInstrumentation.kt:16)
    at io.mockk.proxy.jvm.ProxyMaker.inline(ProxyMaker.kt:88)
    at io.mockk.proxy.jvm.ProxyMaker.proxy(ProxyMaker.kt:30)
    at io.mockk.impl.instantiation.JvmMockFactory.newProxy(JvmMockFactory.kt:34)
    at io.mockk.impl.instantiation.AbstractMockFactory.newProxy$default(AbstractMockFactory.kt:24)
    at io.mockk.impl.instantiation.AbstractMockFactory.mockk(AbstractMockFactory.kt:59)
    at io.mockk.impl.annotations.JvmMockInitializer.assignMockK(JvmMockInitializer.kt:163)
    at io.mockk.impl.annotations.JvmMockInitializer.initMock(JvmMockInitializer.kt:41)
    at io.mockk.impl.annotations.JvmMockInitializer.initAnnotatedMocks(JvmMockInitializer.kt:24)
    at io.mockk.junit5.MockKExtension.postProcessTestInstance(MockKExtension.kt:181)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$10(ClassBasedTestDescriptor.java:377)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:382)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$11(ClassBasedTestDescriptor.java:377)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:376)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$6(ClassBasedTestDescriptor.java:289)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:288)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$4(ClassBasedTestDescriptor.java:278)
    at java.base/java.util.Optional.orElseGet(Optional.java:364)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$5(ClassBasedTestDescriptor.java:277)
    at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:105)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:104)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:68)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:62)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    at jdk.proxy1/jdk.proxy1.$Proxy2.stop(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
    at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
    at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
    at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)

Cannot invoke "org.springframework.kafka.core.KafkaTemplate.send(org.springframework.messaging.Message)" because "$this.kafkaTemplate" is null
java.lang.NullPointerException: Cannot invoke "org.springframework.kafka.core.KafkaTemplate.send(org.springframework.messaging.Message)" because "$this.kafkaTemplate" is null
    at service.KafkaService.send$suspendImpl(KafkaService.kt:20)
    at service.KafkaService.send(KafkaService.kt)

Here are Mockk dependencies which I am using

    testImplementation("com.ninja-squad:springmockk:4.0.0")
    testImplementation("io.mockk:mockk:1.13.3")

I am working on a Springboot 3.0.1 project which requires JDK 17.

Please help.

Update

I removed the Parameter P from KafkaService and after that the mockk test started running, also changing the class level parameter P to function level parameter of send worked fine i.e.

suspend fun
 send(topic: String, data: P, headers: MutableMap<String, String?>, key: String? = null): SendResult<String, String>?


问:
Github Commit/Sync problem (How to copy commits from one branch to another)
I am not a experienced coder and do the layouting in a two man project.

This is the branch situation on github:

```<code>      _____design2 (0 commits)
     /____design1 (#35 commits ahead of master are good; #36 is faulty)
    /
</code>```

----master
_____coding1

In Visual Studio Code I continued to work on design1 and deleted commit #36 and then continued to add 7 new commits. So Visual Studio Code now tells me to sync by pulling #36 from Github and pushing the 7 new ones. However when I click on sync I get an error.

The faulty commit #36 is not correlated to the other ones.

So I would like to keep the first 35 good commits on Github and the 7 new ones in Visual Studio Code.

This was a lot of work and I am basically lost as manual copy and paste of code would take forever.

What would be the best way to do this. Can I save design1?

best regards
Martin

I tried the following commands in Visual Studio Code in branch design1 (7 commits ahead of the branch on github):

git revert a7dd6c5 (This was the faulty commit #36)
Result: Error because branches are divergent...

git pull
result: Error because branches have different changes

Body:
I am not a experienced coder and do the layouting in a two man project.

This is the branch situation on github:

      _____design2 (0 commits)
     /____design1 (#35 commits ahead of master are good; #36 is faulty)
    /

----master
_____coding1

In Visual Studio Code I continued to work on design1 and deleted commit #36 and then continued to add 7 new commits. So Visual Studio Code now tells me to sync by pulling #36 from Github and pushing the 7 new ones. However when I click on sync I get an error.

The faulty commit #36 is not correlated to the other ones.

So I would like to keep the first 35 good commits on Github and the 7 new ones in Visual Studio Code.

This was a lot of work and I am basically lost as manual copy and paste of code would take forever.

What would be the best way to do this. Can I save design1?

best regards
Martin

I tried the following commands in Visual Studio Code in branch design1 (7 commits ahead of the branch on github):

git revert a7dd6c5 (This was the faulty commit #36)
Result: Error because branches are divergent...

git pull
result: Error because branches have different changes


问:
DataFrame cleanup: join/concatenate non-NaN values when there is NaN in-between rows (spin-off from row with 'unique' record))
I created a data-capturing template. When imported into Python (as DataFrame), I noticed that some of the records spanned multiple rows.

I need to clean up the spanned record (see expected representation).

The 'Entity' column is the anchor column. Currently, it is not the definitive column, as one can see the row(s) underneath with NaN.
NB: Along the line, I'll be dropping the 'Unnamed:' column.

Essentially, for every row where df.Entity.isnull(), the value(s) must be joined to the row above where df.Entity.notnull().

NB: I can adjust the source, however, I'll like to keep the source template because of ease of capturing and #reproducibility.

[dummy representation]

Unnamed: 0
Entity
Country
Naming
Type:
Mode:
Duration
Page
Reg
Elig
Unit
Structure
Notes

6.
Sur...
UK
...Publ
Pros...
FT
Standard
Yes
Guid... 2021
General
All
Intro & discussion...
Formal

NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
Assessment

7.
War...
UK

by Publ...
Retro...
FT
1 yr
Yes
Reg 38...
Staff
All
Covering Doc...

NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
General
NaN
5000 <10000
3-8 publ...

8.
EAng...
UK
Publ...
Retro...
PT
6 mths
Yes
Reg...
General (Cat B)
All
Critical Anal...
Formal as

NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
Staff (Cat A)
NaN
15000
*g...

NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
Edu & LLL l...
NaN
NaN
LLL not...

[expected representation] I expect to have

Unnamed
Entity
Country
Naming
Type:
Mode:
Duration
Page
Reg
Elig-------------
Unit
Structure -----
Notes

6.
Sur...
UK
...Publ
Pros...
FT
Standard
Yes
Guid... 2021
General
All
Intro & discussion...
Formal
 Assessment

7.
War...
UK
by Publ...
Retro...
FT
1 yr
Yes
Reg 38...
Staff
 General
All
Covering Doc...
 5000 <10000
Formal
3-8 publ...

8.
EAng...
UK
Publ...
Retro...
PT
6 mths
Yes
Reg...
General  (Cat B)
Staff (Cat A)
Edu & LLL l...
All
Critical Anal...
15000
Formal as
*g...
LLL not...

My instinct is to test for isnull() on [Entity] column. I would prefer not to do a if...then/'loop' check.

My mind wandered along stack, groupby or stack, merge/join, pop. Not sure these approaches are 'right'.

My preference will be some 'vectorisation' as much as it's possible; taking advantage of pandas' DataFrame

I took note of

Merging Two Rows (one with a value, the other NaN) in Pandas

Pandas dataframe merging rows to remove NaN

Concatenate column values in Pandas DataFrame with "NaN" values

Merge DF of different Sizes with NaN values in between

In my case, my anchor column [Entity] has the key values on one row; however, its values are on one row or span multiple rows.

NB: I'm dealing with one DataFrame and not two df.

I should also mention that I took note of the SO solution that 'explode' newline across multiple rows. This is the opposite for my own scenario. However, I take note as it might provide hints.

Pandas: How to read a DataFrame from excel-file where multiple rows are sometimes separated by line break (\n)

[UPDATE: Walkaround 1]

NB: This walkaround is not a solution. It simply provide an alternate!

With leads from a Medium and a SO post,

I attempted with success reading my dataset directly from the table in the Word document. For this, I installed the python-docx library.

## code snippet; #Note: incomplete
from docx import Document as docs
... ...
document = docs("datasets/IDA..._AppendixA.docx")
def read_docx_table(document, tab_id: int = None, nheader: int = 1, start_row: int = 0):
    ... ...
    data = [[cell.text for cell in row.cells] for i, row in enumerate(table.rows)
        if i >= start_row]
    ... ...
    if nheader == 1:    ## first row as column header
        df = df.rename(columns=df.iloc[0]).drop(df.index[0]).reset_index(drop=True)
    ... ...
    return df
... ...
## parse and show dataframe
df_table = read_docx_table(document, tab_id=3, nheader=1, start_row=0)
df_table
```

The rows are no longer spilling over multiple rows. The columns with newline are now showing the '\n' character.
I can, if I use df['col'].str.replace(), remove newlines '\n' or other delimiters, if I so desire.

Replacing part of string in python pandas dataframe

[dataframe representation: importing and parsing using python-docx library] Almost a true representation of the original table in Word

Unnamed
Entity
Country
Naming
Type:
Mode:
Duration
Page
Reg
Elig-------------
Unit
Structure -----
Notes

6.
Sur...
UK
...Publ
Pros...
FT
Standard
Yes
Guid... 2021
General
All
Intro & discussion...
Formal \n| Assessment

7.
War...
UK
by Publ...
Retro...
FT
1 yr
Yes
Reg 38...
Staff \nGeneral
All
Covering Doc... \n| 5000 <10000
Formal \n| 3-8 publ...

8.
EAng...
UK
Publ...
Retro...
PT
6 mths
Yes
Reg...
General  (Cat B)
Staff (Cat A) \nEdu & LLL l...
All
Critical Anal... \n| 15000
Formal as \n|*g... \n| LLL not...

[UPDATE 2]
After my update: walkaround 1, I saw @J_H comments. Whiltst it is not 'data corruption' in the true sense, it is nonetheless an ETL strategy issue. Thanks @J_H. Absolutely, well-thought-through #design is of the essence.

Going forward, I'll either leave the source template practically as-is with minor modifications and use python-docx as I've used; or

I modify the source template for easy capture in Excel or 'csv' type repository.

Despite the two approaches outlined here or any other, I'm still keen on 'data cleaning code' that can clean-up the df, to give the expected df.

Body:
I created a data-capturing template. When imported into Python (as DataFrame), I noticed that some of the records spanned multiple rows.

I need to clean up the spanned record (see expected representation).

The 'Entity' column is the anchor column. Currently, it is not the definitive column, as one can see the row(s) underneath with NaN.
NB: Along the line, I'll be dropping the 'Unnamed:' column.

Essentially, for every row where df.Entity.isnull(), the value(s) must be joined to the row above where df.Entity.notnull().

NB: I can adjust the source, however, I'll like to keep the source template because of ease of capturing and #reproducibility.

[dummy representation]

Unnamed: 0
Entity
Country
Naming
Type:
Mode:
Duration
Page
Reg
Elig
Unit
Structure
Notes

6.
Sur...
UK
...Publ
Pros...
FT
Standard
Yes
Guid... 2021
General
All
Intro & discussion...
Formal

NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
Assessment

7.
War...
UK

by Publ...
Retro...
FT
1 yr
Yes
Reg 38...
Staff
All
Covering Doc...

NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
General
NaN
5000 <10000
3-8 publ...

8.
EAng...
UK
Publ...
Retro...
PT
6 mths
Yes
Reg...
General (Cat B)
All
Critical Anal...
Formal as

NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
Staff (Cat A)
NaN
15000
*g...

NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
Edu & LLL l...
NaN
NaN
LLL not...

[expected representation] I expect to have

Unnamed
Entity
Country
Naming
Type:
Mode:
Duration
Page
Reg
Elig-------------
Unit
Structure -----
Notes

6.
Sur...
UK
...Publ
Pros...
FT
Standard
Yes
Guid... 2021
General
All
Intro & discussion...
Formal
 Assessment

7.
War...
UK
by Publ...
Retro...
FT
1 yr
Yes
Reg 38...
Staff
 General
All
Covering Doc...
 5000 <10000
Formal
3-8 publ...

8.
EAng...
UK
Publ...
Retro...
PT
6 mths
Yes
Reg...
General  (Cat B)
Staff (Cat A)
Edu & LLL l...
All
Critical Anal...
15000
Formal as
*g...
LLL not...

My instinct is to test for isnull() on [Entity] column. I would prefer not to do a if...then/'loop' check.

My mind wandered along stack, groupby or stack, merge/join, pop. Not sure these approaches are 'right'.

My preference will be some 'vectorisation' as much as it's possible; taking advantage of pandas' DataFrame

I took note of

Merging Two Rows (one with a value, the other NaN) in Pandas

Pandas dataframe merging rows to remove NaN

Concatenate column values in Pandas DataFrame with "NaN" values

Merge DF of different Sizes with NaN values in between

In my case, my anchor column [Entity] has the key values on one row; however, its values are on one row or span multiple rows.

NB: I'm dealing with one DataFrame and not two df.

I should also mention that I took note of the SO solution that 'explode' newline across multiple rows. This is the opposite for my own scenario. However, I take note as it might provide hints.

Pandas: How to read a DataFrame from excel-file where multiple rows are sometimes separated by line break (\n)

[UPDATE: Walkaround 1]

NB: This walkaround is not a solution. It simply provide an alternate!

With leads from a Medium and a SO post,

I attempted with success reading my dataset directly from the table in the Word document. For this, I installed the python-docx library.

## code snippet; #Note: incomplete
from docx import Document as docs
... ...
document = docs("datasets/IDA..._AppendixA.docx")
def read_docx_table(document, tab_id: int = None, nheader: int = 1, start_row: int = 0):
    ... ...
    data = [[cell.text for cell in row.cells] for i, row in enumerate(table.rows)
        if i >= start_row]
    ... ...
    if nheader == 1:    ## first row as column header
        df = df.rename(columns=df.iloc[0]).drop(df.index[0]).reset_index(drop=True)
    ... ...
    return df
... ...
## parse and show dataframe
df_table = read_docx_table(document, tab_id=3, nheader=1, start_row=0)
df_table

The rows are no longer spilling over multiple rows. The columns with newline are now showing the '\n' character.
I can, if I use df['col'].str.replace(), remove newlines '\n' or other delimiters, if I so desire.

Replacing part of string in python pandas dataframe

[dataframe representation: importing and parsing using python-docx library] Almost a true representation of the original table in Word

Unnamed
Entity
Country
Naming
Type:
Mode:
Duration
Page
Reg
Elig-------------
Unit
Structure -----
Notes

6.
Sur...
UK
...Publ
Pros...
FT
Standard
Yes
Guid... 2021
General
All
Intro & discussion...
Formal \n| Assessment

7.
War...
UK
by Publ...
Retro...
FT
1 yr
Yes
Reg 38...
Staff \nGeneral
All
Covering Doc... \n| 5000 <10000
Formal \n| 3-8 publ...

8.
EAng...
UK
Publ...
Retro...
PT
6 mths
Yes
Reg...
General  (Cat B)
Staff (Cat A) \nEdu & LLL l...
All
Critical Anal... \n| 15000
Formal as \n|*g... \n| LLL not...

[UPDATE 2]
After my update: walkaround 1, I saw @J_H comments. Whiltst it is not 'data corruption' in the true sense, it is nonetheless an ETL strategy issue. Thanks @J_H. Absolutely, well-thought-through #design is of the essence.

Going forward, I'll either leave the source template practically as-is with minor modifications and use python-docx as I've used; or

I modify the source template for easy capture in Excel or 'csv' type repository.

Despite the two approaches outlined here or any other, I'm still keen on 'data cleaning code' that can clean-up the df, to give the expected df.


问:
How do I include endpoints with query params when configuring requestMatchers in Spring security 6?
I have the following code...

import com.purepm.admin.services.authentication.AudienceValidator;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.oauth2.core.DelegatingOAuth2TokenValidator;
import org.springframework.security.oauth2.core.OAuth2TokenValidator;
import org.springframework.security.oauth2.jwt.*;
import org.springframework.security.web.SecurityFilterChain;

@EnableWebSecurity
@Configuration
public class SecurityConfig{

    @Value("${auth0.audience}")
    private String audience;

    @Value("${spring.security.oauth2.resourceserver.jwt.issuer-uri}")
    private String issuer;
    @Bean
    JwtDecoder jwtDecoder() {
        NimbusJwtDecoder jwtDecoder = (NimbusJwtDecoder)
                JwtDecoders.fromOidcIssuerLocation(issuer);

        OAuth2TokenValidator<Jwt> audienceValidator = new AudienceValidator(audience);
        OAuth2TokenValidator<Jwt> withIssuer = JwtValidators.createDefaultWithIssuer(issuer);
        OAuth2TokenValidator<Jwt> withAudience = new DelegatingOAuth2TokenValidator<>(withIssuer, audienceValidator);

        jwtDecoder.setJwtValidator(withAudience);

        return jwtDecoder;
    }
    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http.authorizeHttpRequests()
                .requestMatchers("/").permitAll()
                .requestMatchers("/person").hasAuthority("SCOPE_blahablah")
                .anyRequest().authenticated();

        return http.build();
    }
}
```
<p>But when I use the following command to run the request <code>curl http://localhost:8080/person -v</code> I see the expected 403...</p>
```*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /person HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 403
< Set-Cookie: JSESSIONID=EFD9C400D91760FE8FA2119AC2EB382B; Path=/; HttpOnly
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 0
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< Content-Length: 0
< Date: Wed, 11 Jan 2023 21:45:16 GMT
<
* Connection #0 to host localhost left intact
```

This is as expected since I am not providing an Authorization header (Although I would expect a 401).

But when I add the query param like curl http://localhost:8080/person?email=me@me.co it just lets it right through and I get a 200. Is there a way to use the query string to enforce the 403 when there is a query param as well?

Body:
I have the following code...

import com.purepm.admin.services.authentication.AudienceValidator;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.oauth2.core.DelegatingOAuth2TokenValidator;
import org.springframework.security.oauth2.core.OAuth2TokenValidator;
import org.springframework.security.oauth2.jwt.*;
import org.springframework.security.web.SecurityFilterChain;

@EnableWebSecurity
@Configuration
public class SecurityConfig{

    @Value("${auth0.audience}")
    private String audience;

    @Value("${spring.security.oauth2.resourceserver.jwt.issuer-uri}")
    private String issuer;
    @Bean
    JwtDecoder jwtDecoder() {
        NimbusJwtDecoder jwtDecoder = (NimbusJwtDecoder)
                JwtDecoders.fromOidcIssuerLocation(issuer);

        OAuth2TokenValidator<Jwt> audienceValidator = new AudienceValidator(audience);
        OAuth2TokenValidator<Jwt> withIssuer = JwtValidators.createDefaultWithIssuer(issuer);
        OAuth2TokenValidator<Jwt> withAudience = new DelegatingOAuth2TokenValidator<>(withIssuer, audienceValidator);

        jwtDecoder.setJwtValidator(withAudience);

        return jwtDecoder;
    }
    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http.authorizeHttpRequests()
                .requestMatchers("/").permitAll()
                .requestMatchers("/person").hasAuthority("SCOPE_blahablah")
                .anyRequest().authenticated();

        return http.build();
    }
}

But when I use the following command to run the request curl http://localhost:8080/person -v I see the expected 403...

*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /person HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 403
< Set-Cookie: JSESSIONID=EFD9C400D91760FE8FA2119AC2EB382B; Path=/; HttpOnly
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 0
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< Content-Length: 0
< Date: Wed, 11 Jan 2023 21:45:16 GMT
<
* Connection #0 to host localhost left intact

This is as expected since I am not providing an Authorization header (Although I would expect a 401).

But when I add the query param like curl http://localhost:8080/person?email=me@me.co it just lets it right through and I get a 200. Is there a way to use the query string to enforce the 403 when there is a query param as well?


问:
Vertex AI Sequential Tensorflow Endpoint Deployment Dimensionality error
My tensorflow model is set up with the following layers:

```<code>NN_model = Sequential()
NN_model.add(Dense(10, kernel_initializer = 'normal', activation = 'relu'))
NN_model.add(Dense(8, kernel_initializer = 'normal', activation = 'relu'))
NN_model.add(Dense(8, kernel_initializer = 'normal', activation = 'relu'))
NN_model.add(Dense(6, kernel_initializer = 'normal', activation = 'relu'))
NN_model.add(Dense(1, kernel_initializer = 'normal', activation = 'linear'))
</code>```

I have my model set up in Vertex AI, and have it registered as well as set up with the proper bucket locations. I can deploy my endpoint fine, but every time I try to predict with the endpoint I get this error.

error: In[0] and In[1] has different ndims: [10] vs. [10,10]\n\t [[{{function_node __inference__wrapped_model_724923}}{{node sequential_2/dense_10/Relu}}]]

My training dataset has 10 features. The dataset I am trying to use to predict also has 10 features (1,10) Shape. When I try to predict the same dataset without deploying the endpoint (Locally from the notebook), I do not get any error.

Body:
My tensorflow model is set up with the following layers:

NN_model = Sequential()
NN_model.add(Dense(10, kernel_initializer = 'normal', activation = 'relu'))
NN_model.add(Dense(8, kernel_initializer = 'normal', activation = 'relu'))
NN_model.add(Dense(8, kernel_initializer = 'normal', activation = 'relu'))
NN_model.add(Dense(6, kernel_initializer = 'normal', activation = 'relu'))
NN_model.add(Dense(1, kernel_initializer = 'normal', activation = 'linear'))

I have my model set up in Vertex AI, and have it registered as well as set up with the proper bucket locations. I can deploy my endpoint fine, but every time I try to predict with the endpoint I get this error.

error: In[0] and In[1] has different ndims: [10] vs. [10,10]\n\t [[{{function_node __inference__wrapped_model_724923}}{{node sequential_2/dense_10/Relu}}]]

My training dataset has 10 features. The dataset I am trying to use to predict also has 10 features (1,10) Shape. When I try to predict the same dataset without deploying the endpoint (Locally from the notebook), I do not get any error.


问:
Is it possible to override the behavior of tqdm.auto in a loaded library?
I am using an Emacs interface to Jupyter notebooks which means that even though tqdm detects that I am in a Jupyter notebook, I would like it to update the progress bar as if it were in a terminal (i.e. I use from tqdm import tqdm) in my Emacs interface.

However, some libraries (e.g. Huggingface) automatically detect whether or not I am in a notebook and use the specified tqdm progress bar. I would like to override this to use tqdm.std. Is this possible?

My current fix is to go into the source code and replace: #from tqdm.auto import tqdm with from tqdm import tqdm everywhere.


问:
pgAgent post json to PostgreSQL database
I am looking to update JSON data in a PostgreSQL database after the service has been updated or after 28 days. and is it possible to use pgAgent?

I need to bring FAA gis JSON into PostgreSQL. https://services6.arcgis.com/ssFJjBXIUyZDrSYZ/arcgis/rest/services/Digital_Obstacle_File/FeatureServer/0. But need to be up to date so the code should run every 28 days or look for a change in the JSON.

I am trying to run a job that pulls in the json to the database.


问:
Import modules with eval in JavaScript
Is it possible to import modules with 'import' inside an eval in JavaScript?

Something like this idk

```<code>let test = index;

eval(`import { a } from './${test}.js'`);
</code>```

Title: Import modules with eval in JavaScript

Body:
Is it possible to import modules with 'import' inside an eval in JavaScript?

Something like this idk

let test = index;

eval(`import { a } from './${test}.js'`);


问:
How can I provide input field arguments with apollo federation 2?
I am trying to federate two of my micro services with apollo gql federation 2.
I have successfully connected the two services through the federation with the following schemas:

Subgraph1 - Product

```<code>type Product @key(fields: "id") {
    id: ID!
    title: String!
    description: String
    price: Int!
    category: [Category!]
  }

type Category @key(fields: "id") {
    id: ID!
  }

type Query {
    product(id: ID!): Product
  }
</code>```

Subgraph 2 - Category

```<code>type Category @key(fields: "id") {
    id: ID!
    title: String
  }
</code>```

and the following query

```<code>query Product($productId: ID!) {
  product(id: $productId) {
    id
    title
    category {
      id
      title
    }
  }
}
</code>```

gives a desired result

However, what if I wanted to add some filter on the returned categories for a given product. Lets say I only wanted to have the ones with title "sport", so the query would look like this instead:

```<code>query Product($productId: ID!) {
  product(id: $productId) {
    id
    title
    category(searchTerm: "sport") {
      id
      title
    }
  }
}
</code>```

A normal way of doing the input argument would be simply just

```<code>type Product @key(fields: "id") {
    id: ID!
    title: String!
    description: String
    price: Int!
    category(searchTerm: String): [Category!]
  }
</code>```

Is this achievable when federating the services? I am not sure how the input field is provided to the second subgraph?

I tried to add the input as a part of the type in the first subgraph, however it does not seem to pass the search term to the next graph.

Body:
I am trying to federate two of my micro services with apollo gql federation 2.
I have successfully connected the two services through the federation with the following schemas:

Subgraph1 - Product

type Product @key(fields: "id") {
    id: ID!
    title: String!
    description: String
    price: Int!
    category: [Category!]
  }

type Category @key(fields: "id") {
    id: ID!
  }

type Query {
    product(id: ID!): Product
  }

Subgraph 2 - Category

type Category @key(fields: "id") {
    id: ID!
    title: String
  }

and the following query

query Product($productId: ID!) {
  product(id: $productId) {
    id
    title
    category {
      id
      title
    }
  }
}

gives a desired result

However, what if I wanted to add some filter on the returned categories for a given product. Lets say I only wanted to have the ones with title "sport", so the query would look like this instead:

query Product($productId: ID!) {
  product(id: $productId) {
    id
    title
    category(searchTerm: "sport") {
      id
      title
    }
  }
}

A normal way of doing the input argument would be simply just

type Product @key(fields: "id") {
    id: ID!
    title: String!
    description: String
    price: Int!
    category(searchTerm: String): [Category!]
  }

Is this achievable when federating the services? I am not sure how the input field is provided to the second subgraph?

I tried to add the input as a part of the type in the first subgraph, however it does not seem to pass the search term to the next graph.


问:
How can I send an api PATCH request with only the fields that have been modified from my vue application?
I have a vue application with a form that fetches data from my backend api.  My api has an endpoint that accepts PATCH requests and when using postman to test it works great.

When I try from my vue app it always sends every field, even if the field hasn't been modified.  I realize it does this because I am using v-model for each form field to a pinia state object and I'm sending the entire object during the PATCH request.  I really only want to send the fields that have been modified.  How can I cleanly accomplish this?

Here is my component for my form:

// @/components/ApplicationForm.vue

<template>
  <input v-model="application.name" class="input" type="text" />
  <input v-model="application.location" class="input" type="text" />
</template>

```
<p>I use a pinia action that uses a composable to get and update the data for the form.  Here is my store:</p>
<pre class="lang-js prettyprint-override"><code>// @/stores/ApplicationStore.js

import { defineStore } from "pinia";
import router from "@/router";
import { getApplications, updateApplication } from "@/composables/applications";

export const useApplicationStore = defineStore("application", {
  state: () => ({
    applications: [], // all applications
    application: {}, // selected application to create or modify
    loading: false,
    success: "",
    error: "",
  }),
  actions: {
    async fetchApplications() {
      this.loading = true;
      this.applications = [];
      const { applications, error } = await getApplications();

      this.applications = applications;
      this.error = error;
      this.loading = false;
    },
    async updateApplication() {
      this.loading = true;
      this.success = "";
      const { application, results, error } = await updateApplication(this.application);
      this.application = application;
      this.error = error;
      this.loading = false;

      if (results.status === 200) {
        this.success = "Successfully Updated";
      }
    }
  }
});
</code>```

Here is the function from my composable that runs the update and sends the PATCH request:

// @/composables/applications.js

import axios from "axios";

let applications = [];
let application = {};
let error = "";
const url = process.env.VUE_APP_API_URL + "api/applications";

export const updateApplication = async (payload) => {
  let results = {};

  try {
    error = "";
    results = await axios.patch(`${url}/${payload.id}`, payload, { responseType: "json" });
    application = results.data;

  } catch (err) {
    console.log("inside catch");
    error = err;
  }

  return { application, results, error };
};
```

I feel like this should be easier than I'm anticipating.  I'm new to using pinia and sending these patch requests.  I don't know if it's exhaustion, or just my poverty of knowledge preventing me from clearly solving this.  Many thanks.

Body:
I have a vue application with a form that fetches data from my backend api.  My api has an endpoint that accepts PATCH requests and when using postman to test it works great.

When I try from my vue app it always sends every field, even if the field hasn't been modified.  I realize it does this because I am using v-model for each form field to a pinia state object and I'm sending the entire object during the PATCH request.  I really only want to send the fields that have been modified.  How can I cleanly accomplish this?

Here is my component for my form:

// @/components/ApplicationForm.vue

<template>
  <input v-model="application.name" class="input" type="text" />
  <input v-model="application.location" class="input" type="text" />
</template>

I use a pinia action that uses a composable to get and update the data for the form.  Here is my store:

// @/stores/ApplicationStore.js

import { defineStore } from "pinia";
import router from "@/router";
import { getApplications, updateApplication } from "@/composables/applications";

export const useApplicationStore = defineStore("application", {
  state: () => ({
    applications: [], // all applications
    application: {}, // selected application to create or modify
    loading: false,
    success: "",
    error: "",
  }),
  actions: {
    async fetchApplications() {
      this.loading = true;
      this.applications = [];
      const { applications, error } = await getApplications();

      this.applications = applications;
      this.error = error;
      this.loading = false;
    },
    async updateApplication() {
      this.loading = true;
      this.success = "";
      const { application, results, error } = await updateApplication(this.application);
      this.application = application;
      this.error = error;
      this.loading = false;

      if (results.status === 200) {
        this.success = "Successfully Updated";
      }
    }
  }
});

Here is the function from my composable that runs the update and sends the PATCH request:

// @/composables/applications.js

import axios from "axios";

let applications = [];
let application = {};
let error = "";
const url = process.env.VUE_APP_API_URL + "api/applications";

export const updateApplication = async (payload) => {
  let results = {};

  try {
    error = "";
    results = await axios.patch(`${url}/${payload.id}`, payload, { responseType: "json" });
    application = results.data;

  } catch (err) {
    console.log("inside catch");
    error = err;
  }

  return { application, results, error };
};

I feel like this should be easier than I'm anticipating.  I'm new to using pinia and sending these patch requests.  I don't know if it's exhaustion, or just my poverty of knowledge preventing me from clearly solving this.  Many thanks.


问:
cv2.imread path integrity warning
I'm trying to open a jpg file on Jupyter Notebook using this code:

```<code>import cv2
img = cv2.imread('/Users/redacted/Desktop/1__M_Left_index_finger.jpg')
</code>```

When I run it, I get the following warning:

[ WARN:0@2119.814] global /private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_506zufg7xt/croots/recipe/opencv-suite_1664548331847/work/modules/imgcodecs/src/loadsave.cpp (239) findDecoder imread_('/Users/redacted/Desktop/1__M_Left_index_finger.jpg'): can't open/read file: check file path/integrity

I've tried several things to get around it:

Changing the file type from jpg to bmp and png

Moving the file into/out of folders

Using \ instead of /

I'm running this through anaconda, so I've updated anaconda

Uninstalling and reinstalling anaconda's opencv package

Using the following code in place of the above

```<code>path = r'C:Users/redacted/Desktop/1__M_Left_index_finger.jpg'
img = cv2.imread(path)
cv2.imshow('image', img)
</code>```

Everything I've read indicates that something is wrong with the path. But I've checked my spelling and directory order dozens of times at this point. Regardless, I get the same warning. Any thoughts on how to fix this? Is it just a simple syntax error that I'm not seeing?

Title: cv2.imread path integrity warning

Body:
I'm trying to open a jpg file on Jupyter Notebook using this code:

import cv2
img = cv2.imread('/Users/redacted/Desktop/1__M_Left_index_finger.jpg')

When I run it, I get the following warning:

[ WARN:0@2119.814] global /private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_506zufg7xt/croots/recipe/opencv-suite_1664548331847/work/modules/imgcodecs/src/loadsave.cpp (239) findDecoder imread_('/Users/redacted/Desktop/1__M_Left_index_finger.jpg'): can't open/read file: check file path/integrity

I've tried several things to get around it:

Changing the file type from jpg to bmp and png

Moving the file into/out of folders

Using \ instead of /

I'm running this through anaconda, so I've updated anaconda

Uninstalling and reinstalling anaconda's opencv package

Using the following code in place of the above

path = r'C:Users/redacted/Desktop/1__M_Left_index_finger.jpg'
img = cv2.imread(path)
cv2.imshow('image', img)

Everything I've read indicates that something is wrong with the path. But I've checked my spelling and directory order dozens of times at this point. Regardless, I get the same warning. Any thoughts on how to fix this? Is it just a simple syntax error that I'm not seeing?