class_docstr: This test Does few checks that the core user interfaces are working :
  1. It validates we can call `current.card.refresh` without any errors.
  2. It validates if the data updates that are getting shipped are correct.
  
  How will it do it :
  
  1. In step code:
      1. We create a random array of strings.
      2. We call `current.card.refresh` with the array.
      3. We check if the card is present given that we have called referesh and the card
          should have reached the backend in some short period of time
      4. Keep adding new data to the array and keep calling refresh.
      5. The data-update that got shipped should *atleast* be a subset the actual data present in the runtime code.
  2. In check_results:
      1. We check if the data that got shipped can be access post task completion
      2. We check if the data that got shipped is a subset of the actual data created during the runtime code.
class_docstr_tok: ["This","test","Does","few","checks","that","the","core","user","interfaces","are","working",":","1",".","It","validates","we","can","call","`","current.card.refresh","`","without","any","errors",".","2",".","It","validates","if","the","data","updates","that","are","getting","shipped","are","correct",".","How","will","it","do","it",":","1",".","In","step","code",":","1",".","We","create","a","random","array","of","strings",".","2",".","We","call","`","current.card.refresh","`","with","the","array",".","3",".","We","check","if","the","card","is","present","given","that","we","have","called","referesh","and","the","card","should","have","reached","the","backend","in","some","short","period","of","time","4",".","Keep","adding","new","data","to","the","array","and","keep","calling","refresh",".","5",".","The","data-update","that","got","shipped","should","*","atleast","*","be","a","subset","the","actual","data","present","in","the","runtime","code",".","2",".","In","check_results",":","1",".","We","check","if","the","data","that","got","shipped","can","be","access","post","task","completion","2",".","We","check","if","the","data","that","got","shipped","is","a","subset","of","the","actual","data","created","during","the","runtime","code","."]
code: def check_results(self, flow, checker):
      def _array_is_a_subset(arr1, arr2):
          return set(arr1).issubset(set(arr2))
  
      if checker.__class__.__name__ != "MetadataCheck":
          return
      run = checker.get_run()
      for step in flow:
          meta_check_dict = checker.artifact_dict_if_exists(
              step.name, "final_data"
          )
          # Which ever steps ran the actual card testing code
          # contains the `final_data` attribute and the `step_name` attribute.
          # If these exist then we can succesfully validate the card data since it is meant to exist.
          step_done_check_dict = checker.artifact_dict_if_exists(
              step.name, "step_name"
          )
          for task_id in step_done_check_dict:
              if (
                  len(step_done_check_dict[task_id]) == 0
                  or step_done_check_dict[task_id]["step_name"]
                  != step.name
              ):
                  print(
                      "Skipping task pathspec %s"
                      % run[step.name][task_id].pathspec
                  )
                  continue
              # If the `step_name` attribute was set then surely `final_data` will also be set;
              data_obj = meta_check_dict[task_id]["final_data"]
              card_present, card_data = checker.get_card_data(
                  step.name,
                  task_id,
                  "test_refresh_card",
                  card_id="refresh_card",
              )
              assert_equals(card_present, True)
              data_has_latest_artifact = _array_is_a_subset(
                  data_obj["arr"], card_data["data"]["user"]["arr"]
              )
              assert_equals(data_has_latest_artifact, True)
              print(
                  "Succesfully validated task pathspec %s"
                  % run[step.name][task_id].pathspec
              )
  
imports: from metaflow_test import MetaflowTest, ExpectationFailed, steps, tag
label_desc: Use image node_id 3 for calling the CardWithRefreshTest obj's underlying member method code with example usage: obj.check_results(flow, checker) and returns: set